London 10 Maksim Lukianenko JavaScript-Core-1-Coursework-Week3 - #218
London 10 Maksim Lukianenko JavaScript-Core-1-Coursework-Week3#218maxbmaapc wants to merge 8 commits into
Conversation
|
|
||
| function getTemperatureReport(cities) { | ||
| // TODO | ||
| const temperatureReport = []; |
| */ | ||
| function potentialHeadlines(allArticleTitles) { | ||
| // TODO | ||
| const headTitle = allArticleTitles.filter(title => title.length < 65); |
There was a problem hiding this comment.
This is a nice implementation!
I would ask you double-check one thing: the comment above says "65 characters or less". Could you update this code to meet that requirement?
| */ | ||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let shortestTitle = allArticleTitles[0]; |
| */ | ||
| function averageNumberOfCharacters(allArticleTitles) { | ||
| // TODO | ||
| const articleSum = allArticleTitles.reduce((acc, val) => acc + val.length, 0); |
There was a problem hiding this comment.
Nice use of reduce here!
| */ | ||
| function getAveragePrices(closingPricesForAllStocks) { | ||
| // TODO | ||
| let currentStock = []; |
There was a problem hiding this comment.
This looks good 😄
A suggestion: you might be able to improve the readability of this code by creating a separate function which calculates the average for a single stock. Each function will be a little bit simpler, and the new function will have a name - so we can more easily see what it's doing.
|
|
||
| for (let i = 0; i < closingPricesForAllStocks.length; i++) { | ||
| const numberOfPrices = closingPricesForAllStocks[i].length - 1; | ||
| const firstDay = closingPricesForAllStocks[i].at(0); |
There was a problem hiding this comment.
It's also possible here to use bracket notation twice. For example, closingPricesForAllStocks[i][0].
| for (let i = 0; i < closingPricesForAllStocks.length; i++) { | ||
| const stockName = stocks[i].toUpperCase(); | ||
| const stockPrices = closingPricesForAllStocks[i]; | ||
| const highestPrice = Math.max(...stockPrices).toFixed(2); |
There was a problem hiding this comment.
Nice use of Math.max here 👍
|
Overall, this is very good work - great job! |
No description provided.