diff --git a/ex01.html b/ex01.html new file mode 100644 index 0000000..402178a --- /dev/null +++ b/ex01.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex01.js b/ex01.js index d3d6486..bdab0c3 100644 --- a/ex01.js +++ b/ex01.js @@ -18,9 +18,8 @@ qui retourne ce paramètre "nb"; */ -function returnParameter(nb) { - return nb; -} +function returnParameter(nb) {return nb;} // écrire votre code sous ce commentaire +console.log(returnParameter(5)); \ No newline at end of file diff --git a/ex02.html b/ex02.html new file mode 100644 index 0000000..6ce21d8 --- /dev/null +++ b/ex02.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex02.js b/ex02.js index 6dc819d..067046a 100644 --- a/ex02.js +++ b/ex02.js @@ -20,3 +20,6 @@ retParam(5); // écrire votre code sous ce commentaire + +function retParam(n){return(n);} +console.log(retParam(5)); diff --git a/ex03.html b/ex03.html new file mode 100644 index 0000000..91b9a4d --- /dev/null +++ b/ex03.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex03.js b/ex03.js index 5e563b1..5107633 100644 --- a/ex03.js +++ b/ex03.js @@ -7,7 +7,7 @@ Nous appelons déjà la fonction; Vous n'avez plus qu'a coder la fonction; - Utilisez la fonction console.log + Utilisez la fonction conso le.log pour afficher la valeur de retour de la fonction; */ @@ -29,3 +29,6 @@ addition(98766, 345678); // écrire votre code sous ce commentaire +function addition(a,b) {return (a + b);} +console.log(addition(6,9)); +console.log(addition(98766,34678)); \ No newline at end of file diff --git a/ex04.html b/ex04.html new file mode 100644 index 0000000..24b884b --- /dev/null +++ b/ex04.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex04.js b/ex04.js index 476c243..7756432 100644 --- a/ex04.js +++ b/ex04.js @@ -24,3 +24,8 @@ isEven(6); isEven(5); // écrire votre code sous ce commentaire + +function isEven(n) { return (n % 2 == 0) ? "1" :"2";} + +console.log(isEven(6)); +console.log(isEven(5)); \ No newline at end of file diff --git a/ex05.html b/ex05.html new file mode 100644 index 0000000..727d2d8 --- /dev/null +++ b/ex05.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex05.js b/ex05.js index ffd8041..0946f5b 100644 --- a/ex05.js +++ b/ex05.js @@ -24,3 +24,8 @@ isEvenConcat(6); isEvenConcat(5); // écrire votre code sous ce commentaire + +function isEvenConcat(n){ return (n % 2 == 0)? "Le nombre " + n + " est pair et ":"le nombre " + n + " est impair.";} + +console.log(isEvenConcat(6)); +console.log(isEvenConcat(5)); \ No newline at end of file diff --git a/ex06.html b/ex06.html new file mode 100644 index 0000000..933dc9e --- /dev/null +++ b/ex06.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex06.js b/ex06.js index 032a640..a8320d3 100644 --- a/ex06.js +++ b/ex06.js @@ -51,3 +51,11 @@ getHumanTypeByAge(33); getHumanTypeByAge(140); // écrire votre code sous ce commentaire + +function getHumanTypeByAge (age) { return (age > 0 && age < 12)? "enfant": (age >= 12 && age < 18)? "ado":(age >= 18 && age < 124)? "adulte":"impossible";} + +console.log(getHumanTypeByAge(-5)); +console.log(getHumanTypeByAge(6)); +console.log(getHumanTypeByAge(17)); +console.log(getHumanTypeByAge(33)); +console.log(getHumanTypeByAge(140)); \ No newline at end of file diff --git a/ex07.html b/ex07.html new file mode 100644 index 0000000..f7531b1 --- /dev/null +++ b/ex07.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex07.js b/ex07.js index 4142339..46c2c74 100644 --- a/ex07.js +++ b/ex07.js @@ -22,3 +22,16 @@ boostedAddition([4, 5, 6]); boostedAddition([4, 4, 6, 8, 10, 12]); // écrire votre code sous ce commentaire + + +function boostedAddition (table) { + let sum = 0; + for(i = 0; i < table.length; i++) { + sum = sum+table[i]; + } + return sum; +} + +console.log(boostedAddition([4, 5, 6])); +console.log(boostedAddition([4, 4, 6, 8, 10, 12])); + \ No newline at end of file diff --git a/ex08.html b/ex08.html new file mode 100644 index 0000000..8b57a2b --- /dev/null +++ b/ex08.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex08.js b/ex08.js index 089e24b..6953c72 100644 --- a/ex08.js +++ b/ex08.js @@ -31,3 +31,24 @@ isAllEven([4, 4, 6, 8, 10, 12]); // écrire votre code sous ce commentaire +function isEven(n) { + if (n % 2 != 0) { + return 0; + } + else { + return 1; + } +} + +function isAllEven(table) { + for (let i = 0; i < table.length; i++) { + if (isEven(table[i]) != 1) { + return 0; + } + } + return 1; +} + +console.log(isAllEven([4, 5, 6])); +console.log(isAllEven([4, 6, 6, 8, 10, 12])); + diff --git a/ex09.html b/ex09.html new file mode 100644 index 0000000..7ea8bdf --- /dev/null +++ b/ex09.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ex09.js b/ex09.js index 4a4ce6b..7c82538 100644 --- a/ex09.js +++ b/ex09.js @@ -22,3 +22,55 @@ boostedEvenAddition([4, 5, 6]); boostedEvenAddition([1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12]); // écrire votre code sous ce commentaire + +function boostedAddition(array) { + let sum = 0; + for (i = 0; i < array.length; i++) { + sum = sum + array[i]; + } + return sum; +} + + + +function isEven(n) { + if (n % 2 != 0) { + return 0; + } + else { + return 1; + } +} + +function boostedEvenAddition(table) { + var array = []; + for (let i = 0; i < table.length; i++) { + if (isEven(table[i]) == 1) { + array.push(table[i]); + } + } +return boostedAddition(array); +} + + + + + +console.log(boostedEvenAddition([4, 5, 6])); +console.log(boostedEvenAddition([1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12])); + + +// Beaucoup plus simple, méthode Stéph: + +function simple(table) { +let sumpair= 0; +for (i=0; i + + + + + + + + + + + \ No newline at end of file diff --git a/ex10.js b/ex10.js index 161479c..237217c 100644 --- a/ex10.js +++ b/ex10.js @@ -45,3 +45,42 @@ shoppingList([ ]); // écrire votre code sous ce commentaire + +function shoppingList(table) { + var kiwi= 0; + var ananas= 0; + var prune= 0; + var banane= 0; + var pamplemousse= 0; + var orange= 0; + +for (let i = 0; i