Skip to content

Commit 6cac27a

Browse files
problem 42 completed
1 parent 40446fa commit 6cac27a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

problem42/problem.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Find the lowest price product

problem42/problem42.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* ## Find the lowest price product */
2+
3+
4+
5+
function findTheLowest(product1, product2, product3, product4){
6+
const lowestPrice = Math.min(product1, product2, product3, product4);
7+
8+
if(product1 === lowestPrice){
9+
const outputMassage1 = "The lowest price product is Phone. " + "And it's price is " + product1;
10+
return outputMassage1;
11+
}
12+
13+
else if(product2 === lowestPrice){
14+
const outputMassage2 = "The lowest price product is Computer. " + "And it's price is " + product2;
15+
return outputMassage2;
16+
}
17+
18+
else if(product3 === lowestPrice){
19+
const outputMassage3 = "The lowest price product is Tv. " + "And it's price is " + product3;
20+
return outputMassage3;
21+
}
22+
23+
else{
24+
const outputMassage4 = "The lowest price product is Fridge. " + "And it's price is " + product4;
25+
return outputMassage4;
26+
}
27+
28+
29+
};
30+
31+
32+
33+
const phone = 120000;
34+
const computer = 65000;
35+
const tv = 20000;
36+
const fridge = 27000;
37+
38+
const lowestPriceProduct = findTheLowest(phone, computer, tv, fridge);
39+
console.log(lowestPriceProduct);

0 commit comments

Comments
 (0)