WM4_Dawit-Abraha_JavaScript-Core-1_Week-3 - #92
Conversation
| let array = allArticleTitles[0].split(" ").length; | ||
| let spaceCount; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| wordCount = allArticleTitles[i].split(" ").length; |
There was a problem hiding this comment.
I suggest to add .trim() method before split ,Because if there is any space at first or in the end of string it will wrongly add to the number of words
| i++ | ||
| } while (n > evenNum.length) | ||
|
|
||
| let sum = evenNum.reduce((acc, curr) => acc + curr, 0); |
There was a problem hiding this comment.
I like that you used reduce method here
|
|
||
| // TODO Use a for-of loop to capitalise and output each letter in the string seperately. | ||
| let str = "codeyourfuture"; | ||
| for (arr of str){ |
There was a problem hiding this comment.
it would be nice to declare variable - arr
| */ | ||
| function headlinesWithNumbers(allArticleTitles) { | ||
| // TODO | ||
| return allArticleTitles.filter(headline => /[0-9]/.test(headline)); |
There was a problem hiding this comment.
Why do you like it? What is appealing about this code?
There was a problem hiding this comment.
My comment is a sample of how beginners comment who make a review for beginners))
I liked that it fits in one line and it is clear what is going on.
|
|
||
| function potentialHeadlines(allArticleTitles) { | ||
| // TODO | ||
| return allArticleTitles.filter(title => title.length <= 65) |
There was a problem hiding this comment.
Nice use of .filter(). Why did you chose this solution vs the commented out one?
|
|
||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let array = allArticleTitles[0].split(" ").length; |
There was a problem hiding this comment.
What do you think will happen on this line of code if there are no articles?
Naming is hard. What data does the variable array contain? Can you think of a better variable name?
| let array = allArticleTitles[0].split(" ").length; | ||
| let spaceCount; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| wordCount = allArticleTitles[i].split(" ").length; |
| function getAveragePrices(closingPricesForAllStocks) { | ||
| // TODO | ||
| let arr = []; | ||
| let average = 0; |
There was a problem hiding this comment.
What is the benefit of defining this variable outside the for loop?
| const sortedPrices = closingPricesForAllStocks.map((prices) => | ||
| prices.sort((a, b) => b - a) | ||
| ); | ||
| return sortedPrices.map((price, index) => { |
There was a problem hiding this comment.
Nice use of .map() 😄 why did you go with this vs the commented out code?
No description provided.