diff --git a/week-1/Extra/1-syntax-errors.js b/week-1/Extra/1-syntax-errors.js index fb756b63..b932e761 100644 --- a/week-1/Extra/1-syntax-errors.js +++ b/week-1/Extra/1-syntax-errors.js @@ -1,17 +1,17 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(a b c) { +function addNumbers(a ,b, c) { return a + b + c; } function introduceMe(name, age) -return "Hello, my name is " + name "and I am " age + "years old"; +return "Hello, my name is " + name +" and I am "+ age + "years old"; function getTotal(a, b) { - total = a ++ b; + total = a + b; // Use string interpolation here - return "The total is %{total}" + return `The total is ${total}` } /* ======= TESTS - DO NOT MODIFY ===== diff --git a/week-1/Extra/2-logic-error.js b/week-1/Extra/2-logic-error.js index c8444605..848fe937 100644 --- a/week-1/Extra/2-logic-error.js +++ b/week-1/Extra/2-logic-error.js @@ -1,7 +1,7 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return word.trim(); } function getWordLength(word) { diff --git a/week-1/Extra/4-tax.js b/week-1/Extra/4-tax.js index 79db5409..78761fde 100644 --- a/week-1/Extra/4-tax.js +++ b/week-1/Extra/4-tax.js @@ -5,7 +5,10 @@ Sales tax is 20% of the price of the product */ -function calculateSalesTax() {} +function calculateSalesTax(price,tax) { + return price*tax +} +calculateSalesTax(500,20%) /* CURRENCY FORMATTING @@ -17,7 +20,9 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency( price,tax) { + return price+tax +} /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. diff --git a/week-1/Homework/F-strings-methods/exercise.js b/week-1/Homework/F-strings-methods/exercise.js index 2cffa6a8..8ded44ac 100644 --- a/week-1/Homework/F-strings-methods/exercise.js +++ b/week-1/Homework/F-strings-methods/exercise.js @@ -1,3 +1,9 @@ // Start by creating a variable `message` +var na= "mamadou"; +var na1=na.length +var text= `ny name is ${na} it is composed of ${na1} caracters `; -console.log(message); + +console.log(text); +var mes +var diff --git a/week-1/Homework/F-strings-methods/exercise2.js b/week-1/Homework/F-strings-methods/exercise2.js index b4b46943..72f8fa34 100644 --- a/week-1/Homework/F-strings-methods/exercise2.js +++ b/week-1/Homework/F-strings-methods/exercise2.js @@ -1,3 +1,7 @@ -const name = " Daniel "; +const pas = " Daniel "; +const trimpas=pas.trim() +const lenpas=trimpas.length +var message=" my name is "+trimpas+ " and my name has " +lenpas+" carracters"; console.log(message); + diff --git a/week-1/Homework/J-functions/exercise.js b/week-1/Homework/J-functions/exercise.js index 0ae5850e..e9ba2f0e 100644 --- a/week-1/Homework/J-functions/exercise.js +++ b/week-1/Homework/J-functions/exercise.js @@ -1,5 +1,6 @@ function halve(number) { // complete the function here + return number/2; } var result = halve(12); diff --git a/week-1/Homework/J-functions/exercise2.js b/week-1/Homework/J-functions/exercise2.js index 82ef5e78..6d216ffc 100644 --- a/week-1/Homework/J-functions/exercise2.js +++ b/week-1/Homework/J-functions/exercise2.js @@ -1,5 +1,6 @@ function triple(number) { // complete function here + return number*3; } 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..2271caed 100644 --- a/week-1/Homework/K-functions-parameters/exercise.js +++ b/week-1/Homework/K-functions-parameters/exercise.js @@ -1,7 +1,8 @@ // Complete the function so that it takes input parameters -function multiply() { +function multiply(hour , price) { + return hour*price; // Calculate the result of the function and return it -} +} // Assign the result of calling the function the variable `result` var result = multiply(3, 4); diff --git a/week-1/Homework/K-functions-parameters/exercise2.js b/week-1/Homework/K-functions-parameters/exercise2.js index db7a8904..cc7b5aa2 100644 --- a/week-1/Homework/K-functions-parameters/exercise2.js +++ b/week-1/Homework/K-functions-parameters/exercise2.js @@ -1,4 +1,8 @@ // Declare your function first +function divide(height,mass) { + return height/mass; + +} var result = divide(3, 4); diff --git a/week-1/Homework/K-functions-parameters/exercise3.js b/week-1/Homework/K-functions-parameters/exercise3.js index 537e9f4e..3df8af64 100644 --- a/week-1/Homework/K-functions-parameters/exercise3.js +++ b/week-1/Homework/K-functions-parameters/exercise3.js @@ -1,4 +1,9 @@ // Write your function here +function createGreeting(name){ + var message =` hello, my name is ${name}.`; + return message + +} var greeting = createGreeting("Daniel"); diff --git a/week-1/Homework/K-functions-parameters/exercise4.js b/week-1/Homework/K-functions-parameters/exercise4.js index 7ab44589..3681937f 100644 --- a/week-1/Homework/K-functions-parameters/exercise4.js +++ b/week-1/Homework/K-functions-parameters/exercise4.js @@ -1,4 +1,8 @@ // Declare your function first +function passing(num1,num2){ + return num1+num2 +} +var sum =passing(13,124) // Call the function and assign to a variable `sum` diff --git a/week-1/Homework/K-functions-parameters/exercise5.js b/week-1/Homework/K-functions-parameters/exercise5.js index 7c5bcd60..fcbdd8fa 100644 --- a/week-1/Homework/K-functions-parameters/exercise5.js +++ b/week-1/Homework/K-functions-parameters/exercise5.js @@ -1,4 +1,8 @@ // Declare your function here +function createLongGreeting(name,age){ + var message=` hello my name is ${name} and i am ${age} years old.` + return message +} 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..d4413273 100644 --- a/week-1/Homework/L-functions-nested/exercise.js +++ b/week-1/Homework/L-functions-nested/exercise.js @@ -3,3 +3,20 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; +var greeting="hello" + +function upper(greeting){ + return greeting.toUpperCase(); +} +//console.log(upper(greeting)) + +function bigup(name,greeting){ + var up= upper(greeting) + return up+" " +name + console.log(bigup) +} +console.log(bigup(mentor1,greeting)); +console.log(bigup(mentor2,greeting)); +console.log(bigup(mentor3,greeting)); +console.log(bigup(mentor4,greeting)); +console.log(bigup(mentor5,greeting)); \ No newline at end of file diff --git a/week-1/InClass/exercise-A.js b/week-1/InClass/exercise-A.js index e69de29b..07816631 100644 --- a/week-1/InClass/exercise-A.js +++ b/week-1/InClass/exercise-A.js @@ -0,0 +1 @@ +console.log("hi") \ No newline at end of file diff --git a/week-1/InClass/exercise-B.js b/week-1/InClass/exercise-B.js index e69de29b..82b07ca6 100644 --- a/week-1/InClass/exercise-B.js +++ b/week-1/InClass/exercise-B.js @@ -0,0 +1,13 @@ +var doto= "word"; +console.log("hello " + doto); + +console.log("hello "+ doto); +var doto= "world"; +console.log("hello " + doto); +var world= "mond"; +console.log("hello "+ world); +var world= "mundo"; +var world= "aduna"; +console.log("hello "+ world); + + diff --git a/week-1/InClass/exercise-C.js b/week-1/InClass/exercise-C.js index e69de29b..334e6049 100644 --- a/week-1/InClass/exercise-C.js +++ b/week-1/InClass/exercise-C.js @@ -0,0 +1,2 @@ +const greeting =" Hi" +console.log(greeting) \ No newline at end of file diff --git a/week-1/InClass/exercise-D.js b/week-1/InClass/exercise-D.js index e69de29b..067b3fa3 100644 --- a/week-1/InClass/exercise-D.js +++ b/week-1/InClass/exercise-D.js @@ -0,0 +1,4 @@ +const colors="blue ,yellow"; +console.log(typeof colors) +const number = 34 +console.log(typeof colors) \ No newline at end of file diff --git a/week-1/InClass/exercise-E.js b/week-1/InClass/exercise-E.js index e69de29b..528b27a6 100644 --- a/week-1/InClass/exercise-E.js +++ b/week-1/InClass/exercise-E.js @@ -0,0 +1,6 @@ +const pres="i live in "; +const city="barcelon"; +const mytown= pres +city; +console.log(mytown) +const town=`actually ${pres} a city named ${city}`; +console.log(town) diff --git a/week-1/InClass/exercise-F.js b/week-1/InClass/exercise-F.js index e69de29b..3bcf3ac0 100644 --- a/week-1/InClass/exercise-F.js +++ b/week-1/InClass/exercise-F.js @@ -0,0 +1,4 @@ +const numerofstudent=45; +const numberofmentor=20; +const total =numerofstudent+numberofmentor; +console.log(total) \ No newline at end of file diff --git a/week-1/InClass/exercise-G.js b/week-1/InClass/exercise-G.js index e69de29b..44966188 100644 --- a/week-1/InClass/exercise-G.js +++ b/week-1/InClass/exercise-G.js @@ -0,0 +1,7 @@ +const numerofstudent=45; +const numberofmentor=20; +const total =numerofstudent+numberofmentor; + +const nbrstudentpermentor=Math.round(numerofstudent/numberofmentor)*100 ; +const nbrmentorperstudent=Math.round(numberofmentor/numerofstudent)*100; +console.log(nbrmentorperstudent,nbrstudentpermentor) \ No newline at end of file diff --git a/week-1/InClass/exercise-H.js b/week-1/InClass/exercise-H.js index e69de29b..1615a6ca 100644 --- a/week-1/InClass/exercise-H.js +++ b/week-1/InClass/exercise-H.js @@ -0,0 +1,11 @@ +function myage(my,age){ + const myage=my+age; + + console.log(myage) + +} +var my=" i have " +var age="30 years" +myage(my, age) +/* THIS FUNCTION GIVE THE AGE OF THE PERSON*/ +//Return is used to interrupt the flow of execution of a function and return some value (or not). console.log is used to print information to the console // \ No newline at end of file diff --git a/week-1/InClass/exercise-I.js b/week-1/InClass/exercise-I.js index e69de29b..a3127a57 100644 --- a/week-1/InClass/exercise-I.js +++ b/week-1/InClass/exercise-I.js @@ -0,0 +1,11 @@ +function calcby(yrs){ + return 2021-yrs; +} + +function myinfo(fulln,yofb){ + const calcb =calcby(yofb) + const data="my name is "+fulln+" and i was born in "+calcb; + return data; + console.log(myinfo) +} +myinfo("marc",19) diff --git a/week-1/InClass/text.js b/week-1/InClass/text.js new file mode 100644 index 00000000..04479bd7 --- /dev/null +++ b/week-1/InClass/text.js @@ -0,0 +1,11 @@ +function calcby(yrs){ + return 2021-yrs; +} + +function myinfo(fulln,yofb){ + const calcb =calcby(yofb) + const data="my name is "+fulln+" and i was born in "+calcb; + return data; + console.log(myinfo) +} +myinfo("marc",19) \ No newline at end of file diff --git a/week-2/Homework/C-comparison-operators/exercise.js b/week-2/Homework/C-comparison-operators/exercise.js index 58aee1c5..7fb2841d 100644 --- a/week-2/Homework/C-comparison-operators/exercise.js +++ b/week-2/Homework/C-comparison-operators/exercise.js @@ -7,14 +7,16 @@ var studentCount = 16; var mentorCount = 9; -var moreStudentsThanMentors; // finish this statement +var moreStudentsThanMentors = studentCount>mentorCount; + + var roomMaxCapacity = 25; -var enoughSpaceInRoom; // finish this statement +var enoughSpaceInRoom=roomMaxCapacity<=(studentCount+mentorCount) ; var personA = "Daniel"; var personB = "Irina"; -var sameName; // finish this statement +var sameName=personA===personB; /* 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..6a74a683 100644 --- a/week-2/Homework/E-conditionals/exercise.js +++ b/week-2/Homework/E-conditionals/exercise.js @@ -8,6 +8,11 @@ var name = "Daniel"; var danielsRole = "mentor"; +if(danielsRole==="mentor"){ + console.log(`Hi,I am ${name}, i am a ${danielsRole}`) +}else if(danielsRole==="student"){ + console.log(`Hi, I am ${name}, I am 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..519d5c1f 100644 --- a/week-2/Homework/F-logical-operators/exercise.js +++ b/week-2/Homework/F-logical-operators/exercise.js @@ -11,14 +11,14 @@ 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>cssLevel); +var cssLevelAbove5=(cssLevel>htmlLevel); // Finish the next two statement // Use the previous variables and logical operators // Do not "hardcode" the answers -var cssAndHtmlAbove5; -var cssOrHtmlAbove5; +var cssAndHtmlAbove5=htmlLevel && cssLevel>5; +var cssOrHtmlAbove5= htmlLevel>5 || cssLevel>5; /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/Homework/F-logical-operators/exercise2.js b/week-2/Homework/F-logical-operators/exercise2.js index fcc99247..e6560aa2 100644 --- a/week-2/Homework/F-logical-operators/exercise2.js +++ b/week-2/Homework/F-logical-operators/exercise2.js @@ -5,7 +5,18 @@ Update the code so that you get the expected result. */ -function isNegative() {} +function isNegative() { + if(-10<0){ + return true + }; + if(5<0); + if(10<=10&&10>5); + +} + + + + /* 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..2cbdb54a 100644 --- a/week-2/Homework/G-conditionals-2/exercise-1.js +++ b/week-2/Homework/G-conditionals-2/exercise-1.js @@ -7,6 +7,8 @@ */ function negativeOrPositive(number) { + if(number>=0)return "positive"; + else return "negative"; } diff --git a/week-2/Homework/G-conditionals-2/exercise-2.js b/week-2/Homework/G-conditionals-2/exercise-2.js index 313f3fb2..774df071 100644 --- a/week-2/Homework/G-conditionals-2/exercise-2.js +++ b/week-2/Homework/G-conditionals-2/exercise-2.js @@ -8,6 +8,10 @@ */ function studentPassed(grade) { + if(grade<=50){ + return "failed"; + } + else return"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..70ad6abf 100644 --- a/week-2/Homework/G-conditionals-2/exercise-3.js +++ b/week-2/Homework/G-conditionals-2/exercise-3.js @@ -9,6 +9,17 @@ */ 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..a7741c49 100644 --- a/week-2/Homework/G-conditionals-2/exercise-4.js +++ b/week-2/Homework/G-conditionals-2/exercise-4.js @@ -9,6 +9,10 @@ */ function containsCode(sentence) { + if(sentence.includes("code")){ + return true; + } + else return false; } diff --git a/week-2/Homework/H-array-literals/exercise.js b/week-2/Homework/H-array-literals/exercise.js index d6dc556a..0f6d4c51 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..674033c1 100644 --- a/week-2/Homework/I-array-properties/exercise.js +++ b/week-2/Homework/I-array-properties/exercise.js @@ -6,7 +6,11 @@ */ function isEmpty(arr) { - return; // complete this statement + if(arr==""){ + 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..cbb60c10 100644 --- a/week-2/Homework/J-array-get-set/exercises2.js +++ b/week-2/Homework/J-array-get-set/exercises2.js @@ -7,6 +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..ee6319cc 100644 --- a/week-2/Homework/K-while-loop/exercise.js +++ b/week-2/Homework/K-while-loop/exercise.js @@ -9,7 +9,22 @@ let n = 10; function sumTillNum(num){ + let x=0; +let result=0; +while(x<=10){ + console.log(x,result); + x++; + result=result+x; + + + + + + + + //console.log(sumTillNum(n)) + //your code here } - -console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); +} +//console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); \ No newline at end of file diff --git a/week-2/Homework/K-while-loop/exercise1.js b/week-2/Homework/K-while-loop/exercise1.js new file mode 100644 index 00000000..8122a320 --- /dev/null +++ b/week-2/Homework/K-while-loop/exercise1.js @@ -0,0 +1,10 @@ + +//function sumTillNum(num){ +let x=0; +let result=0; +while(x<=10){ + console.log(x,result); + x++; + result=result+x; +} +//} \ No newline at end of file diff --git a/week-2/Homework/L-for-loop/exercise.js b/week-2/Homework/L-for-loop/exercise.js index 151a60da..13d8fe9d 100644 --- a/week-2/Homework/L-for-loop/exercise.js +++ b/week-2/Homework/L-for-loop/exercise.js @@ -7,9 +7,33 @@ */ let n = 10; +let nums=[1,2,3,4,5,6,7,8,9,10]; + + + function sumTillNum(num){ - //your code here + n=10; +let sum=0 +for(var i=0; i 5 && num < 15 +num < 10 || num === 10 +false || true +!true +let greaterThan5 = num > 5 +!greaterThan5 +!(num === 10) \ No newline at end of file diff --git a/week-2/InClass/exercise-F.js b/week-2/InClass/exercise-F.js index e69de29b..fde49e41 100644 --- a/week-2/InClass/exercise-F.js +++ b/week-2/InClass/exercise-F.js @@ -0,0 +1,16 @@ +function checkuser(username,type){ + if (username[0].toUpperCase()===username[0] && username.length<10 && username.length>5){ + return"Username valid"; + } + else if(type==="mamager"||type==="admin"){ + return "Username valid" + } + else return "Username invalid"; + + } + + console.log(acces); + + + var acces = checkuser("Mamadou","employee"); + console.log(acces,) \ No newline at end of file diff --git a/week-2/InClass/exercise-G.js b/week-2/InClass/exercise-G.js index efbb01e2..ded28301 100644 --- a/week-2/InClass/exercise-G.js +++ b/week-2/InClass/exercise-G.js @@ -1,4 +1,9 @@ var apolloCountdownMessage = "all engine running... LIFT-OFF!"; var countdown = 8; +while (countdown >=0){ + console.log(countdown); +countdown--; +} -console.log(apolloCountdownMessage); \ No newline at end of file + +console.log(apolloCountdownMessage); diff --git a/week-3/Homework/A-array-find/exercise.js b/week-3/Homework/A-array-find/exercise.js index d7fd51f8..14e935a4 100644 --- a/week-3/Homework/A-array-find/exercise.js +++ b/week-3/Homework/A-array-find/exercise.js @@ -7,9 +7,12 @@ var names = ["Rakesh", "Antonio", "Alexandra", "Andronicus", "Annam", "Mikey", "Anastasia", "Karim", "Ahmed"]; -var longNameThatStartsWithA = findLongNameThatStartsWithA(names); -console.log(longNameThatStartsWithA); +var longNameThatStartsWithA= names.find(element => element.length > 7 && element[0]=="A"); + + +console.log(longNameThatStartsWithA) +; /* EXPECTED OUTPUT */ // "Alexandra" diff --git a/week-3/Homework/B-array-some/exercise.js b/week-3/Homework/B-array-some/exercise.js index 965c0524..c0711346 100644 --- a/week-3/Homework/B-array-some/exercise.js +++ b/week-3/Homework/B-array-some/exercise.js @@ -7,6 +7,9 @@ */ var pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]]; +var nullval=pairsByIndex.some(function(pair) +{if(Array.isArray(pair) && pair!=null) + {return} break // 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 diff --git a/week-3/Homework/C-array-every/exercise.js b/week-3/Homework/C-array-every/exercise.js index b515e941..9866cc7d 100644 --- a/week-3/Homework/C-array-every/exercise.js +++ b/week-3/Homework/C-array-every/exercise.js @@ -5,9 +5,13 @@ var students = ["Omar", "Austine", "Dany", "Swathi", "Lesley", "Rukmini"]; var group = ["Austine", "Dany", "Swathi", "Daniel"]; -var groupIsOnlyStudents; // complete this statement +var groupIsOnlyStudents = group.every(function(pers){ + return students.includes(pers) +}); -if (groupIsOnlyStudents) { +// complete this statement + +if (groupIsOnlyStudents === true) { console.log("The group contains only students"); } else { console.log("The group does not contain only students"); diff --git a/week-3/Homework/D-array-filter/exercise.js b/week-3/Homework/D-array-filter/exercise.js index 6e32cc6b..0b54d78f 100644 --- a/week-3/Homework/D-array-filter/exercise.js +++ b/week-3/Homework/D-array-filter/exercise.js @@ -8,7 +8,7 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; -var pairsByIndex; // Complete this statement +var pairsByIndex=pairsByIndexRaw.filter(function(tres){if(Array.isArray(tres) && tres.length>1){return true}}); // Complete this statement var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; @@ -20,3 +20,6 @@ var pairs = pairsByIndex.map(function(indexes) { }); console.log(pairs); +console.log(pairsByIndex) + + diff --git a/week-3/Homework/E-array-map/exercise.js b/week-3/Homework/E-array-map/exercise.js index 2835e922..0a0058ea 100644 --- a/week-3/Homework/E-array-map/exercise.js +++ b/week-3/Homework/E-array-map/exercise.js @@ -2,4 +2,8 @@ // Write multiple solutions using different syntax (as shown in the README) var numbers = [0.1, 0.2, 0.3, 0.4, 0.5]; +var numbermulti =numbers.map(function(number){return number*100}) +console.log(numbermulti) +var numbermulti2 =numbers.map(number=>number*100) +console.log(numbermulti2); diff --git a/week-3/Homework/F-array-forEach/exercise.js b/week-3/Homework/F-array-forEach/exercise.js index e83e2df6..ea1ce065 100644 --- a/week-3/Homework/F-array-forEach/exercise.js +++ b/week-3/Homework/F-array-forEach/exercise.js @@ -8,6 +8,14 @@ */ var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; +arr.forEach(function(num){ + if(num % 3==0 && num%5==0 ) {console.log("Fizzbuzz")} + else if(num % 3==0){console.log("Fizz")} + else if(num % 5==0){console.log("buzz")} + + else {console.log(num)} +}) + /* EXPECTED OUTPUT */ diff --git a/week-3/Homework/G-array-methods/exercise.js b/week-3/Homework/G-array-methods/exercise.js index 44e9c801..b16182ba 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 +var sortedNumbers =numbers.sort(); // complete this statement /* 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..e0bacb78 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..cd66a16d 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(2,8); // 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..d5a37152 100644 --- a/week-3/Homework/H-array-methods-2/exercise2.js +++ b/week-3/Homework/H-array-methods-2/exercise2.js @@ -7,10 +7,23 @@ Tip: use the string method .split() and the array method .join() */ -function capitalise(str) {} + +function capitalise(str) { + var strspl=str.split("") + +var strsplup= strspl[0].toUpperCase(0); + + return strsplup+strspl.join("").slice(1) + + + + +} + /* DO NOT EDIT BELOW THIS LINE + --------------------------- */ var name = "daniel"; diff --git a/week-3/Homework/H-array-methods-2/exercise3.js b/week-3/Homework/H-array-methods-2/exercise3.js index 82e9dd8c..1b092a7b 100644 --- a/week-3/Homework/H-array-methods-2/exercise3.js +++ b/week-3/Homework/H-array-methods-2/exercise3.js @@ -6,9 +6,11 @@ var ukNations = ["Scotland", "Wales", "England", "Northern Ireland"]; -function isInUK(country) { - return; // complete this statement -} + +function isInUK(country) {if(ukNations.includes(country)) + {return true} + else {return false}; // complete this statement + } /* DO NOT EDIT BELOW THIS LINE diff --git a/week-3/InClass/exercise-B.js b/week-3/InClass/exercise-B.js index e69de29b..05c9fdce 100644 --- a/week-3/InClass/exercise-B.js +++ b/week-3/InClass/exercise-B.js @@ -0,0 +1,9 @@ +inclass=["diego","saidu","mamadou"]; +otherclass=["fran","maxwell","bianca",]; +both=inclass.concat(otherclass); +console.log(both.sort()); + + + + + \ No newline at end of file diff --git a/week-3/InClass/exercise-C.js b/week-3/InClass/exercise-C.js index e69de29b..067c37cb 100644 --- a/week-3/InClass/exercise-C.js +++ b/week-3/InClass/exercise-C.js @@ -0,0 +1,18 @@ + +function magician(yourFunc) { + console.log( + "I am magician! Watch as I mutate an array of strings to your heart's content!" + ); + const namesArray = [ + "James", + "Elamin", + "Ismael", + "Sanyia", + "Chris", + "Antigoni", + ]; + + const magicOutput = yourFunc(namesArray); + + return magicOutput; + } \ No newline at end of file diff --git a/week-3/InClass/exercise-E.js b/week-3/InClass/exercise-E.js index e69de29b..a29bc514 100644 --- a/week-3/InClass/exercise-E.js +++ b/week-3/InClass/exercise-E.js @@ -0,0 +1,6 @@ +let years=[1964, 2008, 1999, 2005, 1978, 1985, 1919] + + return names.forEach(function (year,) { return 2021-year; + console.log(); + }); +} diff --git a/week-3/InClass/exercise-F.js b/week-3/InClass/exercise-F.js index e69de29b..3e0b2521 100644 --- a/week-3/InClass/exercise-F.js +++ b/week-3/InClass/exercise-F.js @@ -0,0 +1,5 @@ +years=[ 1964, 2008, 1999, 2005, 1978, 1985, 1919 ] +function drive (yearofb){ + years.forEach(yearofb)=>{2021-yearofb}; +} +console.log(candrive(years)); \ No newline at end of file diff --git a/week-3/InClass/exercise-G.js b/week-3/InClass/exercise-G.js index e69de29b..46a00046 100644 --- a/week-3/InClass/exercise-G.js +++ b/week-3/InClass/exercise-G.js @@ -0,0 +1,4 @@ +let an=[ 18,19,12,14,43,76,]; +function(yrs) { + return yrs=> 17;} +console.log(drive(an.forEach(yrs))); \ No newline at end of file diff --git a/week-3/InClass/exercise-H.js b/week-3/InClass/exercise-H.js index e69de29b..8960b24b 100644 --- a/week-3/InClass/exercise-H.js +++ b/week-3/InClass/exercise-H.js @@ -0,0 +1,2 @@ +le +function ami() \ No newline at end of file