London10_Jan_Softa_Javascript_Core1_Coursework_Week3 - #235
Conversation
| @@ -13,6 +13,16 @@ | |||
|
|
|||
| function getTemperatureReport(cities) { | |||
There was a problem hiding this comment.
Looks great!
A small point - keep an eye on indentation, as it will make it easier for other developers to read your code.
| Implement the function below, which will return a new array containing only article titles which will fit. | ||
| */ | ||
|
|
||
| function potentialHeadlines(allArticleTitles) { |
There was a problem hiding this comment.
Looks perfect!
For extra practice, can you re-write this with the filter array method?
|
|
||
|
|
||
|
|
||
| function titleWithFewestWords(allArticleTitles) { |
There was a problem hiding this comment.
This solution will return the title with the fewest characters, but this might be different from the title with the fewest words.
Can you try fixing this? (you only need to make 2 small changes 😄)
| // TODO | ||
| let newArr = []; | ||
| for (let title of allArticleTitles) { | ||
| if (/[0-9]/.test(title) === true) { |
There was a problem hiding this comment.
You can replace this line with if (/[0-9]/.test(title)) {
Can you think of why that is the case?
| */ | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
This is a nice solution.
Can you think of another way to get the number of articles, without using the numberOfArticles variable?
| */ | ||
|
|
||
| // | ||
|
|
There was a problem hiding this comment.
This is a great solution! 👍
I love the use of the extra function here 😄 It makes the code very easy to read and understand.
| let arrayWithStrings = []; | ||
| for (let i = 0; i < stocks.length; i++) { | ||
| let stockOfName = stocks[i].toUpperCase(); | ||
| let sortedArray = closingPricesForAllStocks[i].sort(function (a, b) { |
There was a problem hiding this comment.
This looks good - I think it works.
There are a few other ways to do this as well - have a look at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max
No description provided.