Skip to content

Commit f439001

Browse files
Done the homework week3
1 parent 2b27bce commit f439001

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
function calculateDogAge(age){
3+
console.log("Your doggie is "+age/7+" years old in dog years!");
4+
}
5+
calculateDogAge(8);
6+
calculateDogAge(9);
7+
calculateDogAge(10);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict'
2+
function tellFortune(nbChild, partName, locGeog, workName){
3+
console.log("You will be a "+workName+" in "+locGeog+", and married to "+partName+" with "+nbChild+" kids.");
4+
}
5+
let childTab=[0, 1, 2, 3, 4];
6+
let partenerTab=["Binta", "Idiatou", "Djenabou", "Kadiatou", "Mariama"];
7+
let geogTab=["Daresalam 1", "Hamdalaye 1", "Hafia 2", "Cimenterie", "Kamsar"];
8+
let jobTab=["Programmar", "Mecanician", "Nurse", "Commercant", "Economist"];
9+
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)]);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict'
2+
function giveCompliment (name){
3+
let comTab=["great", "beautiful", "awesome", "nice", "happy", "sociable", "amiable", "shy", "friendly", "elegant"];
4+
console.log("You are "+comTab[Math.floor(Math.random() * 10)]+" "+name);
5+
}
6+
giveCompliment("Balde");
7+
giveCompliment("Balde");
8+
giveCompliment("Balde");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
function addToShoppingCart(article){
3+
if (epicerieTab.length>2){
4+
epicerieTab.shift();
5+
}
6+
epicerieTab.push(article);
7+
console.log("You bought "+epicerieTab);
8+
9+
}
10+
let epicerieTab=["Bananas", "Milk"];
11+
addToShoppingCart("Mangue");
12+
addToShoppingCart("Orange");
13+
addToShoppingCart("Fraise");
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
function calculateTotalPrice(price) {
3+
let cal=0;
4+
for(let obj in price){
5+
cal+=price[obj];
6+
}
7+
console.log("the total price of all items is : "+cal+"euros")
8+
}
9+
10+
let cartForParty={
11+
oil: 6.88,
12+
paper: 0.75,
13+
vegetable:5.22,
14+
Milk : 0.65,
15+
Mayonnaise: 1.43
16+
}
17+
calculateTotalPrice(cartForParty);

0 commit comments

Comments
 (0)