London 9 - Marziyeh Azhdari - JS-Core-1 - Week 3 - #173
Conversation
|
Good job .Well done Mari 🥇 |
| arr.push(num) | ||
| num += 2 | ||
| n-- | ||
| } |
There was a problem hiding this comment.
This function works. Another way to write it which for me it's a bit more readable would be like this:
function evenNumbers(n) {
let num= 0 ;
let arr =[]
while(num < n){
arr.push(2*num)
num ++
}
I find it more natural that the comparison is between n and num but both of them are correct.
| function evenNumbersSum(n) { | ||
| // TODO | ||
| let result = 0; | ||
| let i = 0 * 2; |
| do{ | ||
| result += i * 2; | ||
| i++; | ||
| }while(i < n) |
|
|
||
| // TODO - Write for loop code here | ||
|
|
||
| for(i = 0;i <= WRITERS.length;i++ ){ |
There was a problem hiding this comment.
The comparison should be i < WRITERS.length, because array start counting from 0. With the current code, you will get an undefined for the last line.
| let arr=[] | ||
| for (let article of allArticleTitles){ | ||
| for (let char of article){ | ||
| if (char>="0" && char<="9"){ |
There was a problem hiding this comment.
You could have also used regular expressions here:
https://stackoverflow.com/questions/5778020/check-whether-an-input-string-contains-a-number-in-javascript
|
|
||
| function factorial(input) { | ||
| // TODO | ||
| let sum = 1 |
There was a problem hiding this comment.
Very small detail, but this is not a sum but a product. The function is correct though.
No description provided.