Ldn-class-8-Saf Shah - JS Core 1 - Week 3 - #22
Conversation
mahri09
left a comment
There was a problem hiding this comment.
@s-shah-coder your code is clean and very good to understand I was glad to read your code, thank you!!!
| } | ||
| return arr.toString(); | ||
| } | ||
|
|
There was a problem hiding this comment.
hey, Saf in line 11 when you give the condition while loop you can make it simply (n > arr.length) and it will work!
| letter === "8"|| | ||
| letter === "9") { | ||
| newClicks.push(allArticleTitles[i]) | ||
| } |
There was a problem hiding this comment.
maybe you already know there is another easy way to find out number inside array I used that
if (/[0-9]/g.test(sentence)) {
titleWithNum.push(sentence);
}
| } | ||
| return (Math.round(totalLength / allArticleTitles.length)) | ||
| } | ||
|
|
There was a problem hiding this comment.
you did it an easier way I changed my code after seeing yours thank you Saf!
| highestPriceLast5Days = []; | ||
| for (let i = 0; i < closingPricesForAllStocks.length; i++) { | ||
| highestPriceLast5Days.push(`The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${Math.max(...closingPricesForAllStocks[i]).toFixed(2)}`); | ||
| } |
There was a problem hiding this comment.
I have seen it on google using Math.max() it really helps to make easier our work, anyway I also used another way to solve it.
| } | ||
| return arr.toString(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Do you need to check if i is even here?
| return sumTotal; | ||
| } | ||
|
|
||
| console.log(evenNumbersSum(3)); // should output 6 |
There was a problem hiding this comment.
If you print out each number as its being added here you're not actually adding the even numbers, you're adding the product of the even numbers of three. Have a double-check of the logic you're using here.
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== */ | ||
|
|
||
| function temperatureService(city) { |
There was a problem hiding this comment.
Try and get into the habit of using a more descriptive name for your variable than 'newArray'
|
|
||
| return newString; | ||
| } | ||
|
|
There was a problem hiding this comment.
Another way of doing this is to initialise newString with the first entry, and then you can just check each subsequent entry with only one condition
No description provided.