Manchester NW5-Doris Siu-JavaScript1-Week3#124
Manchester NW5-Doris Siu-JavaScript1-Week3#124Doris-Siu wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
| return sum; | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
I think You need the loop to add up the first n even numbers,
starting at 0. So if n=3, you need to add up 0+2+4. If n=10 you
need to add up 0+2+4+6+8+10+12+14+16+18.
| let arr = []; | ||
| for (let item of cities) { | ||
| let temp = temperatureService(item); | ||
| arr.push (`The temperature in ${item} is ${temp} degrees`); | ||
| } | ||
| return arr; |
There was a problem hiding this comment.
really nice solution & use of template literals :) could you think of renaming your arr variable to something more descriptive? For example let cityTemperatures
| result = generateRandomNumber(); | ||
| } while (result <= 50); | ||
|
|
||
| return result; |
There was a problem hiding this comment.
really good use of a do-while loop, well done
| let numTitleArr = []; | ||
| let conditions = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]; | ||
| for (let title of allArticleTitles) { | ||
| if (conditions.some((el) => title.includes(el))) { |
There was a problem hiding this comment.
this works, but you could use regex so you don't have to type out an array of the conditions :) for example:
if (/\d/.test(title)) {
numTitleArr.push(title);
}
\d is used to test for numbers present - this is a good site for playing around with regex https://regex101.com/
| sum += strLength; | ||
| } | ||
| let average = sum / totalOfArticle; | ||
| return Math.round(average); |
| let averageOfStock = []; | ||
| let sum = 0; | ||
| for (let item of closingPricesForAllStocks) { | ||
| for (let element of item) { |
There was a problem hiding this comment.
good job using 2 loops here to reach your solution
| let priceChange = item[4] - item[0]; | ||
| let formattedPriceChange = parseFloat(priceChange.toFixed(2)); | ||
| priceChangeOfStock.push(formattedPriceChange); | ||
| priceChange = 0; |
There was a problem hiding this comment.
no need to set priceChange as 0 here, as priceChange is being defined with each iteration
| } | ||
|
|
||
| return describingArr; | ||
| } |
There was a problem hiding this comment.
well done on solving this! you could reduce your amount of for loops, by just having one loop which loops through the array of CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS and then uses stocks[i] to select the relevant stock
No description provided.