ZA2 - Anthony Mogotlane - JavaScript-Core-1-Coursework - W3 - #53
ZA2 - Anthony Mogotlane - JavaScript-Core-1-Coursework - W3#53AnthonyMogotlane wants to merge 6 commits into
Conversation
dschouw-CYF
left a comment
There was a problem hiding this comment.
Thank you for your submission Anthony, awesome work!
|
|
||
| function evenNumbers(n) { | ||
| // TODO | ||
| let res = []; |
|
|
||
| function getTemperatureReport(cities) { | ||
| // TODO | ||
| return cities.map(town => `The temperature in ${town} is ${temperatureService(town)} degrees`) |
|
|
||
| function getRandomNumberGreaterThan50() { | ||
| // TODO - implement using a do-while loop | ||
| let rand = generateRandomNumber(); |
There was a problem hiding this comment.
The function getRandomNumberGreaterThan50() invokes generateRandomNumber() only once.
The do/while loop then executes until the result of the generateRandomNumber() returns a value greater than zero.
Will the do/while loop ever complete?
| */ | ||
| function potentialHeadlines(allArticleTitles) { | ||
| // TODO | ||
| return allArticleTitles.filter(title => { |
There was a problem hiding this comment.
Good use of .filter().
Filter is a predicate function , so you can also just return the result of a boolean evaluation and it should still work.
Well done
| */ | ||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let num = Math.min(...allArticleTitles.map(title => title.split(" ").length)); |
| */ | ||
| function getAveragePrices(closingPricesForAllStocks) { | ||
| // TODO | ||
| return closingPricesForAllStocks.map(priceArr => { |
| return `The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${Math.max(...priceArr).toFixed(2)}`; | ||
| }) | ||
| } | ||
| console.log(highestPriceDescriptions(CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS, STOCKS)); |
There was a problem hiding this comment.
Really well done on your solutions for this exercise Anthony 🔥
| Using a loop, complete the function below so it returns the factorial of the number being passed in. | ||
| */ | ||
|
|
||
| // Solved it using recursion instead of a loop |
There was a problem hiding this comment.
👀 Much more elegant than the official solution 🤣
No description provided.