London10 - Khalil Alhaydr - JavaScript-Core-1-Coursework-Week3 - #241
London10 - Khalil Alhaydr - JavaScript-Core-1-Coursework-Week3#241Khlil1313 wants to merge 14 commits into
Conversation
| sum += wordCount; | ||
| count += 1; | ||
| } | ||
| let average = sum / count; |
There was a problem hiding this comment.
couldnt you use allArticleTitles.length - 1 instead count variable ?
|
|
||
| } | ||
| return resultArray | ||
| } |
There was a problem hiding this comment.
Comment: I saw you and Elena have a similar solution.
I had another solution
function getTemperatureReport(cities) {
const temperatureReport = [];
for(let i = 0; i < cities.length; i++) {
const temperature = temperatureService(cities[i]);
temperatureReport.push(The temperature in ${cities[i]} is ${temperature} degrees);
}
return temperatureReport;
}
| } | ||
| return articleTitlesLessThan65 | ||
|
|
||
| } |
|
|
||
|
|
||
| } | ||
| return shortestTitle |
There was a problem hiding this comment.
Comment: I see you use .split which I did not. Well done
| count += 1; | ||
| } | ||
| let average = sum / count; | ||
| return Math.round(average); |
| averageArray.push(Math.round(average *100)/100) | ||
| sum = 0; | ||
| } | ||
| return averageArray |
| priceChangeArray.push(Math.round(priceChange * 100) / 100) | ||
| } | ||
| return priceChangeArray | ||
| } |
There was a problem hiding this comment.
Comment: You could also use array in array method.
function getPriceChanges(closingPricesForAllStocks) {
// TODO
let changedPrices = [];
for (let arrayWithPrices of closingPricesForAllStocks) {
let changedPrice = arrayWithPrices[arrayWithPrices.length - 1] - arrayWithPrices[0];
changedPrices.push(Number(changedPrice.toFixed(2)));
}
return changedPrices;
}
msimmdev
left a comment
There was a problem hiding this comment.
Well implemented solutions, I've noted a few different ways of approaching some of the problems, however your solutions are very appropriate as well.
| } | ||
|
|
||
| sayHelloToUser(); | ||
| sayHelloToUser(); // we didn't insert any input in the function sayHelloToUser() |
There was a problem hiding this comment.
Thought: The function will output the string "Hello undefined" instead of just undefined
|
|
||
| function first(arr) { | ||
| return; // complete this statement | ||
| return arr[0]; // complete this statement |
There was a problem hiding this comment.
Thought: This will return undefined if the array is empty.
|
|
||
| function last(arr) { | ||
| return; // complete this statement | ||
| return arr[arr.length - 1]; // complete this statement |
There was a problem hiding this comment.
Thought: This will return an error if the arr value is not an array
| */ | ||
|
|
||
| let numbers = [1, 2, 3]; // Don't change this array literal declaration | ||
| numbers[3] = 4; |
There was a problem hiding this comment.
Suggestion: You could also do
numbers.push(4);
| articleTitlesLessThan65.push(article) | ||
| } | ||
| } | ||
| return articleTitlesLessThan65 |
There was a problem hiding this comment.
Suggestion: This could also be achieved by using a .filter() function
| // TODO | ||
|
|
||
| let shortestTitle; | ||
| // let shortestTitleWordCount = Infinity; |
There was a problem hiding this comment.
Nitpick: Don't leave commented code in your solution
|
|
||
| } | ||
| return shortestTitle | ||
|
|
There was a problem hiding this comment.
Nitpick: Don't leave too many blank lines in a function
|
|
||
|
|
||
| } | ||
| return shortestTitle |
There was a problem hiding this comment.
Suggestion: This could also be achieved with a reduce() function.
No description provided.