Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

LONDON_10_Saqib_Javed_JavaScript-Core-1-Coursework-Week3 #267

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

saqibjvd
Copy link

No description provided.

saqibjvd added 5 commits March 4, 2023 15:19
weather
Mandatory financial  times completed
completed exercises
}

let hello = sayHello();
console.log(hello);


Copy link

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));
Copy link

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 = [];
Copy link
Contributor

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) {
Copy link
Contributor

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;
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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 😄

@moneyinthesky moneyinthesky added the reviewed A mentor has reviewed this code label Mar 15, 2023
@kwebster77 kwebster77 self-requested a review March 15, 2023 19:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
reviewed A mentor has reviewed this code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants