Manchester NW5_ Adiba Belayete_JS-01_WEEK_03 - #151
Conversation
| for ( let city of cities){ | ||
| array.push(`The temperature in ${city} is ${temperatureService(city)} degrees`); | ||
| } | ||
| return array; |
There was a problem hiding this comment.
really nice solution & good use of template literals. Could you think of a more explanatory variable name to use here rather than array?
| } | ||
| while ( number <= 50) | ||
| return number | ||
|
|
| } else if (allArticleTitles[i].length === 0 ){ | ||
| sortedArticleTitles = [] | ||
| } |
There was a problem hiding this comment.
no need for this else if statement here - are you trying to put a check in for allArticleTitles.length being 0? If so the loop would not run as i < allArticleTitles.length would equate to i < 0 and sortedArticleTitles would get returned as an empty array :)
There was a problem hiding this comment.
Hi, yeah I was trying to check for an empty array. So if the input is an empty array then the return should be empty. Now it makes sense that I should not put else if. thank u so much. I am updating my solution.
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| if (allArticleTitles[i].length < fewestWordArticle.length) { | ||
| fewestWordArticle = allArticleTitles[i]; |
There was a problem hiding this comment.
this is so close! this is a really good solution for checking for the fewest letters, but here we are checking for the fewest words. Using .split(" ") here would help with this, for example:
if (allArticleTitles[i].split(" ").length < fewestWordArticle.split(" ").length) {
There was a problem hiding this comment.
thank you so much. I got the point.
| // TODO | ||
| let newArray = []; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| if (/[0-9]/g.test(allArticleTitles[i])) { |
There was a problem hiding this comment.
using regex here makes sense, well done. You can also use \d for checking for digits, I find this site really useful for trying out different regex patterns https://regex101.com/
| (sum += allArticleTitles[i].length) / allArticleTitles.length; | ||
| } | ||
| return Math.floor(avgCharacter); | ||
| } |
There was a problem hiding this comment.
nice job! remember to remove comments that are no longer relevant when you have reached your solution
| -closingPricesForAllStocks[i][0] + | ||
| closingPricesForAllStocks[i][closingPricesForAllStocks.length - 1] | ||
| ).toFixed(2) |
There was a problem hiding this comment.
Nice solution, well done. Your ordering on this line is a little confusing, this would make it more readable (last stock - first stock) :
closingPricesForAllStocks[i][closingPricesForAllStocks.length - 1] - closingPricesForAllStocks[i][0]
| `The highest price of ${stocks[ | ||
| i |
There was a problem hiding this comment.
really well done using the available [i] here to access items in the stocks array rather than creating another loop
No description provided.