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 279
London9 Lovelace - Mehreen Aziz - JS Week 3 #194
Open
Mehreenaziz
wants to merge
3
commits into
CodeYourFuture:main
Choose a base branch
from
Mehreenaziz: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
3 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -11,10 +11,23 @@ | |
| - Hint: you can call the temperatureService function from your function | ||
| */ | ||
|
|
||
|
|
||
| // let citiesArr = ['London', 'São Paulo', 'Paris', 'Barecelona'] | ||
|
|
||
| function getTemperatureReport(cities) { | ||
| // TODO | ||
| let cityWeather = []; | ||
| for (let i = 0; i < cities.length; i++) { | ||
|
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. Perhaps linting could be applied here |
||
| cityWeather.push( | ||
| `The temperature in ${cities[i]} is ${temperatureService(cities[i])} degrees` | ||
| ); | ||
| } | ||
| return cityWeather; | ||
| } | ||
|
|
||
| // console.log(getTemperatureReport('London')) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== */ | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| /* | ||
| Imagine you are working on the Financial Times web site! They have a list of article titles stored in an array. | ||
|
|
||
| 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(items => items.length < 65); | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -15,6 +15,11 @@ function potentialHeadlines(allArticleTitles) { | |
| */ | ||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let arr = []; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| arr.push(allArticleTitles[i].split(" ").length); | ||
| } | ||
| return allArticleTitles[arr.indexOf(Math.min(...arr))]; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -24,6 +29,18 @@ function titleWithFewestWords(allArticleTitles) { | |
| */ | ||
| function headlinesWithNumbers(allArticleTitles) { | ||
| // TODO | ||
| // let arrayNum = [] | ||
| // for (let el of ARTICLE_TITLES) { | ||
|
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. Removing the dead code would enhance the readability and accidental issues |
||
| // for (let ele of el){ | ||
| // if (ele.includes(Number)) { | ||
| // return arrayNum.push(ele.includes(Number)); | ||
| // } | ||
| // } | ||
| // return arrayNum | ||
| // } | ||
| return allArticleTitles.filter((element) => | ||
| [...element].find((number) => number >= "0" && number <= "9") | ||
| ); | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -32,6 +49,11 @@ function headlinesWithNumbers(allArticleTitles) { | |
| */ | ||
| function averageNumberOfCharacters(allArticleTitles) { | ||
| // TODO | ||
| let sum = 0; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| sum += allArticleTitles[i].length; | ||
| } | ||
| return Math.round(sum / allArticleTitles.length); | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -78,4 +100,4 @@ test("should only return headlines containing numbers", () => { | |
|
|
||
| test("should return the average number of characters in a headline", () => { | ||
| expect(averageNumberOfCharacters(ARTICLE_TITLES)).toEqual(65); | ||
| }); | ||
| }); | ||
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
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.
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.
Good catch, keep it up