London 9 Turing- Farnoosh Moayeri- JavaScript- Week 3 - #205
Conversation
|
@qingwei91 Hi Qing, Could you review this homework, please? Thank you in advance:) |
| arr.push(i * 2); | ||
| i++; | ||
| } | ||
| console.log(arr.join()); |
| function potentialHeadlines(allArticleTitles) { | ||
| // TODO | ||
| newArticleArray =[]; | ||
| for(let title of allArticleTitles){ |
There was a problem hiding this comment.
This impl is correct, but you can try to implement it in a simpler way using Array filter method
| */ | ||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let shortestTitle = allArticleTitles[0]; |
There was a problem hiding this comment.
Hint, you might be able to implement this using sorting algorithm, available in Array
| // TODO | ||
| } | ||
| let newArrayOfHeadlines = []; | ||
| for(let allTitles of allArticleTitles){ |
There was a problem hiding this comment.
Similarly, you can try to use Array.filter to implement this
| for(let price of closingPrices){ | ||
| sum += price; | ||
| } | ||
| let averagePrice = sum / closingPrices.length; |
There was a problem hiding this comment.
Can you try to factor the calc of average price into a function?
| // TODO | ||
| let priceChanges = []; | ||
| for(let closingPrices of closingPricesForAllStocks){ | ||
| let priceChange = closingPrices[closingPrices.length - 1] -closingPrices[0]; |
There was a problem hiding this comment.
Likewise, can you try to factor out this into a function?
| const highestRated = []; | ||
| for(let book of books){ | ||
| const {title, genre, rating} = book; | ||
| if(!highestRated[genre] || rating > highestRated[genre].rating){ |
There was a problem hiding this comment.
Hmm, is highestRated[genre] correct?
is highestRated an array or object?
No description provided.