-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproblem42.js
39 lines (26 loc) · 1.04 KB
/
problem42.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* ## Find the lowest price product */
function findTheLowest(product1, product2, product3, product4){
const lowestPrice = Math.min(product1, product2, product3, product4);
if(product1 === lowestPrice){
const outputMassage1 = "The lowest price product is Phone. " + "And it's price is " + product1;
return outputMassage1;
}
else if(product2 === lowestPrice){
const outputMassage2 = "The lowest price product is Computer. " + "And it's price is " + product2;
return outputMassage2;
}
else if(product3 === lowestPrice){
const outputMassage3 = "The lowest price product is Tv. " + "And it's price is " + product3;
return outputMassage3;
}
else{
const outputMassage4 = "The lowest price product is Fridge. " + "And it's price is " + product4;
return outputMassage4;
}
};
const phone = 120000;
const computer = 65000;
const tv = 20000;
const fridge = 27000;
const lowestPriceProduct = findTheLowest(phone, computer, tv, fridge);
console.log(lowestPriceProduct);