This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 283
London_10- Danny Romero-JS-Core-1-Coursework-week3 #269
Open
Elenar9
wants to merge
9
commits into
CodeYourFuture:main
Choose a base branch
from
Elenar9:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
98c3776
javaScriot-Core-1-Coursework-Week3
Elenar9 34f40ce
JavaScriot-core-1-Coursework-week3
Elenar9 27c8fc8
JavaScript-core-1-coursework-week3
Elenar9 321ff7f
Update 1-weather-report.js
Elenar9 e5b07ef
update mandatory1
Elenar9 5cc3d9b
update mandatory-2
Elenar9 e1478f8
Update 2-financial-times.js
Elenar9 90fda67
2-mandatory/1-weather-report.js
Elenar9 faf37a3
E-while-loop-with-array/exercise.js
Elenar9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,25 @@ | |
|
||
function getTemperatureReport(cities) { | ||
// TODO | ||
} | ||
|
||
let arr = []; | ||
let degree = 0; | ||
let cityDegree = ""; | ||
for (let i = 0; i < cities.length; i++) { | ||
degree = temperatureService(cities[i]); | ||
|
||
arr.push(cityDegree); | ||
} | ||
return arr; | ||
|
||
} let arr = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you have the same code copied twice here, maybe this was an accident? |
||
let degree = 0; | ||
let cityDegree = ""; | ||
for (let i = 0; i < cities.length; i++) { | ||
degree = temperatureService(cities[i]); | ||
cityDegree = `The temperature in ${cities[i]} is ${degree} degrees`; | ||
arr.push(cityDegree); | ||
} | ||
return arr | ||
/* ======= TESTS - DO NOT MODIFY ===== */ | ||
|
||
function temperatureService(city) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,17 @@ | |
*/ | ||
function potentialHeadlines(allArticleTitles) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you have the same function name defined twice here? |
||
// TODO | ||
function potentialHeadlines(allArticleTitles) { | ||
// TODO | ||
let shortArticles = []; | ||
for (let article of allArticleTitles) { | ||
if (article.length <= 65) { | ||
shortArticles.push(article); | ||
} | ||
} | ||
return shortArticles; | ||
} | ||
|
||
} | ||
|
||
/* | ||
|
@@ -15,6 +26,14 @@ function potentialHeadlines(allArticleTitles) { | |
*/ | ||
function titleWithFewestWords(allArticleTitles) { | ||
// TODO | ||
const myArray = []; | ||
for (let article of allArticleTitles) { | ||
myArray.push(article.split(" ")); | ||
} | ||
let result = myArray.reduce(function (a,b) { | ||
return a.length <= b.length ? a : b; | ||
}); | ||
return allArticleTitles[myArray.indexOf(result)]; | ||
} | ||
|
||
/* | ||
|
@@ -24,18 +43,40 @@ function titleWithFewestWords(allArticleTitles) { | |
*/ | ||
function headlinesWithNumbers(allArticleTitles) { | ||
// TODO | ||
let countArray = []; | ||
for (article of allArticleTitles) { | ||
countArray.push(article.length); | ||
} | ||
let sum = 0; | ||
for (let i = 0; i < countArray.length; i++) { | ||
sum += countArray[i]; | ||
} | ||
return Math.round(sum / countArray.length); | ||
} | ||
|
||
|
||
|
||
|
||
/* | ||
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) { | ||
// TODO | ||
let countArray = []; | ||
for (article of allArticleTitles) { | ||
countArray.push(article.length); | ||
} | ||
let sum = 0; | ||
for (let i = 0; i < countArray.length; i++) { | ||
sum += countArray[i]; | ||
} | ||
return Math.round(sum / countArray.length); | ||
} | ||
|
||
|
||
|
||
|
||
/* ======= List of Articles - DO NOT MODIFY ===== */ | ||
const ARTICLE_TITLES = [ | ||
"Streaming wars drive media groups to spend more than $100bn on new content", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Your implementation here looks good 👍
You are adding the value returned by
temperatureService
to the arrayarr
.The question wants you to take this value, and put it into a string - like "The temperature in London is 10 degrees".
Can you think of how to create a string like this using the value you get back from the
temperatureService
?One idea is to use template literals in JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
When you have created this string - you could add that to the array instead 😄