diff --git a/1-exercises/A-undefined/exercise.js b/1-exercises/A-undefined/exercise.js index 0acfc78d..b67b40aa 100644 --- a/1-exercises/A-undefined/exercise.js +++ b/1-exercises/A-undefined/exercise.js @@ -12,11 +12,13 @@ // Example 1 let a; console.log(a); +function has no parimeter // Example 2 function sayHello() { let message = "Hello"; + needed to return message } let hello = sayHello(); @@ -29,6 +31,7 @@ function sayHelloToUser(user) { } sayHelloToUser(); +needs a parimeter // Example 4 diff --git a/1-exercises/E-for-loop/exercise1.js b/1-exercises/E-for-loop/exercise1.js index db5fac64..a9697c2f 100644 --- a/1-exercises/E-for-loop/exercise1.js +++ b/1-exercises/E-for-loop/exercise1.js @@ -6,9 +6,12 @@ // Change the below code to use a for loop instead of a while loop. -let i = 0; -while(i < 26) { - console.log(String.fromCharCode(97 + i)); - i++; + +for (let index = 0; index < 26; index++) { + + console.log(String.fromCharCode(97 + index)); + } + + // The output shouldn't change. diff --git a/1-exercises/E-for-loop/exercise2.js b/1-exercises/E-for-loop/exercise2.js index 081002b2..5d54d5b4 100644 --- a/1-exercises/E-for-loop/exercise2.js +++ b/1-exercises/E-for-loop/exercise2.js @@ -27,7 +27,10 @@ const AGES = [ ]; // TODO - Write for loop code here - +for (let index = 0; index < WRITERS.length; index++) { + console.log(`${WRITERS[index]} is ${AGES[index]} years old`); + +} /* The output should look something like this: diff --git a/1-exercises/F-for-of-loop/exercise.js b/1-exercises/F-for-of-loop/exercise.js index 65585c6a..280012f7 100644 --- a/1-exercises/F-for-of-loop/exercise.js +++ b/1-exercises/F-for-of-loop/exercise.js @@ -11,6 +11,5 @@ let tubeStations = [ "Tottenham Court Road" ]; - // TODO Use a for-of loop to capitalise and output each letter in the string seperately. let str = "codeyourfuture"; diff --git a/2-mandatory/1-weather-report.js b/2-mandatory/1-weather-report.js index dcc2bdb0..392d1ac4 100644 --- a/2-mandatory/1-weather-report.js +++ b/2-mandatory/1-weather-report.js @@ -13,6 +13,12 @@ function getTemperatureReport(cities) { // TODO + let final = [] + for (let index = 0; index < cities.length; index++) { + final.push(`The temperature in ${cities[index]} is ${temperatureService(cities[index])} degrees`); + + } + return final } diff --git a/3-extra/1-factorial.js b/3-extra/1-factorial.js index 31f8052c..b26e49e2 100644 --- a/3-extra/1-factorial.js +++ b/3-extra/1-factorial.js @@ -9,7 +9,12 @@ */ function factorial(input) { - // TODO + let result = 1 + for (let i = 1; i <= input; i++) { + result *= i + } + return result + } /* ======= TESTS - DO NOT MODIFY ===== */ diff --git a/3-extra/3-fibonacci.js b/3-extra/3-fibonacci.js index 9ef9aec7..91c69f1f 100644 --- a/3-extra/3-fibonacci.js +++ b/3-extra/3-fibonacci.js @@ -14,7 +14,19 @@ */ function generateFibonacciSequence(n) { - // TODO + let start = 0 + let final =[] + let next =1 + let current + for (let i = 0; i < n; i++) { + final.push(start) + current = start + next + start = next + next = current + + + } + return final } /* ======= TESTS - DO NOT MODIFY ===== */