LONDON_10_Saqib_Javed_JavaScript-Core-1-Coursework-Week3#267
LONDON_10_Saqib_Javed_JavaScript-Core-1-Coursework-Week3#267saqibjvd wants to merge 6 commits intoCodeYourFuture:mainfrom
Conversation
| let hello = sayHello(); | ||
| console.log(hello); | ||
|
|
||
|
|
| "Lagos", | ||
| ]; | ||
|
|
||
| console.log(getTemperatureReport(cities)); |
|
|
||
| function getTemperatureReport(cities) { | ||
| // TODO | ||
| temperatures = []; |
There was a problem hiding this comment.
The logic looks good to me 👍
Something to keep in mind: it's a good idea to use let or const when declaring a variable (like temperatures, city, information_string in your example.)
|
|
||
| let lessArticle = []; | ||
|
|
||
| for (headline of allArticleTitles) { |
There was a problem hiding this comment.
The code looks good here.
Same comment as above about using let or const for the headline variable here.
| headlines = potentialHeadlines(allArticleTitles); | ||
|
|
||
| let shortHeadline = []; | ||
| let fewestWords = 100; |
There was a problem hiding this comment.
This is not bad - and it might work for the test cases...
But what if all the headlines had more that 100 words?
Can you think of how you could do this without initialising fewestWords to a specific number?
One idea is to use the number of words in the first headline 🤔
| for (singleTitle of allArticleTitles) { | ||
| let numberChecker = /[0-9]/.test(singleTitle); | ||
|
|
||
| if (numberChecker === true) { |
There was a problem hiding this comment.
Normally when you have an if statement that look like if (numberChecker === true) {, you can instead write if (numberChecker) {.
Can you think of why that works?
| (Hint: remember that you can also loop through the characters of a string if you need to) | ||
| */ | ||
|
|
||
| function headlinesWithNumbers(allArticleTitles) { |
There was a problem hiding this comment.
Very nice implementation for this one 👏
| The Financial Times wants to understand what the average number of characters in an article title is. | ||
| Implement the function below to return this number - rounded to the nearest integer. | ||
| */ | ||
| function averageNumberOfCharacters(allArticleTitles) { |
There was a problem hiding this comment.
This looks almost perfect to me!
Again, just remember to use let or const when declaring a variable 😄
No description provided.