London Class 8 - Matilda Ako - JS Core 1 Coursework - Week 3 - #24
London Class 8 - Matilda Ako - JS Core 1 Coursework - Week 3#24MatildaAko wants to merge 8 commits into
Conversation
|
@haack My work is ready for review |
haack
left a comment
There was a problem hiding this comment.
Really nice 🚀 I've commented a few extension thoughts on how to make a couple of solutions slightly more concise or to explore another way to solve them.
| for (title of allArticleTitles) { | ||
| titles.push(title.length); | ||
| } | ||
| let total = titles.reduce((a, b) => { |
There was a problem hiding this comment.
Nice! I'd recommend avoiding very short variable names in a reduce because it can make it hard to know what they refer to.
Also does reduce make sense to you? Can you think of other situations where reduce is helpful?
| let total = titles.reduce((a, b) => { | ||
| return a + b; | ||
| }) | ||
| return parseInt(total / titles.length) |
| function averageNumberOfCharacters(allArticleTitles) { | ||
| // TODO | ||
| let titles = []; | ||
| for (title of allArticleTitles) { |
There was a problem hiding this comment.
If you want a little extension you can try writing this function without the for loop step. Tip: have a think about how you can do it with just the reduce function below!
| let closingPrices = closingPricesForAllStocks; | ||
| let averagePrices = []; | ||
| for (let prices of closingPrices) { | ||
| let total = prices.reduce((a, b) => { |
There was a problem hiding this comment.
Same as above about short variable names
| (Apple's price on the 5th day) - (Apple's price on the 1st day) = 172.99 - 179.19 = -6.2 | ||
| The price change value should be rounded to 2 decimal places, and should be a number (not a string) | ||
| */ | ||
| function rounded(num) { |
| // TODO | ||
| } | ||
| let closingPrices = closingPricesForAllStocks; | ||
| let stock = stocks; |
| let stock = stocks; | ||
| let highestArr = []; | ||
|
|
||
| for (let i = 0; i < closingPrices.length; i++) { |
There was a problem hiding this comment.
This looks good. Can you think of another way how you could find the highest without a for loop? (tip: what if you could easily get the highest element and lowest element)
| } | ||
| let result = num.reduce((a, b) => { | ||
| return a * b; | ||
| }) |
There was a problem hiding this comment.
There is a more concise way to do this. (Tip: how could you do this without the reduce and only using the while loop above?)
No description provided.