Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions Week1/homework/js-exercices/animalTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'
let numbersTable=[];
console.log("I create an empty table");
numbersTable=[1, 3, 5, 7, 9];
console.log("Numbers table:");
let x; let i=0;
for (x of numbersTable) {
console.log(numbersTable[i]); i++;
}
let animalsTable=["Lion", "Cat", "Dogg"];
console.log("\nAnimals table 1:");
i=0;
for (x of animalsTable) {
console.log(animalsTable[i]); i++;
}
animalsTable.push("Porcelet");
console.log("\nAnimals table 2:");
i=0;
for (x of animalsTable) {
console.log(animalsTable[i]); i++;
}
7 changes: 7 additions & 0 deletions Week1/homework/js-exercices/aroundNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
let z=7.25;
console.log("Declaration and initialisation the variable z: "+z);
let a=parseInt(z);
console.log("Declaration and initialisation the variable a: "+a);
let max=(z>a ? z : a);
console.log("The greatest value: "+max);
6 changes: 6 additions & 0 deletions Week1/homework/js-exercices/compareArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'
const array1 = [ "hello" , 123 , true , { name : "Noer" } ] , array2=["balde", "diallo", "sow", "barry"];
console . log ( "the length of the table 1 is: " +array1.length +", the length of the table 2 is: "+array1.length) ;
if(array1.length==array2.length){
console.log("They are the same!");
}else{ console.log("Two different sizes");}
2 changes: 2 additions & 0 deletions Week1/homework/js-exercices/debugError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict'
console.log("I'm awesome");
3 changes: 3 additions & 0 deletions Week1/homework/js-exercices/lenghOfString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'
let mySentence="La programmation est tellement intéressante!";
console.log("the lengh of my sentence is: "+mySentence.length);
11 changes: 11 additions & 0 deletions Week1/homework/js-exercices/logHello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'
console.log("Hello, world"); //English
console.log("Bonjour, tout le monde"); //French
console.log("Halo, dunia!"); // Indonesian
console.log("Ciao, mondo!"); // Italian
console.log("Hola, mundo!"); // Spanish
console.log("Hallo Welt"); //Deuch
console.log("Hej Verden"); //Danois
console.log("Γειά σου Κόσμε"); //Greek
console.log("Helo Byd"); //Gallois
console.log("Dia duit, domhan"); //Irlandais
8 changes: 8 additions & 0 deletions Week1/homework/js-exercices/logRemainder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'
let x=7, y= 21, z=13;
x = x % 3; y = y % 4; z = z % 2;
console.log("the remainde of x/3 is: "+x);
console.log("the remainde of y/4 is: "+y);
console.log("the remainde of z/2 is: "+z);


7 changes: 7 additions & 0 deletions Week1/homework/js-exercices/saveNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
let myNum;
console.log("Variable declaration");
console.log("variable initialisation");
myNum=19;
console.log("the variable type is :"+typeof(myNum));
console.log("the variable value is :"+myNum);
7 changes: 7 additions & 0 deletions Week1/homework/js-exercices/saveString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
let myString="Boubacar Balde";
console.log("The variable is a string and containt my name");
console.log("the variable value is :"+myString);
myString="My new string sentence";
console.log("The variable containt a new string");
console.log("the variable value is :"+myString);
26 changes: 26 additions & 0 deletions Week1/homework/js-exercices/verifyType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'
let vari1="First variable", vari2="Second variable", vari3=null, vari4=null;
console.log("the variable 1 type is: "+typeof(vari1)+" the variable 2 type is : "+typeof(vari2));
if(typeof(vari1)===typeof(vari2)){
console.log('SAME TYPE');
}else{console.log('NOT SAME TYPE');}
console.log("the variable 1 type is: "+typeof(vari1)+" the variable 3 type is : "+typeof(vari3));
if(typeof(vari1)===typeof(vari3)){
console.log('SAME TYPE');
}else{console.log('NOT SAME TYPE');}
console.log("the variable 1 type is: "+typeof(vari1)+" the variable 4 type is : "+typeof(vari4));
if(typeof(vari1)===typeof(vari4)){
console.log('SAME TYPE');
}else{console.log('NOT SAME TYPE');}
console.log("the variable 2 type is: "+typeof(vari2)+" the variable 3 type is : "+typeof(vari3));
if(typeof(vari2)===typeof(vari3)){
console.log('SAME TYPE');
}else{console.log('NOT SAME TYPE');}
console.log("the variable 2 type is: "+typeof(vari2)+" the variable 4 type is : "+typeof(vari4));
if(typeof(vari2)===typeof(vari4)){
console.log('SAME TYPE');
}else{console.log('NOT SAME TYPE');}
console.log("the variable 3 type is: "+typeof(vari3)+" the variable 4 type is : "+typeof(vari4));
if(typeof(vari3)===typeof(vari4)){
console.log('SAME TYPE');
}else{console.log('NOT SAME TYPE');}
25 changes: 25 additions & 0 deletions Week2/homework/js-execices/readingList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'
var mesLivres=[
{
title:"Les Crapauds-brousse",
author:"Tierno Monénembo",
alreadyRead:true,
},
{
title: "La Révolte des bovidés",
author: "Amadou Hampâté Bâ",
alreadyRead: true,
},
{
title: "Hosties noires",
author: "Léopold Sédar Senghor",
alreadyRead: false,
}

]
for (let livreX of mesLivres ) {
console.log(livreX.title+" of "+livreX.author)
if(livreX.alreadyRead){
console.log("You already read : "+livreX.title+"\n")
}else{ console.log("You still need to read : "+livreX.title+"\n")}
}
12 changes: 12 additions & 0 deletions Week2/homework/js-execices/recipeCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'
var maRecette={
name: "Omelete",
serves: 2,
ingredients: ["4 eggs", "2 strips of bacon", "tsp salt/pepper" ]
}
console.log("My meal name is: " +maRecette.name+" \nServes : "+maRecette.serves);
let ingr="Ingredients :\n"
for(var x of maRecette.ingredients ){
ingr+=x+"\n";
}
console.log(ingr);
6 changes: 6 additions & 0 deletions Week2/homework/js-execices/removeComma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'
let myString = "hello,this,is,a,difficult,to,read,sentence";
console.log("my string in the first time: "+myString);
console.log("the length of my String is: "+myString.length);
myString = myString.replace(/,/g, " ");
console.log("my string in the second time: "+myString);
6 changes: 6 additions & 0 deletions Week2/homework/js-execices/reportEvenOdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'
for(let x=1; x<=20; x++){
if((x % 2) ==0){
console.log("The number: "+x+" is odd!");
}else{console.log("The number: "+x+" is even!");}
}
17 changes: 17 additions & 0 deletions Week2/homework/js-execices/wantsDrink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'
let drinkTray = [];
const drinkTypes = [ "cola" , "limonade" , "eau" ];
let y=1 ;
drinkTypes.forEach(function(element){
let x=1;
do{
drinkTray.push(element); x++; y++;
}while((x<=2) && (y<5));
});
let drinkGay="Hey guys, I brought a "; y=1;
drinkTray.forEach(function(element){
if (y<drinkTray.length){
drinkGay+=element+", a "; y++;
}else{ drinkGay+=element}
});
console.log(drinkGay)
7 changes: 7 additions & 0 deletions Week3/homework/js-execices/dogYears.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
function calculateDogAge(age){
console.log("Your doggie is "+age/7+" years old in dog years!");
}
calculateDogAge(8);
calculateDogAge(9);
calculateDogAge(10);
9 changes: 9 additions & 0 deletions Week3/homework/js-execices/fortuneTeller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'
function tellFortune(nbChild, partName, locGeog, workName){
console.log("You will be a "+workName+" in "+locGeog+", and married to "+partName+" with "+nbChild+" kids.");
}
let childTab=[0, 1, 2, 3, 4];
let partenerTab=["Binta", "Idiatou", "Djenabou", "Kadiatou", "Mariama"];
let geogTab=["Daresalam 1", "Hamdalaye 1", "Hafia 2", "Cimenterie", "Kamsar"];
let jobTab=["Programmar", "Mecanician", "Nurse", "Commercant", "Economist"];
tellFortune(childTab[Math.floor(Math.random() * 5)], partenerTab[Math.floor(Math.random() * 5)], geogTab[Math.floor(Math.random() * 5)], jobTab[Math.floor(Math.random() * 5)]);
8 changes: 8 additions & 0 deletions Week3/homework/js-execices/giveComplim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'
function giveCompliment (name){
let comTab=["great", "beautiful", "awesome", "nice", "happy", "sociable", "amiable", "shy", "friendly", "elegant"];
console.log("You are "+comTab[Math.floor(Math.random() * 10)]+" "+name);
}
giveCompliment("Balde");
giveCompliment("Balde");
giveCompliment("Balde");
13 changes: 13 additions & 0 deletions Week3/homework/js-execices/shopMarket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
function addToShoppingCart(article){
if (epicerieTab.length>2){
epicerieTab.shift();
}
epicerieTab.push(article);
console.log("You bought "+epicerieTab);

}
let epicerieTab=["Bananas", "Milk"];
addToShoppingCart("Mangue");
addToShoppingCart("Orange");
addToShoppingCart("Fraise");
17 changes: 17 additions & 0 deletions Week3/homework/js-execices/totalCost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'
function calculateTotalPrice(price) {
let cal=0;
for(let obj in price){
cal+=price[obj];
}
console.log("the total price of all items is : "+cal+"euros")
}

let cartForParty={
oil: 6.88,
paper: 0.75,
vegetable:5.22,
Milk : 0.65,
Mayonnaise: 1.43
}
calculateTotalPrice(cartForParty);