Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion 2-mandatory/1-weather-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,35 @@
*/

function getTemperatureReport(cities) {
// TODO
const temperatureStatements = [];

cities.forEach(city => {
let temperature = 0;
switch (city) {
case 'Ndola':
temperature = 20;
break;
case 'Kitwe':
temperature = 30;
break;
case 'London':
temperature = 40;
break;
default:
temperature = 0;
break;
// Construct a statement about the temperature of the city
const temperatureStatement = `${city} is currently ${temperature} degrees Celsius.`;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice.

// Add the statement to the array
temperatureStatements.push(temperatureStatement);
});

return temperatureStatements;
}
getTemperatureReport(kitwe)
// TODO



/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
11 changes: 9 additions & 2 deletions 2-mandatory/2-financial-times.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
The home page of the web site has a headline section, which only has space for article titles which are 65 characters or less.
Implement the function below, which will return a new array containing only article titles which will fit.
*/

function potentialHeadlines(allArticleTitles) {
// TODO
}
return allArticleTitles.filter(title => title.length <= 65);
//TODO
}

/*
The editor of the FT likes short headlines with only a few words!
Expand All @@ -23,6 +25,11 @@ function titleWithFewestWords(allArticleTitles) {
(Hint: remember that you can also loop through the characters of a string if you need to)
*/
function headlinesWithNumbers(allArticleTitles) {
let result = [];

for (let title of allArticleTitles) {

}
// TODO
}

Expand Down