Skip to content

Commit 1a754c9

Browse files
committed
wk3
1 parent afa9cc3 commit 1a754c9

File tree

6 files changed

+84
-1
lines changed

6 files changed

+84
-1
lines changed

Week2/homework/js-exercises/sanBox.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
function calculateDogAge(age) {
4+
let dogAge = age * 7;
5+
return `Your doggie is ${dogAge} years old in dog years!`
6+
7+
}
8+
console.log(calculateDogAge(1));
9+
console.log(calculateDogAge(0));
10+
console.log(calculateDogAge(1.5))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict'
2+
3+
function tellFortune() {
4+
let childrensNum = [0, 2, 5, 6, 9];
5+
let partnersNames = ["Isha", "mariam", "kumbis", "katrina", "sun shine"];
6+
let locations = ["Ottawa", "London", "New York", "California", "Barcelona"];
7+
let jobTitle = ["web programmer", "professional web developer", "football player"];
8+
9+
let babyNames = childrensNum[Math.floor(Math.random()*childrensNum.length)];
10+
let favPartners = partnersNames[Math.floor(Math.random()*partnersNames.length)];
11+
let bestLocations = locations[Math.floor(Math.random()*locations.length)];
12+
let dreamJob = jobTitle[Math.floor(Math.random()*jobTitle.length)];
13+
14+
return(`You will be a ${dreamJob}, in ${bestLocations}, and married to ${partnersNames}, with ${childrensNum} kids.`);
15+
};
16+
console.log(tellFortune);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict'
2+
3+
// function giveCompliment(mamAliJallow) {
4+
// let me = ["great", "awesome", "smart", "strong", "theProudOne","charming", "oneOfAKind", "brave", "courageous", "theFavouride"];
5+
// let myName = me[Math.floor(math.random()*me.length)];
6+
// };
7+
// for(let i = 0; i < 10; i++) {
8+
// console.log("YOU ARE"[me],[mamAliJallow]);
9+
// };
10+
11+
function giveCompliment(Jallow) {
12+
let array = ["great", "awesome", "smart", "strong", "the proud one","charming", "one of a kind", "brave", "courageous", "the favouride"];
13+
14+
let comps = array[Math.floor(Math.random()*array.length)];
15+
16+
return `You are ${comps}, ${Jallow}!`;
17+
//return("You are " + " "+array[Math.floor(Math.random() * array.length)]);
18+
19+
}
20+
console.log(giveCompliment("Jallow"));
21+
console.log(giveCompliment("jallow"));
22+
console.log(giveCompliment("jallow"));
23+
console.log(giveCompliment("jallow"));
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict'
2+
3+
function addToShoppingCart(item) {
4+
let shoppingList = ["bananas","milk"];
5+
shoppingList.push(item);
6+
if (shoppingList.length > 3) {
7+
shoppingList.shift();
8+
}
9+
return `You bought ${shoppingList}`;
10+
}
11+
12+
console.log(addToShoppingCart("potato"));
13+
console.log(addToShoppingCart("tomato"));
14+
console.log(addToShoppingCart("onioun"));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
function calculateTotalPrice(price) {
4+
let groc=0;
5+
for(let object in price) {
6+
7+
groc+=price[object];
8+
};
9+
10+
console.log("The total price items is "+groc+"euro.");
11+
}
12+
13+
let cartForParty={
14+
beers: 5.65,
15+
chips: 0.99,
16+
milk: 3.05,
17+
chocolate: 7.6,
18+
cola: 2.5,
19+
};
20+
21+
calculateTotalPrice(cartForParty);

0 commit comments

Comments
 (0)