LONDON_10 | SAIM KORKMAZ | JS1-3 - #245
Conversation
|
|
||
| sayHelloToUser(); | ||
| // user variable is not assigned, doesnt have a value | ||
|
|
There was a problem hiding this comment.
It is better to say that when we call the function, there is no any arguments - there's nothing in the brackets! Therefore value of the user parameter inside the function is undefined
| // Example 4 | ||
| let arr = [1,2,3]; | ||
| console.log(arr[3]); | ||
| // arr is an array and index numbers 0, 1, 2. the other numbers is not index of arr. No newline at end of file |
There was a problem hiding this comment.
Yes, the array doesn't have any value at index 3 - it only has values at indexes 0, 1 and 2. Therefore, retrieving an element from index 3 will give us undefined
| // TODO | ||
| let headlines = []; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| if (allArticleTitles[i].length <= 65) { |
There was a problem hiding this comment.
You know, that we can use for...of here as well ))
| // TODO | ||
| const reports = []; | ||
| for (let i = 0; i < cities.length; i++) { | ||
| const report = `The temperature in ${cities[i]} is ${temperatureService(cities[i])} degrees`; |
| let numberTitle = []; | ||
|
|
||
| for (let i = 0; i < ARTICLE_TITLES.length; i++) { | ||
| if (/\d/.test(ARTICLE_TITLES[i])) { |
| total += closingPricesForAllStocks[i][j]; | ||
| } | ||
| const average = total / closingPricesForAllStocks[i].length; | ||
| resultArray.push(parseFloat(average.toFixed(2))); |
There was a problem hiding this comment.
Here, you are converting a number into a string and then back to a number.
I'm nit picking here, but you could use
Math.round(average * 100) / 100
| for (let i = 0; i < allFrequencies.length; i++) { | ||
| const frequency = allFrequencies[i]; | ||
| if (isRadioStation(frequency)) { | ||
| radioStations.push(frequency); | ||
| } | ||
| } |
There was a problem hiding this comment.
This works fine, but worth looking into .filter method in javascript.
(This will come later in the course, so only if you want a little bit of a challenge)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
| function generateFibonacciSequence(n) { | ||
| // TODO | ||
| let result = [0, 1]; | ||
| for (let i = 2; i < n; i++){ | ||
| let totalOfPrevious = result[i - 1] + result[i - 2] | ||
| result.push(totalOfPrevious) | ||
| } | ||
| return result | ||
| } |
There was a problem hiding this comment.
This works fine and is one of the solutions for finding fibonacci numbers. Try learning about recursion and the solution for fibonacci numbers with recursion if you feel up to the challenge (this will come later, and is one of important topics in programming)
berkeli
left a comment
There was a problem hiding this comment.
All looks good! great submission.
I left a few comments only for some further learning or extra challenges. Let me know if you want to discuss any of these

No description provided.