-
-
Notifications
You must be signed in to change notification settings - Fork 283
LONDON_10_Saqib_Javed_JavaScript-Core-1-Coursework-Week3 #267
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
let hello = sayHello(); | ||
console.log(hello); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work
"Lagos", | ||
]; | ||
|
||
console.log(getTemperatureReport(cities)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well explained,Well Done.
@@ -12,52 +12,62 @@ | |||
*/ | |||
|
|||
function getTemperatureReport(cities) { | |||
// TODO | |||
temperatures = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
} | ||
|
||
/* | ||
The editor of the FT has realised that headlines which have numbers in them get more clicks! | ||
Implement the function below to return a new array containing all the headlines which contain a number. | ||
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice implementation for this one 👏
headlinesWithNumbers.push(singleTitle); | ||
} | ||
} | ||
return headlinesWithNumbers; | ||
} | ||
|
||
/* | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks almost perfect to me!
Again, just remember to use let
or const
when declaring a variable 😄
No description provided.