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

Mes exercises js #6

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
54 changes: 54 additions & 0 deletions codetest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE HTML>

<html>

<body>

<header>
</header>

<script>

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

//test1
console.log(getHumanTypeByAge(-5));

//test2
console.log(getHumanTypeByAge(6));

//test3
console.log(getHumanTypeByAge(17));

//test4
console.log(getHumanTypeByAge(33));

//test5
console.log(getHumanTypeByAge(140));

//test6
console.log(getHumanTypeByAge(120));

</script>

<footer>
</footer>



</body>

</html>
28 changes: 28 additions & 0 deletions ex01.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE HTML>

<html>

<body>

<header>
</header>

<script>

function returnParameter(nb) {
return nb;
}

console.log(5);


</script>

<footer>
</footer>



</body>

</html>
5 changes: 4 additions & 1 deletion ex01.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ function returnParameter(nb) {
return nb;
}

<<<<<<< HEAD
console.log(returnParameter);
=======
// écrire votre code sous ce commentaire

>>>>>>> development
26 changes: 26 additions & 0 deletions ex02.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE HTML>

<html>

<body>

<header>
</header>

<script>
function retParam(nb) {
return (nb);
}

console.log(retParam(4000));

</script>

<footer>
</footer>



</body>

</html>
6 changes: 5 additions & 1 deletion ex02.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
prenant en paramètre le nombre 5;
*/

retParam(5);
function retParam(nb) {
return (nb);
}

console.log(retParam(5));

// écrire votre code sous ce commentaire
35 changes: 35 additions & 0 deletions ex03.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE HTML>

<html>

<body>

<header>
</header>

<script>

//test1
function addition(nb1,nb2){
return(nb1 + nb2)
}
console.log(addition(6, 9));

//test2
function addition(nb1,nb2){
return(nb1 + nb2)
}
console.log(addition(98766, 345678));



</script>

<footer>
</footer>



</body>

</html>
11 changes: 11 additions & 0 deletions ex03.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ addition(98766, 345678);

// écrire votre code sous ce commentaire

//test1
function addition(nb1,nb2){
return(nb1 + nb2)
}
console.log(addition(6, 9));

//test2
function addition(nb1,nb2){
return(nb1 + nb2)
}
console.log(addition(98766, 345678));
47 changes: 47 additions & 0 deletions ex04.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE HTML>

<html>

<body>

<header>
</header>

<script>


//test1
function isEven(nb) {
let filter = nb % 2;
if (filter == 0) {
return 1;
}
else {
return 0;
}
}
console.log(isEven(6));

//test2
function isEven(nb) {
let filter = nb % 2;
if (filter == 0) {
return 1;
}
else {
return 0;
}
}
console.log(isEven(5));
console.log(isEven(13.6));

</script>

<footer>
</footer>



</body>

</html>
18 changes: 18 additions & 0 deletions ex04.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,21 @@ isEven(6);
isEven(5);

// écrire votre code sous ce commentaire

//test1
function isEven(nb) {
let filter = nb % 2;
if filter == 0 {
return 1;
}
else {
return 0;
}
}
console.log(isEven(6));

//test2
console.log(isEven(5));

//test3
console.log(isEven(13.6));
16 changes: 16 additions & 0 deletions ex05.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ isEvenConcat(6);
isEvenConcat(5);

// écrire votre code sous ce commentaire

function isEvenConcat(nb){
let filter = nb % 2;
if (filter == 0) {
return(nb + " est pair");
}
else {
return(nb + " est impair");
}
}

//test1
console.log(isEvenConcat(6));

//test2
console.log(isEvenConcat(5));
33 changes: 33 additions & 0 deletions ex06.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,36 @@ getHumanTypeByAge(33);
getHumanTypeByAge(140);

// écrire votre code sous ce commentaire

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

//test1
console.log(getHumanTypeByAge(-5));

//test2
console.log(getHumanTypeByAge(6));

//test3
console.log(getHumanTypeByAge(17));

//test4
console.log(getHumanTypeByAge(33));

//test5
console.log(getHumanTypeByAge(140));

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

// écrire votre code sous ce commentaire

function boostedAddition(array) {
let sum = 0
for (var i in array) {
sum += array[i];
}
return(sum);
}

//test1
console.log(boostedAddition([4, 5, 6]));

//test2
console.log(boostedAddition([4, 4, 6, 8, 10, 12]));
33 changes: 33 additions & 0 deletions ex08.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,37 @@ isAllEven([4, 5, 6]);
isAllEven([4, 4, 6, 8, 10, 12]);

// écrire votre code sous ce commentaire
function isEven(nb) {
let filter = nb % 2;
if (filter == 0) {
return 0;
}
else {
return 1;
}
}

function isAllEven(array) {
let even = 0;
for (let i in array) {
even += isEven(array[i]);
}
if (even == 0) {
return(1);
}
else {
return(0);
}
}

//test1
console.log(isAllEven([4, 5, 6]));

//test2
console.log(isAllEven([4, 4, 6, 8, 10, 12]));

//test3
console.log(isAllEven([4, 4, 5, 8, 10, 10]));

//test4
console.log(isAllEven([4, 4, 2, 8, 10, 4, 18]));
27 changes: 27 additions & 0 deletions ex09.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,30 @@ boostedEvenAddition([4, 5, 6]);
boostedEvenAddition([1, 3, 4, 5, 4, 6, 9, 8, 11, 10, 11, 12]);

// écrire votre code sous ce commentaire

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

function boostedEvenAddition(array) {
let even = 0;
for (let i in array) {
even += isEven(array[i]);
}
return(even)
}

//test1
console.log(boostedEvenAddition([4, 5, 6]));

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

//test3
console.log(boostedEvenAddition([1, 3, 7, 5, 55, 1, 19, 33, 11, 15, 11, 12]));
Loading