Ezgi-Gunes-JavaScript-Core-1-Coursework-Week3-London8 - #27
Conversation
hachi-ops
left a comment
There was a problem hiding this comment.
Hi Ezgi, I reviewed your 'exercises' folder. Hope you'll find it helpful:)
| even.push(i); | ||
| i+=2; | ||
|
|
||
| }return even; |
There was a problem hiding this comment.
The final output is correct except it should return a string. Think of a method that allows you to do that.
| function findFirstJulyBDay(birthdays) { | ||
| // TODO | ||
| } | ||
| const findFirstJulyBDay = BIRTHDAYS.find(e=>e.includes('July')); |
There was a problem hiding this comment.
The console displays an error message saying it is not a function. There might be some syntax problems here.
| startNumber++; | ||
| } while (startNumber < n); | ||
| return sum; | ||
| } |
There was a problem hiding this comment.
Your code would work if you placed your changes inside the function.
There was a problem hiding this comment.
The code does work :) Maybe it looked confusing on a github diff?
| let i = 0; | ||
| while(i < 26) { | ||
|
|
||
| for(let i = 0; i < 26; i++) { |
| // TODO - Write for loop code here | ||
| for (var i = 0; i < WRITERS.length; i++) { | ||
|
|
||
| console.log(`${WRITERS[i]} is ${AGES[i]} years old.`) |
| ]; | ||
| for(let element of tubeStations){ | ||
|
|
||
| console.log(element); |
There was a problem hiding this comment.
Good but get rid of the unnecessary spaces:)
| // TODO Use a for-of loop to capitalise and output each letter in the string seperately. | ||
| let str = "codeyourfuture"; | ||
| for(let element of str){ | ||
| const myArr=str.toUpperCase().split(''); |
There was a problem hiding this comment.
I think you should target 'element' here not 'str'. The aim of this exercise is to output each letter separately, not the whole string. Also, I don't think you need split method here because it unnecessarily converts you string back to an array.
jstadnik
left a comment
There was a problem hiding this comment.
Congratulations on completing all the exercises!
You pulled a little ahead of the class -- these exercises were about loops, while you used a number of array methods and anonymous functions. It's not incorrect, but you may want to be mindful about making sure you do know how to use for/while loops when you need to.
You should be mindful of two "presentation" issues:
- indentation -- in a number of places you indented things inconsistently/wrongly. I haven't pointed them all out, but I can, if that's helpful. Are you using any auto-formatter in your IDE, such as prettier?
- leftover debug code -- make sure you remove print (
console.log) statements you used for debugging before you submit your PR.
On the whole, though, I am very impressed! Great job! 🙂
| evenNumbers(0); // should output nothing | ||
| evenNumbers(10); // should output 0,2,4,6,8,10,12,14,16,18 | ||
|
|
||
| console.log(evenNumbers(3)); // should output 0,2,4 |
There was a problem hiding this comment.
So, technically, according to the instructions, the function should console.log things.
| let even=[] | ||
| let i =0 | ||
|
|
||
| while(even.length<n){ |
| function findFirstJulyBDay(birthdays) { | ||
| // TODO | ||
| } | ||
| const findFirstJulyBDay = BIRTHDAYS.find(e=>e.includes('July')); |
There was a problem hiding this comment.
While this is a clever solution and kind of does solve the problem, you should try and implement things as asked by the exercise, rather than modify the check. So, here for example, you could do
function findFirstJulyBDay(birthdays) {
return birthdays.find(e=>e.includes('July'));
}To create a function.
Also, this should technically be a "while" loop exercise -- how would you complete it with a while loop?
| startNumber++; | ||
| } while (startNumber < n); | ||
| return sum; | ||
| } |
There was a problem hiding this comment.
The code does work :) Maybe it looked confusing on a github diff?
| let startNumber = 0; | ||
| let sum = 0; | ||
| do { | ||
| sum += startNumber * 2; |
| let totalCharacterNumber = 0; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| totalCharacterNumber = | ||
| totalCharacterNumber + allArticleTitles[i].split("").length; |
There was a problem hiding this comment.
.length works on strings, too:
> str = "somestr"
'somestr'
> str.length
7| } | ||
| average = parseFloat((sum/counter).toFixed(2)) | ||
|
|
||
| console.log(average); |
There was a problem hiding this comment.
You should try and remove all console.log you used for debugging before your final submission.
|
|
||
| for(let price of closingPricesForAllStocks){ | ||
|
|
||
| let priceDiff=Number(price[price.length-1]-price[0]) |
| // TODO | ||
| let bookTitles=[]; | ||
| for(let i=0; i<books.length; i++){ | ||
| if(books[i].rating > 4.8){ |
There was a problem hiding this comment.
This works for the exact test case provided, but wouldn't work with different inputs (for instance, if a genre's highest-rated book was rated 4.5), or there were two books rated > 4.8 in one genre.
| // TODO | ||
|
|
||
| let fibonacci = [0, 1]; | ||
| for(i = 2; i < n; i++) { |
No description provided.