-
-
Notifications
You must be signed in to change notification settings - Fork 279
London9_Inna_Poliakova_JS-Week-3 #195
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,25 +12,35 @@ | |
| // Example 1 | ||
| let a; | ||
| console.log(a); | ||
|
|
||
| // undefined - because variable not assigned | ||
|
|
||
| // Example 2 | ||
| function sayHello() { | ||
| let message = "Hello"; | ||
| } | ||
| // undefined - because function not called | ||
|
|
||
|
|
||
| let hello = sayHello(); | ||
| console.log(hello); | ||
|
|
||
| // undefined - because function not declared | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it is undefined because if we look back at line 19 it doesnt look like the function has returned anything yet. |
||
|
|
||
| // Example 3 | ||
| function sayHelloToUser(user) { | ||
| console.log(`Hello ${user}`); | ||
| } | ||
|
|
||
|
|
||
| sayHelloToUser(); | ||
|
|
||
| // undefined - because we put nothing like an argument | ||
|
|
||
| // Example 4 | ||
| let arr = [1,2,3]; | ||
| console.log(arr[3]); | ||
|
|
||
| // undefind - becouse array isn't conclude element with index 3 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! |
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,18 @@ | |
| The list of numbers should start with 0. n is being passed in as a parameter. | ||
| */ | ||
|
|
||
|
|
||
| function evenNumbers(n) { | ||
| // TODO | ||
| } | ||
| let result = []; | ||
|
|
||
| let i = 0; | ||
| while (i < n) { | ||
| result.push(i * 2); | ||
| i++; | ||
| } | ||
| console.log(result.join()); | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! 1 Caveat would be does the question ask for the first n? If so do we we want to include n itself. If we do how would we update the code to do so. |
||
|
|
||
| evenNumbers(3); // should output 0,2,4 | ||
| evenNumbers(0); // should output nothing | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,14 @@ const BIRTHDAYS = [ | |
| ]; | ||
|
|
||
| function findFirstJulyBDay(birthdays) { | ||
| // TODO | ||
|
|
||
| let i = 0; | ||
| while ( i < BIRTHDAYS.length) { | ||
| if (BIRTHDAYS[i].includes('July')) { | ||
| return BIRTHDAYS[i]; | ||
| } | ||
| i ++ | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
| } | ||
|
|
||
| console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have defined a function, but we have not done anything with it yet