From 4fbcc18af59a332e1e40b3de8abc6d925294b331 Mon Sep 17 00:00:00 2001 From: nunoluis85 <83136872+nunoluis85@users.noreply.github.com> Date: Sat, 10 Sep 2022 17:40:06 +0200 Subject: [PATCH 1/3] Week1 HomeWork --- week-1/Homework/F-strings-methods/exercise.js | 5 +++-- week-1/Homework/F-strings-methods/exercise2.js | 2 ++ week-1/Homework/J-functions/exercise.js | 8 +++++++- week-1/Homework/J-functions/exercise2.js | 2 +- .../Homework/K-functions-parameters/exercise.js | 4 ++-- .../Homework/K-functions-parameters/exercise2.js | 6 +++--- .../Homework/K-functions-parameters/exercise3.js | 6 ++++-- .../Homework/K-functions-parameters/exercise4.js | 6 ++++-- .../Homework/K-functions-parameters/exercise5.js | 4 +++- week-1/Homework/L-functions-nested/exercise.js | 16 ++++++++++++++++ 10 files changed, 45 insertions(+), 14 deletions(-) diff --git a/week-1/Homework/F-strings-methods/exercise.js b/week-1/Homework/F-strings-methods/exercise.js index 2cffa6a8..3686d7c0 100644 --- a/week-1/Homework/F-strings-methods/exercise.js +++ b/week-1/Homework/F-strings-methods/exercise.js @@ -1,3 +1,4 @@ -// Start by creating a variable `message` +var name = "Nuno"; // Start by creating a variable `message` +var nameLength = name.length; -console.log(message); +console.log(`My name is ${name} and my name is ${nameLength} characters long.`); diff --git a/week-1/Homework/F-strings-methods/exercise2.js b/week-1/Homework/F-strings-methods/exercise2.js index b4b46943..2fb71b4b 100644 --- a/week-1/Homework/F-strings-methods/exercise2.js +++ b/week-1/Homework/F-strings-methods/exercise2.js @@ -1,3 +1,5 @@ const name = " Daniel "; +const message = `My name is ${name.trim()} and my name is 6 characters long.`; console.log(message); + diff --git a/week-1/Homework/J-functions/exercise.js b/week-1/Homework/J-functions/exercise.js index 0ae5850e..eb33fd25 100644 --- a/week-1/Homework/J-functions/exercise.js +++ b/week-1/Homework/J-functions/exercise.js @@ -1,7 +1,13 @@ function halve(number) { - // complete the function here + return number / 2; // complete the function here } var result = halve(12); +var result2 = halve(24); +var result3 = halve(36); +var result4= halve(100); console.log(result); +console.log(result2); +console.log(result3); +console.log(result4); diff --git a/week-1/Homework/J-functions/exercise2.js b/week-1/Homework/J-functions/exercise2.js index 82ef5e78..87def2b7 100644 --- a/week-1/Homework/J-functions/exercise2.js +++ b/week-1/Homework/J-functions/exercise2.js @@ -1,5 +1,5 @@ function triple(number) { - // complete function here + return number * 3; // complete function here } var result = triple(12); diff --git a/week-1/Homework/K-functions-parameters/exercise.js b/week-1/Homework/K-functions-parameters/exercise.js index 8d5db5e6..22e0b977 100644 --- a/week-1/Homework/K-functions-parameters/exercise.js +++ b/week-1/Homework/K-functions-parameters/exercise.js @@ -1,6 +1,6 @@ // Complete the function so that it takes input parameters -function multiply() { - // Calculate the result of the function and return it +function multiply(num1, num2) { + return num1 * num2; // Calculate the result of the function and return it } // Assign the result of calling the function the variable `result` diff --git a/week-1/Homework/K-functions-parameters/exercise2.js b/week-1/Homework/K-functions-parameters/exercise2.js index db7a8904..d1881be9 100644 --- a/week-1/Homework/K-functions-parameters/exercise2.js +++ b/week-1/Homework/K-functions-parameters/exercise2.js @@ -1,5 +1,5 @@ -// Declare your function first - +function divide(num1, num2) { // Declare your function first + return num1 / num2; +} var result = divide(3, 4); - console.log(result); diff --git a/week-1/Homework/K-functions-parameters/exercise3.js b/week-1/Homework/K-functions-parameters/exercise3.js index 537e9f4e..93195073 100644 --- a/week-1/Homework/K-functions-parameters/exercise3.js +++ b/week-1/Homework/K-functions-parameters/exercise3.js @@ -1,5 +1,7 @@ -// Write your function here +function createGreeting(name) { + return "Hello, my name is " + name; +} -var greeting = createGreeting("Daniel"); + var greeting = createGreeting("Daniel"); console.log(greeting); diff --git a/week-1/Homework/K-functions-parameters/exercise4.js b/week-1/Homework/K-functions-parameters/exercise4.js index 7ab44589..af271358 100644 --- a/week-1/Homework/K-functions-parameters/exercise4.js +++ b/week-1/Homework/K-functions-parameters/exercise4.js @@ -1,5 +1,7 @@ -// Declare your function first +function numbers(num1, num2) { + return num1 + num2; +}// Declare your function first -// Call the function and assign to a variable `sum` +var sum = numbers(13, 124);// Call the function and assign to a variable `sum` console.log(sum); diff --git a/week-1/Homework/K-functions-parameters/exercise5.js b/week-1/Homework/K-functions-parameters/exercise5.js index 7c5bcd60..4fdaafde 100644 --- a/week-1/Homework/K-functions-parameters/exercise5.js +++ b/week-1/Homework/K-functions-parameters/exercise5.js @@ -1,4 +1,6 @@ -// Declare your function here +function createLongGreeting(name, age) { + return "Hello, my name is " + name + " and I'm " + age + " years old"; +}// Declare your function here const greeting = createLongGreeting("Daniel", 30); diff --git a/week-1/Homework/L-functions-nested/exercise.js b/week-1/Homework/L-functions-nested/exercise.js index a5d37744..448dc978 100644 --- a/week-1/Homework/L-functions-nested/exercise.js +++ b/week-1/Homework/L-functions-nested/exercise.js @@ -3,3 +3,19 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; + +function createGreeting(greeting){ + return "HELLO "; +} + +const message = createGreeting(); + +function mentorsNames(mentor) { + return mentor; +} + +console.log(message + mentor1.toUpperCase()); +console.log(message + mentor2.toUpperCase()); +console.log(message + mentor3.toUpperCase()); +console.log(message + mentor4.toUpperCase()); +console.log(message + mentor5.toUpperCase()); From 0c62e4e05b4efc629dfb87373f47630fab1e0f06 Mon Sep 17 00:00:00 2001 From: nunoluis85 <83136872+nunoluis85@users.noreply.github.com> Date: Sat, 10 Sep 2022 17:45:48 +0200 Subject: [PATCH 2/3] Week2 HomeWork --- .../Homework/C-comparison-operators/exercise.js | 7 ++++--- week-2/Homework/E-conditionals/exercise.js | 6 ++++++ week-2/Homework/F-logical-operators/exercise.js | 14 ++++++-------- week-2/Homework/F-logical-operators/exercise2.js | 16 +++++++++++++++- week-2/Homework/G-conditionals-2/exercise-1.js | 2 +- week-2/Homework/G-conditionals-2/exercise-2.js | 2 +- week-2/Homework/G-conditionals-2/exercise-3.js | 13 ++++++++++++- week-2/Homework/G-conditionals-2/exercise-4.js | 1 + week-2/Homework/H-array-literals/exercise.js | 4 ++-- week-2/Homework/I-array-properties/exercise.js | 7 ++++++- week-2/Homework/J-array-get-set/exercise.js | 4 ++-- week-2/Homework/J-array-get-set/exercises2.js | 2 +- week-2/Homework/K-while-loop/exercise.js | 8 ++++++-- week-2/Homework/L-for-loop/exercise.js | 6 +++++- week-2/Homework/M-array-loop/exercise.js | 12 +++++++++++- 15 files changed, 79 insertions(+), 25 deletions(-) diff --git a/week-2/Homework/C-comparison-operators/exercise.js b/week-2/Homework/C-comparison-operators/exercise.js index 58aee1c5..e2ef4017 100644 --- a/week-2/Homework/C-comparison-operators/exercise.js +++ b/week-2/Homework/C-comparison-operators/exercise.js @@ -7,14 +7,15 @@ var studentCount = 16; var mentorCount = 9; -var moreStudentsThanMentors; // finish this statement +var moreStudentsThanMentors = studentCount > mentorCount; // finish this statement var roomMaxCapacity = 25; -var enoughSpaceInRoom; // finish this statement +var total = studentCount + mentorCount; +var enoughSpaceInRoom = roomMaxCapacity <= total; // finish this statement var personA = "Daniel"; var personB = "Irina"; -var sameName; // finish this statement +var sameName = personA == personB; // finish this statement /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/Homework/E-conditionals/exercise.js b/week-2/Homework/E-conditionals/exercise.js index acbaaa8e..d48c887e 100644 --- a/week-2/Homework/E-conditionals/exercise.js +++ b/week-2/Homework/E-conditionals/exercise.js @@ -8,6 +8,12 @@ var name = "Daniel"; var danielsRole = "mentor"; +if (danielsRole == "mentor") { + console.log(`Hi, I'm ${name} and I work as ${danielsRole}`); +} +else if (danielsRole == "student") { + console.log(`Hi, I'm ${name} and I'm a ${danielsRole}`); +} /* EXPECTED RESULT diff --git a/week-2/Homework/F-logical-operators/exercise.js b/week-2/Homework/F-logical-operators/exercise.js index a8f2945b..7b6fe19e 100644 --- a/week-2/Homework/F-logical-operators/exercise.js +++ b/week-2/Homework/F-logical-operators/exercise.js @@ -11,14 +11,15 @@ var cssLevel = 4; // Finish the statement to check whether HTML, CSS knowledge are above 5 // (hint: use the comparison operator from before) -var htmlLevelAbove5; -var cssLevelAbove5; +var htmlLevelAbove5 = htmlLevel > 5; +var cssLevelAbove5 = cssLevel > 5; + // Finish the next two statement // Use the previous variables and logical operators // Do not "hardcode" the answers -var cssAndHtmlAbove5; -var cssOrHtmlAbove5; +var cssAndHtmlAbove5 = cssLevel > 5 && htmlLevel > 5; +var cssOrHtmlAbove5 = cssLevel > 5 || htmlLevel > 5; /* DO NOT EDIT BELOW THIS LINE @@ -27,10 +28,7 @@ var cssOrHtmlAbove5; console.log("Is Html knowledge above 5?", htmlLevelAbove5); console.log("Is CSS knowledge above 5?", cssLevelAbove5); console.log("Is Html And CSS knowledge above 5?", cssAndHtmlAbove5); -console.log( - "Is either Html or CSS knowledge above 5?", - cssOrHtmlAbove5 -); +console.log("Is either Html or CSS knowledge above 5?", cssOrHtmlAbove5); /* EXPECTED RESULT diff --git a/week-2/Homework/F-logical-operators/exercise2.js b/week-2/Homework/F-logical-operators/exercise2.js index fcc99247..2e3293bc 100644 --- a/week-2/Homework/F-logical-operators/exercise2.js +++ b/week-2/Homework/F-logical-operators/exercise2.js @@ -5,7 +5,21 @@ Update the code so that you get the expected result. */ -function isNegative() {} +function isNegative(number) { + return number<0 ? true : false +} + +function isBetween5and10(num) { + return num>=5 && num<=10 ? true : false +} + +function isShortName(name) { + return name.length<=6; +} + +function startsWithD(name) { + return name[0] === "D"; +} /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/Homework/G-conditionals-2/exercise-1.js b/week-2/Homework/G-conditionals-2/exercise-1.js index 54708ef6..62189f74 100644 --- a/week-2/Homework/G-conditionals-2/exercise-1.js +++ b/week-2/Homework/G-conditionals-2/exercise-1.js @@ -7,7 +7,7 @@ */ function negativeOrPositive(number) { - + return number < 0 ? "negative" : "positive" } /* diff --git a/week-2/Homework/G-conditionals-2/exercise-2.js b/week-2/Homework/G-conditionals-2/exercise-2.js index 313f3fb2..d8730177 100644 --- a/week-2/Homework/G-conditionals-2/exercise-2.js +++ b/week-2/Homework/G-conditionals-2/exercise-2.js @@ -8,7 +8,7 @@ */ function studentPassed(grade) { - + return grade < 50 ? "failed" : "passed" } /* diff --git a/week-2/Homework/G-conditionals-2/exercise-3.js b/week-2/Homework/G-conditionals-2/exercise-3.js index a79cf30e..7a1d1177 100644 --- a/week-2/Homework/G-conditionals-2/exercise-3.js +++ b/week-2/Homework/G-conditionals-2/exercise-3.js @@ -9,7 +9,18 @@ */ function calculateGrade(mark) { - + if (mark>=80) { + return "A" + } + else if (mark<80 && mark>60) { + return "B" + } + else if (mark<=60 && !(mark<50)) { + return "C" + } + else { + return "F" + } } /* diff --git a/week-2/Homework/G-conditionals-2/exercise-4.js b/week-2/Homework/G-conditionals-2/exercise-4.js index bd5bb1ef..50b11966 100644 --- a/week-2/Homework/G-conditionals-2/exercise-4.js +++ b/week-2/Homework/G-conditionals-2/exercise-4.js @@ -9,6 +9,7 @@ */ function containsCode(sentence) { + return sentence.includes("code") ? true : false } diff --git a/week-2/Homework/H-array-literals/exercise.js b/week-2/Homework/H-array-literals/exercise.js index d6dc556a..3d615f13 100644 --- a/week-2/Homework/H-array-literals/exercise.js +++ b/week-2/Homework/H-array-literals/exercise.js @@ -4,8 +4,8 @@ Declare some variables assigned to arrays of values */ -var numbers = []; // add numbers from 1 to 10 into this array -var mentors; // Create an array with the names of the mentors: Daniel, Irina and Rares +var numbers = [1,2,3,4,5,6,7,8,9,10]; // add numbers from 1 to 10 into this array +var 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/week-2/Homework/I-array-properties/exercise.js b/week-2/Homework/I-array-properties/exercise.js index f9aec89f..163dda7f 100644 --- a/week-2/Homework/I-array-properties/exercise.js +++ b/week-2/Homework/I-array-properties/exercise.js @@ -6,7 +6,12 @@ */ function isEmpty(arr) { - return; // complete this statement + if(arr.length ==0 ) { + return true; + } + else { + return false; + } // complete this statement } /* diff --git a/week-2/Homework/J-array-get-set/exercise.js b/week-2/Homework/J-array-get-set/exercise.js index 3b95694e..43026ab6 100644 --- a/week-2/Homework/J-array-get-set/exercise.js +++ b/week-2/Homework/J-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/week-2/Homework/J-array-get-set/exercises2.js b/week-2/Homework/J-array-get-set/exercises2.js index 97f126f3..79dc14ee 100644 --- a/week-2/Homework/J-array-get-set/exercises2.js +++ b/week-2/Homework/J-array-get-set/exercises2.js @@ -7,7 +7,7 @@ */ var numbers = [1, 2, 3]; // Don't change this array literal declaration - +numbers.push(4); /* DO NOT EDIT BELOW THIS LINE --------------------------- */ diff --git a/week-2/Homework/K-while-loop/exercise.js b/week-2/Homework/K-while-loop/exercise.js index c5662fe0..aee6fc1c 100644 --- a/week-2/Homework/K-while-loop/exercise.js +++ b/week-2/Homework/K-while-loop/exercise.js @@ -7,9 +7,13 @@ */ let n = 10; - +let sum=0,i=1 function sumTillNum(num){ - //your code here + while(i<=num) { + sum+=i; + i++ + }//your code here + return sum; } console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); diff --git a/week-2/Homework/L-for-loop/exercise.js b/week-2/Homework/L-for-loop/exercise.js index 151a60da..86706b03 100644 --- a/week-2/Homework/L-for-loop/exercise.js +++ b/week-2/Homework/L-for-loop/exercise.js @@ -9,7 +9,11 @@ let n = 10; function sumTillNum(num){ - //your code here + let sum = 0 //your code here + for (let i=1; i <=num; i++) { + sum += i + } + return sum } console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); diff --git a/week-2/Homework/M-array-loop/exercise.js b/week-2/Homework/M-array-loop/exercise.js index b79956a5..38e10042 100644 --- a/week-2/Homework/M-array-loop/exercise.js +++ b/week-2/Homework/M-array-loop/exercise.js @@ -12,4 +12,14 @@ const daysOfWeek = [ "Friday", "Saturday", "Sunday", -]; \ No newline at end of file +]; + +function showDaysOfWeek(days,letter) { + for(let d=0; d Date: Sat, 10 Sep 2022 17:49:25 +0200 Subject: [PATCH 3/3] Week3 HomeWork --- week-3/Homework/A-array-find/exercise.js | 10 +++++++--- week-3/Homework/B-array-some/exercise.js | 17 +++++++++++++++++ week-3/Homework/C-array-every/exercise.js | 5 ++++- week-3/Homework/D-array-filter/exercise.js | 9 ++++++++- week-3/Homework/E-array-map/exercise.js | 3 +++ week-3/Homework/F-array-forEach/exercise.js | 17 +++++++++++++++++ week-3/Homework/G-array-methods/exercise.js | 2 +- week-3/Homework/G-array-methods/exercise2.js | 2 +- week-3/Homework/H-array-methods-2/exercise.js | 4 ++-- week-3/Homework/H-array-methods-2/exercise2.js | 6 +++++- week-3/Homework/H-array-methods-2/exercise3.js | 2 +- 11 files changed, 66 insertions(+), 11 deletions(-) diff --git a/week-3/Homework/A-array-find/exercise.js b/week-3/Homework/A-array-find/exercise.js index d7fd51f8..4ca9f2d1 100644 --- a/week-3/Homework/A-array-find/exercise.js +++ b/week-3/Homework/A-array-find/exercise.js @@ -4,10 +4,14 @@ */ // write your code here +function findLongNameThatStartsWithA(arr) { + return arr.find(function(name) { + return name[0] == "A" && name.length > 7 + }) +} -var names = ["Rakesh", "Antonio", "Alexandra", "Andronicus", "Annam", "Mikey", "Anastasia", "Karim", "Ahmed"]; - -var longNameThatStartsWithA = findLongNameThatStartsWithA(names); +const names = ["Rakesh", "Antonio", "Alexandra", "Andronicus", "Annam", "Mikey", "Anastasia", "Karim", "Ahmed"]; +const longNameThatStartsWithA = findLongNameThatStartsWithA(names); console.log(longNameThatStartsWithA); diff --git a/week-3/Homework/B-array-some/exercise.js b/week-3/Homework/B-array-some/exercise.js index 965c0524..febf5d39 100644 --- a/week-3/Homework/B-array-some/exercise.js +++ b/week-3/Homework/B-array-some/exercise.js @@ -8,6 +8,7 @@ var pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]]; + // If there is a null value in the array exit the program with the error code // https://nodejs.org/api/process.html#process_process_exit_code // process.exit(1); @@ -15,6 +16,22 @@ var pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]]; var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; +function checkNullValue(array) { + if (array === null) { + return true; + } + else { + return false; + } +} + +let result = pairsByIndex.some(checkNullValue); +console.log(result); + +if (result === true) { + process.exit(1); +} + var pairs = pairsByIndex.map(function(indexes) { var student = students[indexes[0]]; var mentor = mentors[indexes[1]]; diff --git a/week-3/Homework/C-array-every/exercise.js b/week-3/Homework/C-array-every/exercise.js index b515e941..bf1c5412 100644 --- a/week-3/Homework/C-array-every/exercise.js +++ b/week-3/Homework/C-array-every/exercise.js @@ -5,7 +5,10 @@ var students = ["Omar", "Austine", "Dany", "Swathi", "Lesley", "Rukmini"]; var group = ["Austine", "Dany", "Swathi", "Daniel"]; -var groupIsOnlyStudents; // complete this statement +var OnlyStudents = group.filter(student => students.includes(student)); +let groupIsOnlyStudents = group.concat.length == OnlyStudents.length + +groupIsOnlyStudents = group.every(e => students.includes(e)) if (groupIsOnlyStudents) { console.log("The group contains only students"); diff --git a/week-3/Homework/D-array-filter/exercise.js b/week-3/Homework/D-array-filter/exercise.js index 6e32cc6b..48698cbe 100644 --- a/week-3/Homework/D-array-filter/exercise.js +++ b/week-3/Homework/D-array-filter/exercise.js @@ -8,7 +8,14 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; -var pairsByIndex; // Complete this statement +var pairsByIndex = pairsByIndexRaw.filter((id) => { + if (id != null && id.length ==2) { + return true; + } + else { + return false; + } +}); var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; diff --git a/week-3/Homework/E-array-map/exercise.js b/week-3/Homework/E-array-map/exercise.js index 2835e922..6f323192 100644 --- a/week-3/Homework/E-array-map/exercise.js +++ b/week-3/Homework/E-array-map/exercise.js @@ -2,4 +2,7 @@ // Write multiple solutions using different syntax (as shown in the README) var numbers = [0.1, 0.2, 0.3, 0.4, 0.5]; +let multiplyNumbers = numbers.map((number) => number * 100); + +console.log(multiplyNumbers); diff --git a/week-3/Homework/F-array-forEach/exercise.js b/week-3/Homework/F-array-forEach/exercise.js index e83e2df6..57fdb90e 100644 --- a/week-3/Homework/F-array-forEach/exercise.js +++ b/week-3/Homework/F-array-forEach/exercise.js @@ -9,6 +9,23 @@ var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; +function fizzBuzz(number) { + if (number % 3 == 0 && number % 5 == 0) { + console.log("FizzBuzz"); + } + else if(number % 5 == 0) { + console.log("Buzz") + } + else if (number % 3 == 0) { + console.log("Fizz"); + } + else { + console.log(number); + } +} + +arr.forEach(fizzBuzz); + /* EXPECTED OUTPUT */ /* diff --git a/week-3/Homework/G-array-methods/exercise.js b/week-3/Homework/G-array-methods/exercise.js index 44e9c801..153cea89 100644 --- a/week-3/Homework/G-array-methods/exercise.js +++ b/week-3/Homework/G-array-methods/exercise.js @@ -4,7 +4,7 @@ */ var numbers = [3, 2, 1]; -var sortedNumbers; // complete this statement +const sortedNumbers = numbers.sort(); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-3/Homework/G-array-methods/exercise2.js b/week-3/Homework/G-array-methods/exercise2.js index 3dd24a17..dd87089e 100644 --- a/week-3/Homework/G-array-methods/exercise2.js +++ b/week-3/Homework/G-array-methods/exercise2.js @@ -7,7 +7,7 @@ var mentors = ["Daniel", "Irina", "Rares"]; var students = ["Rukmini", "Abdul", "Austine", "Swathi"]; -var everyone; // complete this statement +var everyone = mentors.concat(students); // complete this statement /* DO NOT EDIT BELOW THIS LINE diff --git a/week-3/Homework/H-array-methods-2/exercise.js b/week-3/Homework/H-array-methods-2/exercise.js index d36303b8..7f48be66 100644 --- a/week-3/Homework/H-array-methods-2/exercise.js +++ b/week-3/Homework/H-array-methods-2/exercise.js @@ -15,8 +15,8 @@ var everyone = [ "Swathi" ]; -var firstFive; // complete this statement -var lastFive; // complete this statement +var firstFive = everyone.slice(0,5); // complete this statement +var lastFive = everyone.slice(everyone.length -5); // complete this statement /* DO NOT EDIT BELOW THIS LINE diff --git a/week-3/Homework/H-array-methods-2/exercise2.js b/week-3/Homework/H-array-methods-2/exercise2.js index b7be576e..4f7eb0da 100644 --- a/week-3/Homework/H-array-methods-2/exercise2.js +++ b/week-3/Homework/H-array-methods-2/exercise2.js @@ -7,7 +7,11 @@ Tip: use the string method .split() and the array method .join() */ -function capitalise(str) {} +function capitalise(str) { + const string = str.split("") + string[0] = string[0].toUpperCase() + return string.join("") +} /* DO NOT EDIT BELOW THIS LINE diff --git a/week-3/Homework/H-array-methods-2/exercise3.js b/week-3/Homework/H-array-methods-2/exercise3.js index 82e9dd8c..75a6b760 100644 --- a/week-3/Homework/H-array-methods-2/exercise3.js +++ b/week-3/Homework/H-array-methods-2/exercise3.js @@ -7,7 +7,7 @@ var ukNations = ["Scotland", "Wales", "England", "Northern Ireland"]; function isInUK(country) { - return; // complete this statement + return ukNations.includes(country); // complete this statement } /*