WM4 - Robert Csonka - JS1week3 - #101
Conversation
| for (let i = 0; i < 5; i++) { | ||
| console.log(`${WRITERS[i]} is ${AGES[i]} years old`) | ||
| } | ||
|
|
hayatu4islam
left a comment
There was a problem hiding this comment.
Creative solutions. Keep it up!
| // Example 4 | ||
| let arr = [1,2,3]; | ||
| console.log(arr[3]); | ||
| console.log(arr[3]); // the index 3 in the array call points to the 4th placed element inside the array, as we count the elements from index 0, index 3 is undefined No newline at end of file |
There was a problem hiding this comment.
This is an excellent explanation and good use of comments.
| } | ||
| i++; | ||
| } | ||
| return birthday |
There was a problem hiding this comment.
A well structured implementation of the function. However, the function will continue to search the presence of July up till the end even after it found the first July. The presence of i++ in line27 made the function not to give wrong output. Because it skips the next July in the array. If you try to input another July birthday after September 28th, you will see that the function will return the last July instead of the first. I suggest you end the while loop immediately you find the occurrence of July. It is also a good practice to put semi-colon after statements such as return in line 29.
| let arr = []; | ||
| for (const element of cities) { | ||
| if (temperatureService(element)) { | ||
| arr.push(`The temperature in ${element} is ${temperatureService(element)} degrees`); |
| } | ||
| smallestNumValue = Math.min(...arrLength); //once i had the array of indexes of lenght I went on to find the position of the smallest index in the array in 2 steps, first finding the value of the smallest number | ||
| index = arrLength.indexOf(smallestNumValue)//this is the second step of finding the position of the smallest index in an array, this steps finds the position of the smallest number that we identified in the previous step | ||
| return allArticleTitles[index]; //finally i return the position of the smallest number of the original array |
| for (const element of allArticleTitles){ | ||
| if ( /\d/.test(element)) { | ||
| array.push(element); | ||
| } |
There was a problem hiding this comment.
A very good use of regular expression!
| } | ||
| for (const element of arrNumOfCharacters) { | ||
| total = total + element; | ||
| } |
There was a problem hiding this comment.
The way you declare variables at the beginning is fantastic.
| total = total + element; | ||
| } | ||
| average = total / subArray.length; | ||
| total = 0; |
There was a problem hiding this comment.
I like the creative way of resetting the value of total.
| num = 1; | ||
| for (let i = 0; i < n - 1; i++) { | ||
| arr.push(num); | ||
| num = num + arr[i]; |
| cooking.push(books[i]); | ||
| } | ||
| } | ||
| children.sort((a, b) => b.rating - a.rating); |
There was a problem hiding this comment.
A beautiful way of using arrow function!
| for (const subArray of closingPricesForAllStocks) { | ||
|
|
||
| highestPriceEach = Math.max(...subArray).toFixed(2); | ||
| arrayOfPrices.push(`The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${highestPriceEach}`); |
No description provided.