NW5- LEEDS - CUNEYT TURKER - JAVASCRIPT1 WEEK 3 - #128
Conversation
Gevie
left a comment
There was a problem hiding this comment.
You did great Cuneyt, really happy with your progress, some areas I think you know are WIP etc but all in all a good effort. Let's finish those last exercises and smash this PR.
|
|
||
| // Example 1 | ||
| let a; | ||
| let a; // There is nothing equal with variable "a" |
There was a problem hiding this comment.
You're correct, I think maybe a language issue, the best way to say it is that there is no value assigned to variable "a". Just because equal sounds like "a === a" etc but I knew what you meant 👍
|
|
||
| let hello = sayHello(); | ||
| console.log(hello); | ||
| console.log(hello);// Variable defined but function must be defined too. |
There was a problem hiding this comment.
Well spotted, there are no parethesis console.log(hello())
| } | ||
|
|
||
| sayHelloToUser(); | ||
| sayHelloToUser(); // There must be a value inside of the paranthesis to make our function defined. |
There was a problem hiding this comment.
The function will be defined without a value, we're just calling it wrong, so you are correct we need a value.
| // TODO | ||
| let output = []; | ||
| let i =0; | ||
| while(output.length<n){ |
There was a problem hiding this comment.
I'm afraid this doesn't work Cuneyt, if I call this function with evenNumbers(10) it exceeds 10 in its return, it gives me:
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
Let me know if you want help with this one in the group chat.
| // TODO | ||
| let output = [] | ||
| for(let i of cities){ | ||
| output.push(`The temperature in ${i} is ${temperatureService(i)} degrees`) |
| let output = [] | ||
| for(let i in allArticleTitles){ | ||
|
|
||
| if(allArticleTitles[i].match(/[0-9]/g) !== null){ |
There was a problem hiding this comment.
Great use of regular expressions, @Ekremteke actually simplified this with the /d operator. /d is a shortcut for 0-9 both are correct however I just felt it would be good to share that shortcut.
| for(let i = 0; i < allIntegers.length; i++) { | ||
| total += allIntegers[i]; | ||
| } | ||
| let average = total / allIntegers.length; |
There was a problem hiding this comment.
You did great here, I would advise using new lines to help separate your code to help the readability. Split it up into chunks of separate logic.
| for(let j in i){ | ||
| total += i[j]; | ||
| } | ||
| let a = total/i.length; |
There was a problem hiding this comment.
I'm not a huge advocate for your variable naming here, you have i, j, a and b - Imagine if this code was 500 lines long, we'd need to study it closely to know what was happening.
Other than that, good job! There are a couple other ways to do this but you succeeded in completed the exercise.
There was a problem hiding this comment.
I really need to get used to it.
| function factorial(input) { | ||
| // TODO | ||
| let total = 1; | ||
| for(let index=input;index>0;index--){ |
There was a problem hiding this comment.
Always remember to include spaces, they're not needed by the compiler or processor which reads the code, but it helps us read it better as developers 😅
I'm not sure you actually completed this task, we can talk about it in the hawk channel if you want.
|
|
||
| function getHighestRatedInEachGenre(books) { | ||
| // TODO | ||
| for(let everyObjects of books){ |
There was a problem hiding this comment.
I think you know this function isn't complete 😂
If you need help with this one, please talk in the hawk channel, myself and the others can help you out.
No description provided.