diff --git a/1-exercises/A-undefined/exercise.js b/1-exercises/A-undefined/exercise.js index 0acfc78d..cd4bf55a 100644 --- a/1-exercises/A-undefined/exercise.js +++ b/1-exercises/A-undefined/exercise.js @@ -9,12 +9,12 @@ For each example, can you explain why we are seeing undefined? */ -// Example 1 +// a does'nt have any value. let a; console.log(a); -// Example 2 +// The function sayHello doesn't return anything. function sayHello() { let message = "Hello"; } @@ -23,7 +23,7 @@ let hello = sayHello(); console.log(hello); -// Example 3 +// The function is recalled with no parameter. function sayHelloToUser(user) { console.log(`Hello ${user}`); } @@ -31,6 +31,6 @@ function sayHelloToUser(user) { sayHelloToUser(); -// Example 4 +// The array has no 4th element (index is counted from 0). let arr = [1,2,3]; console.log(arr[3]); diff --git a/1-exercises/B-array-literals/exercise.js b/1-exercises/B-array-literals/exercise.js index 51eba5cc..44e2323c 100644 --- a/1-exercises/B-array-literals/exercise.js +++ b/1-exercises/B-array-literals/exercise.js @@ -4,8 +4,8 @@ Declare some variables assigned to arrays of values */ -let numbers = []; // add numbers from 1 to 10 into this array -let mentors; // Create an array with the names of the mentors: Daniel, Irina and Rares +let numbers = [1,2,3,4,5,6,7,8,9,10]; // add numbers from 1 to 10 into this array +let mentors=["Daniel", "Irina","Rares"]; // Create an array with the names of the mentors: Daniel, Irina and Rares /* DO NOT EDIT BELOW THIS LINE diff --git a/1-exercises/C-array-get-set/exercise.js b/1-exercises/C-array-get-set/exercise.js index 5ca911d5..6736a5ee 100644 --- a/1-exercises/C-array-get-set/exercise.js +++ b/1-exercises/C-array-get-set/exercise.js @@ -5,11 +5,11 @@ */ function first(arr) { - return; // complete this statement + return arr[0]; // complete this statement } function last(arr) { - return; // complete this statement + return arr[arr.length-1]; // complete this statement } /* diff --git a/1-exercises/C-array-get-set/exercises2.js b/1-exercises/C-array-get-set/exercises2.js index 6b6b007a..f6526b5a 100644 --- a/1-exercises/C-array-get-set/exercises2.js +++ b/1-exercises/C-array-get-set/exercises2.js @@ -7,7 +7,8 @@ */ let numbers = [1, 2, 3]; // Don't change this array literal declaration - +numbers[numbers.length]=4; +numbers[0]=1; //! /* DO NOT EDIT BELOW THIS LINE --------------------------- */ diff --git a/1-exercises/D-for-loop/exercise.js b/1-exercises/D-for-loop/exercise.js index 081002b2..f23a7f75 100644 --- a/1-exercises/D-for-loop/exercise.js +++ b/1-exercises/D-for-loop/exercise.js @@ -27,6 +27,9 @@ const AGES = [ ]; // TODO - Write for loop code here +for(let i =0; iallArticleTitles[i].length){ + fewestWords=allArticleTitles[i]; + } + } + return fewestWords; +} +// function getWordsCount(allArticleTitles){ +// return allArticleTitles.split(" ").length; +// } /* - The editor of the FT has realised that headlines which have numbers in them get more clicks! + The editor of the FT has realized that headlines which have numbers in them get more clicks! Implement the function below to return a new array containing all the headlines which contain a number. (Hint: remember that you can also loop through the characters of a string if you need to) */ function headlinesWithNumbers(allArticleTitles) { - // TODO + const containNumbers=[]; + for(let i =0; i childrenRate){ + childrenRate = children[j].rating; + childrenTitle = children[j].title; + } + + } + + + let nonfictionRate = 0 ; + let nonfictionTitle = ""; + for (let j=0 ;j nonfictionRate){ + nonfictionRate = fiction[j].rating; + nonfictionTitle = fiction[j].title; + } + + } + + + let cookingRate = 0 ; + let cookingTitle = ""; + for (let j=0 ;j cookingRate){ + cookingRate = cooking[j].rating; + cookingTitle = cooking[j].title; + } + + } + resultArr.push(nonfictionTitle); + resultArr.push(childrenTitle); + resultArr.push(cookingTitle); + return resultArr; + // TODO } @@ -68,6 +120,7 @@ const BOOKS = [ rating: 4.85 }, ] +// console.log(getHighestRatedInEachGenre(BOOKS)); /* ======= TESTS - DO NOT MODIFY ===== */ diff --git a/3-extra/3-fibonacci.js b/3-extra/3-fibonacci.js index 9ef9aec7..03555640 100644 --- a/3-extra/3-fibonacci.js +++ b/3-extra/3-fibonacci.js @@ -15,6 +15,14 @@ function generateFibonacciSequence(n) { // TODO + const FibSequence=[]; + FibSequence[0]=0; + FibSequence[1]=1; + for(let i=2; i