London-Class10-Bedrije Omuri- Javacript-1-WeekIII - #221
Conversation
Solved exercise1 , 2 functions from exercise2 and 1 from exercise 3
|
|
||
| function getTemperatureReport(cities) { | ||
| // TODO | ||
| const weather = []; |
There was a problem hiding this comment.
Great job on this one 😄
| // TODO | ||
| headlines = []; // we declare an empty array so when we get the headlines with length<=65 we push them here | ||
|
|
||
| for (article of allArticleTitles) { // we loop through all articles and check their length |
There was a problem hiding this comment.
Small suggestion: it is usually a good idea to declare the variable in the for loop with let or const:
for (const article of allArticleTitles) {
| (you can assume words will always be seperated by a space) | ||
| (you can assume words will always be separated by a space) | ||
| */ | ||
| function titleWithFewestWords(allArticleTitles) { |
| */ | ||
| function headlinesWithNumbers(allArticleTitles) { | ||
| // TODO | ||
| function withNumber(title) { |
There was a problem hiding this comment.
I like that you've put the withNumber logic into its own function 👍
It might be worth defining the withNumber function outside of the headlinesWithNumbers function - so it can potentially be re-used. But not a big deal!
| 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.
Looks perfect - nice work 😄
| // TODO | ||
|
|
||
| let averagePrices = []; | ||
| for (prices of closingPricesForAllStocks) { |
There was a problem hiding this comment.
Same comment as above about using let or const in the for loop.
| for (prices of closingPricesForAllStocks) { | ||
| sum = 0; | ||
| for (item of prices) { //we use for within for so we can access the arrays of the array | ||
| sum += parseFloat(item); |
There was a problem hiding this comment.
Might be worth double-checking - is item already a Number? If it is, we may not need parseFloat here.
| */ | ||
| function getPriceChanges(closingPricesForAllStocks) { | ||
| // TODO | ||
| return closingPricesForAllStocks.map(prices => { // we use the map method to intenerate each element of closingPricesForAllStock |
There was a problem hiding this comment.
Very nice and short implementation 😄
Again, you might need the parseFloat on lines 74 and 75.
| */ | ||
| function highestPriceDescriptions(closingPricesForAllStocks, stocks) { | ||
| // TODO | ||
| return stocks.map((ticker, index) => { //map method makes it shorter to intenerate through each element of stocks by corresponding the index with the ticker and generate a new array |
There was a problem hiding this comment.
Great work on this one!
|
Great job on this coursework @Bedi06 👍 |
PaulinaWywrot
left a comment
There was a problem hiding this comment.
Great job Bedi, I like your way of writing the code :)
| for (const city of cities) { | ||
| const temperature = temperatureService(city); | ||
| if (temperature !== undefined) { | ||
| const statement = `The temperature in ${city} is ${temperature} degrees`; | ||
| weather.push(statement); | ||
| } | ||
| } | ||
|
|
||
| return weather; | ||
| } |
There was a problem hiding this comment.
spot on! very clear and concise code :)
No description provided.