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..e63d800f 100644 --- a/week-2/Homework/F-logical-operators/exercise2.js +++ b/week-2/Homework/F-logical-operators/exercise2.js @@ -5,7 +5,16 @@ Update the code so that you get the expected result. */ -function isNegative() {} +function isNegative() { + if(-10<0?true:false); + if(5<0?true:false); + if(10<=10&&10>5?true:false); + +} + + + + /* 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/L-for-loop/exercise.js b/week-2/Homework/L-for-loop/exercise.js index 151a60da..66a5f0ee 100644 --- a/week-2/Homework/L-for-loop/exercise.js +++ b/week-2/Homework/L-for-loop/exercise.js @@ -7,9 +7,15 @@ */ let n = 10; +let nums=[1,2,3,4,5,6,7,8,9,10] function sumTillNum(num){ + 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);