diff --git a/Week1/homework/js-exercices/about_me.html b/Week1/homework/js-exercices/about_me.html new file mode 100644 index 000000000..b6ea4f732 --- /dev/null +++ b/Week1/homework/js-exercices/about_me.html @@ -0,0 +1,24 @@ + + + + + Codestin Search App + + + + + +

About Me

+ + + + + \ No newline at end of file diff --git a/Week1/homework/js-exercices/about_me.js b/Week1/homework/js-exercices/about_me.js new file mode 100644 index 000000000..1ac8f50b2 --- /dev/null +++ b/Week1/homework/js-exercices/about_me.js @@ -0,0 +1,25 @@ +var myBody = document.body; +myBody.style.fontFamily="Arial, sans-serif"; + +var mySpan1 = document.getElementById("nickname"); +var mySpan2 = document.getElementById("fav-food"); +var mySpan3 = document.getElementById("hometown"); +mySpan1.innerHTML="Bouba"; +mySpan2.innerHTML="Rice"; +mySpan3.innerHTML="Conakry"; + +var myLi= document.getElementsByTagName("li"); +for(let i=0; i + + + + + + Codestin Search App + + + + + + + + \ No newline at end of file diff --git a/Week1/homework/js-exercices/bookList.js b/Week1/homework/js-exercices/bookList.js new file mode 100644 index 000000000..203e76716 --- /dev/null +++ b/Week1/homework/js-exercices/bookList.js @@ -0,0 +1,44 @@ +var mesLivres=[ + { + title:"Les Crapauds-brousse", + author:"Tierno Monénembo", + alreadyRead:true, + imgSrc:"https://media.senscritique.com/media/000006441212/source_big/Les_crapauds_brousse.jpg", + }, + { + title: "La Révolte des bovidés", + author: "Amadou Hampâté Bâ", + alreadyRead: false, + imgSrc:"https://images-eu.ssl-images-amazon.com/images/I/61d84huBGyL.jpg", + }, + { + title: "Hosties noires", + author: "Léopold Sédar Senghor", + alreadyRead: true, + imgSrc:"https://images-na.ssl-images-amazon.com/images/I/41ZQjlvZ2QL._AC_SY400_.jpg", + } + +] +var para = document.createElement("p"); +var ulList = document.createElement("ul"); +for (let livreX of mesLivres ) { + var div=document.createElement("div"); + var liList = document.createElement("li"); + var myImg = document.createElement("img"); + if(livreX.alreadyRead){ + div.style.background="red"; + }else{div.style.background="green";} + myImg.src=livreX.imgSrc; + myImg.style.height="100px"; + myImg.style.width="100px"; + var nodeli = document.createTextNode(livreX.title+' of '+livreX.author); + liList.appendChild(nodeli); + ulList.appendChild(div); + div.appendChild(liList); + div.appendChild(myImg); + console.log(mesLivres.length) ; +} +var myBody = document.querySelector("body"); +myBody.appendChild(para); +para.appendChild(ulList); + diff --git a/Week1/homework/js-exercices/bouba.jpg b/Week1/homework/js-exercices/bouba.jpg new file mode 100644 index 000000000..d2e213a45 Binary files /dev/null and b/Week1/homework/js-exercices/bouba.jpg differ diff --git a/Week1/homework/js-exercices/catWalk.html b/Week1/homework/js-exercices/catWalk.html new file mode 100644 index 000000000..20509a5ca --- /dev/null +++ b/Week1/homework/js-exercices/catWalk.html @@ -0,0 +1,57 @@ + + + + + Codestin Search App + + + + + + + + + + + +; \ No newline at end of file diff --git a/Week1/homework/js-exercices/hijackGoogleLogo.js b/Week1/homework/js-exercices/hijackGoogleLogo.js new file mode 100644 index 000000000..fb5208982 --- /dev/null +++ b/Week1/homework/js-exercices/hijackGoogleLogo.js @@ -0,0 +1,4 @@ +(function hijackGoogleLogo(){ + var myLogo=document.querySelector("[alt=Google]"); + myLogo.srcset="https://www.hackyourfuture.dk/static/logo-dark.svg"; +})(); diff --git a/Week1/homework/js-exercices/showCurrentTime.js b/Week1/homework/js-exercices/showCurrentTime.js new file mode 100644 index 000000000..b6fb0804c --- /dev/null +++ b/Week1/homework/js-exercices/showCurrentTime.js @@ -0,0 +1,9 @@ +var myTime = setInterval(myFuncTimer, 1000); + + function myFuncTimer() { + var d = new Date(); + var t = d.toLocaleTimeString(); + document.getElementById("time").innerHTML = t; + } + + \ No newline at end of file diff --git a/Week1/homework/js-exercices/time.html b/Week1/homework/js-exercices/time.html new file mode 100644 index 000000000..41ddd2bb1 --- /dev/null +++ b/Week1/homework/js-exercices/time.html @@ -0,0 +1,24 @@ + + + + +

+ + + + + + + + + + \ No newline at end of file diff --git a/Week2/homework/js-exercices/collectiveAge.js b/Week2/homework/js-exercices/collectiveAge.js new file mode 100644 index 000000000..815cdfcb5 --- /dev/null +++ b/Week2/homework/js-exercices/collectiveAge.js @@ -0,0 +1,20 @@ +const hackYourFutureMembers = [ + { name : 'Wouter' , age : 33 } , + { name : 'Federico' , age : 32 } , + { name : 'Noer' , age : 27 } , + { name : 'Tjebbe' , age : 22 } , + ] ; + +const ages=hackYourFutureMembers.map(keepAge); +function keepAge(myArrayAges){ + return myArrayAges.age; +} +console.log("the age by student is :"+ages); + +const collectiveAge=hackYourFutureMembers.reduce((accu, ages) => accu+ages.age, 0); + +function mainFunc(callFunc){ + console.log("L'âge collectif de l'équipe HYF est : "+callFunc); + return callFunc; +} +mainFunc(collectiveAge); diff --git a/Week2/homework/js-exercices/favoritHobbies.html b/Week2/homework/js-exercices/favoritHobbies.html new file mode 100644 index 000000000..7de9915a2 --- /dev/null +++ b/Week2/homework/js-exercices/favoritHobbies.html @@ -0,0 +1,19 @@ + + + + + + + Codestin Search App + + + + + + + + + + \ No newline at end of file diff --git a/Week2/homework/js-exercices/favoritHobbies.js b/Week2/homework/js-exercices/favoritHobbies.js new file mode 100644 index 000000000..af559186c --- /dev/null +++ b/Week2/homework/js-exercices/favoritHobbies.js @@ -0,0 +1,22 @@ +const myHobbies = [ + 'Méditation' , + 'Lecture' , + 'Programmation' , + 'Sortir avec des amis' , + 'Aller au gymnase' , + ] ; + +var ulList = document.createElement("ul"); + +var eachELement=myHobbies.forEach(putList); + +function putList(hobbie){ + var liList = document.createElement("li"); + var nodeli = document.createTextNode(hobbie); + liList.appendChild(nodeli); + ulList.appendChild(liList); +} +var myBody = document.querySelector("body"); +myBody.appendChild(ulList); + + \ No newline at end of file diff --git a/Week2/homework/js-exercices/lemonAllergy.js b/Week2/homework/js-exercices/lemonAllergy.js new file mode 100644 index 000000000..f1ec28961 --- /dev/null +++ b/Week2/homework/js-exercices/lemonAllergy.js @@ -0,0 +1,4 @@ +const fruitBasket = ['Apple', 'Lemon', 'Grapefruit', 'Lemon', 'Banana', 'Watermelon', 'Lemon']; + +const fruitWithoutLemon=fruitBasket.filter(fruit=> fruit!='Lemon'); +console.log("My mom bought me a fruit basket, containing : " +fruitWithoutLemon+"!"); \ No newline at end of file diff --git a/Week2/homework/js-exercices/mondayWorth.js b/Week2/homework/js-exercices/mondayWorth.js new file mode 100644 index 000000000..8029b9169 --- /dev/null +++ b/Week2/homework/js-exercices/mondayWorth.js @@ -0,0 +1,55 @@ +const mondayTasks = [ + { + name: 'Daily standup', + duration: 30, // specified in minutes + }, + { + name: 'Feature discussion', + duration: 120, + }, + { + name: 'Development time', + duration: 240, + }, + { + name: 'Talk to different members from the product team', + duration: 60, + }, + ]; + +function addMinute(totMin, minut){ + return totMin+=minut.duration; +} + +var totalMinutes1=mondayTasks.reduce(addMinute, 0); + +function time_convert(totalMinutes) + { + const hours = Math.floor(totalMinutes / 60); + const minutes = totalMinutes % 60; + return `${hours}H:${minutes}M`; +} + +var totalMinutes2=time_convert(totalMinutes1); +console.log("My hourly rate on Monday is : " +totalMinutes2); + +function timeEachTask(duree){ + return duree.duration; +} + +var timeTask=mondayTasks.map(timeEachTask); +console.log("\nThe duration for each task is : " +timeTask); + +function multiplyDuration(duree){ + let rate=11; + return ((duree*rate)/60); +} +var multEachDuration=timeTask.map(multiplyDuration); +console.log("\nThe bill per duration for each task is : " +multEachDuration); + +function totalBill(total, rateBytask){ + return total+rateBytask; +} +var totBill=multEachDuration.reduce(totalBill, 0); +totBill=totBill.toFixed(2); +console.log("\nThe total of he bill per duration for each task is : €" +totBill); \ No newline at end of file diff --git a/Week2/homework/js-exercices/oddOnesOut.js b/Week2/homework/js-exercices/oddOnesOut.js new file mode 100644 index 000000000..3d3ff03a6 --- /dev/null +++ b/Week2/homework/js-exercices/oddOnesOut.js @@ -0,0 +1,21 @@ +function doubleEvenNumbersMap(numbers){ + return numbers.map(function(element){ + if(element%2===0){ + return element*2 + } + }) +} + +const myNumbers = [1, 2, 3, 4]; +console.log(doubleEvenNumbersMap(myNumbers)); + +function doubleEvenNumbersFilter(numbers){ + return numbers.filter(function(element){ + if(element%2===0){ + return element*2 + } + }); + +} + +console.log(doubleEvenNumbersFilter(myNumbers)); \ No newline at end of file diff --git a/Week3/homework/js-exercices/addSix.js b/Week3/homework/js-exercices/addSix.js new file mode 100644 index 000000000..cb389cf8c --- /dev/null +++ b/Week3/homework/js-exercices/addSix.js @@ -0,0 +1,14 @@ +'use strict'; +function createBase(numb) { + var compt=9; + return function () {compt += numb; numb=numb+3; return compt; } +} + +const addSix = createBase(6); + +// Put here your function calls... + +console.log(addSix()); +console.log(addSix()); +console.log(addSix()); + diff --git a/Week3/homework/js-exercices/guessMore.js b/Week3/homework/js-exercices/guessMore.js new file mode 100644 index 000000000..be6bc0858 --- /dev/null +++ b/Week3/homework/js-exercices/guessMore.js @@ -0,0 +1,24 @@ +// Snippet +var x = 9; +function f1(val) { + val = val + 1; + return val; +} +f1(x); +console.log(x); + +const y = { x: 9 }; +function f2(val) { + val.x = val.x + 1; + return val; +} +f2(y); +console.log(y); + +/* +1-"x" is a primitif value, it will not change when we use it in argument of the function. when "f1" receive the argument, + make a new memory in the computer keep there the value of argument and modifi that value in the new memory. + the new memory will be free when "f1" finish to execute. the console.log(x) will display 9. + 2-"y" is not a primitif value, it will change when we use it in argument of the function. when "f2" receive the argument, + the parameter point at the same memory than the argument and modifi that value in the memory. + the value of the memory of argument will be change when "f2" finish to execute. the console.log(x) will display x:10. diff --git a/Week3/homework/js-exercices/guessOutPut.js b/Week3/homework/js-exercices/guessOutPut.js new file mode 100644 index 000000000..82ab82584 --- /dev/null +++ b/Week3/homework/js-exercices/guessOutPut.js @@ -0,0 +1,12 @@ +'use strict'; +// Snippet +let a = 10; +const x = (function() { + a = 12; + return function() { + alert(a); + }; +})(); + +x(); +/* This function will be semi execute automaticaly. that why we use parenrhese at 3 times. we declare and initialize two times "a" variable, the first is globale for all functions and second is local for the first function but it's global for the second function who is inside also the first function. In the second function we alert "a" variable, the function go up and check the first "a" variable that going to find and it will alert "12", value of the locale variable.*/ \ No newline at end of file diff --git a/Week3/homework/js-exercices/lotteryMachine.js b/Week3/homework/js-exercices/lotteryMachine.js new file mode 100644 index 000000000..7b1afa480 --- /dev/null +++ b/Week3/homework/js-exercices/lotteryMachine.js @@ -0,0 +1,28 @@ + +function lotteryThreeFive (valStart, valFinale, divBy3, divBy5){ + let myArray=[valStart]; + for(let i=1; i<=valFinale-valStart; i++){ + myArray.push(valStart+i); + } + console.log(myArray); + for(let elements of myArray){ + if((elements%3)===0){ + divBy3(elements); + console.log("------------------"); + } + if((elements%5)===0){ + divBy5(elements); + console.log("------------------"); + } + } +// return myArray; +} +function divByTree(element){ + console.log(element+" is divible by 3") +} +function divByFive(element){ + console.log(element+" is divible by 5") +} +lotteryThreeFive(0,15,divByTree, divByFive); + +; diff --git a/Week3/homework/js-exercices/takeOutDuplicate.js b/Week3/homework/js-exercices/takeOutDuplicate.js new file mode 100644 index 000000000..f708a131a --- /dev/null +++ b/Week3/homework/js-exercices/takeOutDuplicate.js @@ -0,0 +1,17 @@ +'use strict'; + +const letter = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c', 'b']; +function removeDuplicates(array){ + + for( let element of array){ + let run=(array.indexOf(element)+1); + for(run; run