Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Je pense avoir terminé les 10 exercices #5

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
529ad75
la console renvoie 5
bastienduran Mar 10, 2017
738b5d9
la console renvoie bien5
bastienduran Mar 10, 2017
08a00a1
la console renvoie bien 15 et 444444
bastienduran Mar 10, 2017
3bd3bd7
renvoie 1 pour un chiffre pair
bastienduran Mar 10, 2017
1bbfc37
retourne le bon resultat des deux tests
bastienduran Mar 10, 2017
2122d20
j'ai oublié de créer un branche
bastienduran Mar 10, 2017
101c25a
les deux tests sont passés
bastienduran Mar 10, 2017
2d14d60
tous les tests passent
bastienduran Mar 10, 2017
102c099
test one returns 15, test two returns 44
bastienduran Mar 12, 2017
d62b654
first test returns 1 second test returns 0
bastienduran Mar 12, 2017
0f2a89c
erge branch 'dev08'
bastienduran Mar 12, 2017
36cf977
je n'arrive pas à stocker les différents résultats de isEven dans un …
bastienduran Mar 12, 2017
f4237f9
je n'arrive pas à stocker les différents résultats de isEven dans un …
bastienduran Mar 12, 2017
e65eea8
il manquait let dans ma boucle for
bastienduran Mar 12, 2017
b634865
cette fois ci, l'exercie est resolu
bastienduran Mar 12, 2017
e49d243
ok
bastienduran Mar 12, 2017
9a4e6ef
ignore html test file
bastienduran Mar 12, 2017
292e1b5
erge branch 'dev08'
bastienduran Mar 12, 2017
0bc2552
test 1 returns 10, test 2 returns 44
bastienduran Mar 12, 2017
121f8e1
Merge branch 'dev09'
bastienduran Mar 12, 2017
7899997
reste a parcourir un tableau de tableau
bastienduran Mar 12, 2017
59e27ea
le resultat semble bon mais je ne comprend pas pourquoi la derniere l…
bastienduran Mar 12, 2017
008e602
le rsultat correspond ce qui est attendu
bastienduran Mar 12, 2017
0102c61
j'arrive au resultat avec un seule boucle
bastienduran Mar 13, 2017
3b1e6c0
j'arrive à extraire les nom de fruits
bastienduran Mar 13, 2017
edf4d79
on y est presque
bastienduran Mar 14, 2017
3a7db05
je ne comprend pas comment est défini emptyList
bastienduran Mar 14, 2017
de933e1
le resultat est le bon
bastienduran Mar 14, 2017
5c3a2f0
le resultat est le bon
bastienduran Mar 14, 2017
b025b35
la solution tient en 9 lignes
bastienduran Mar 15, 2017
54ffa1d
on peut faire plus court sans utiliser la fonction isEven
bastienduran Mar 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
index.html
ex11.js
9 changes: 5 additions & 4 deletions ex01.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Appeler la fonction "returnParameter",
Envoyer le nombre 5 en paramètre;

Tips:
// Appeler la fonction "returnParameter",
// Envoyer le nombre 5 en paramètre;

/* Tips:
Nous avons déclaré la fonction;
Vous avez juste à l'appeler;
Ne cherchez pas trop loin;
Expand All @@ -24,3 +24,4 @@ function returnParameter(nb) {

// écrire votre code sous ce commentaire

console.log(returnParameter(5));
4 changes: 4 additions & 0 deletions ex02.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
retParam(5);

// écrire votre code sous ce commentaire
function retParam(nb){
return nb;
}
console.log(retParam(5));
5 changes: 5 additions & 0 deletions ex03.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ addition(98766, 345678);

// écrire votre code sous ce commentaire

function addition(nb1,nb2){
return (nb1+nb2);
}
console.log(addition(6, 9));
console.log(addition(98766, 345678));
11 changes: 11 additions & 0 deletions ex04.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ isEven(6);
isEven(5);

// écrire votre code sous ce commentaire

function isEven(nb){
// var mobulo = %nb;
if( nb % 2 === 0){
return 1;
} else{
return 0;
}
}
console.log(isEven(6));
console.log(isEven(5));
9 changes: 9 additions & 0 deletions ex05.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ isEvenConcat(6);
isEvenConcat(5);

// écrire votre code sous ce commentaire
function isEvenConcat(nb){
if ( nb % 2 === 0){
return (nb + ' est pair')
}else {
return (nb + ' est impair')
}
}
console.log(isEvenConcat(6));
console.log(isEvenConcat(5));
21 changes: 21 additions & 0 deletions ex06.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ getHumanTypeByAge(33);
getHumanTypeByAge(140);

// écrire votre code sous ce commentaire

function getHumanTypeByAge(nb){
if(nb > 0 && nb < 12){
return("enfant");
}
else if(nb >= 12 && nb < 18){
return("ado");
}
else if (nb >= 18 && nb < 124){
return("adulte");
}
else {
return ("impossible... ou encore jamais vu");
}
}

console.log(getHumanTypeByAge(-5));
console.log(getHumanTypeByAge(6));
console.log(getHumanTypeByAge(17));
console.log(getHumanTypeByAge(33));
console.log(getHumanTypeByAge(140));
10 changes: 10 additions & 0 deletions ex07.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ boostedAddition([4, 5, 6]);
boostedAddition([4, 4, 6, 8, 10, 12]);

// écrire votre code sous ce commentaire
function boostedAddition(table){
var addition = 0;
for (let i=0;i<table.length;i++){
addition = addition + table[i];
}
return addition;
}

console.log(boostedAddition([4, 5, 6]));
console.log(boostedAddition([4, 4, 6, 8, 10, 12]));
24 changes: 22 additions & 2 deletions ex08.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,35 @@
et nous attendons comme résultat 0;
*/

isAllEven([4, 5, 6]);
// isAllEven([4, 5, 6]);

/* Test 1
Appel à la fonction "isAllEven",
prenant en paramètre le tableau [4, 4, 6, 8, 10, 12],
et nous attendons comme résultat 1;
*/

isAllEven([4, 4, 6, 8, 10, 12]);
// isAllEven([4, 4, 6, 8, 10, 12]);

// écrire votre code sous ce commentaire

function isEven(nb){
if( nb % 2 === 0){
return 1;
} else{
return 0;
}
}

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, 4, 6, 8, 10, 12]));
17 changes: 15 additions & 2 deletions ex09.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@
et nous attendons comme résultat 10;
*/

boostedEvenAddition([4, 5, 6]);
// boostedEvenAddition([4, 5, 6]);

/* Test 2
Appel à la fonction "boostedEvenAddition",
prenant en paramètre le tableau [1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12],
et nous attendons comme résultat 44;
*/

boostedEvenAddition([1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12]);
// boostedEvenAddition([1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12]);

// écrire votre code sous ce commentaire

function boostedEvenAddition(table){
var addition = 0;
for (let i = 0; i<table.length;i++){
if(table[i]%2===0){
addition = addition + table[i];
}
}return addition;
}


console.log(boostedEvenAddition([4,5,6]));
console.log(boostedEvenAddition([1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12]));
24 changes: 21 additions & 3 deletions ex10.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,30 @@

*/

shoppingList([
console.log(shoppingList([
["orange", "orange", "kiwi", "ananas"],
["kiwi", "ananas", "banane", "prune"],
["orange", "orange", "orange", "orange"],
["orange", "orange", "kiwi", "kiwi"],
["prune", "banane", "pamplemousse", "ananas"]
]);
["prune", "banane", "pamplemousse", "ananas"], ["poireau", "pain", "chouquette",]
]));

// écrire votre code sous ce commentaire


function shoppingList(table) {

var List = new Object;

for (let basketIndex of table) {
for (let i = 0; i < basketIndex.length; i++) {
if (List[basketIndex[i]]) {
List[basketIndex[i]] += 1;
}
else{
List[basketIndex[i]]=1;
}
}
}
return (List);
}
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src = "ex08.js"><script>
</body>
</html>
Empty file added node
Empty file.