+ 1

Hi can u please help me with this code

function main() { var totalPrice = parseInt(readLine(), 10) d1 = "50%" d2 = "30%" d3 = "10%" d4 = "0%" if (totalPrice => 5000) { console.log(d1) } else if (3000 <= totalPrice && totalPrice <4999 ) { console.log(d2) } else if (1000 <= totalPrice && totalPrice<= 2999) { console.log(d3) } else console.log(d4) }

22nd Feb 2021, 4:30 PM
Sruthi S
1 Answer
+ 8
Hi Sruthi S 👋 Here is correction of your code: In problem it is asked.. 5000 or above [so, for your if statement.. it will solve this way.. If(totalPrice >= 5000)] & For else-if statement... it should be <= 4999 Rest of your code is completely fine. function main() { var totalPrice = parseInt(readLine(), 10) d1 = "50%" d2 = "30%" d3 = "10%" d4 = "0%" if (totalPrice >= 5000) { console.log(d1) } else if (3000 <= totalPrice && totalPrice <= 4999 ) { console.log(d2) } else if (1000 <= totalPrice && totalPrice<= 2999) { console.log(d3) } else console.log(d4) }
22nd Feb 2021, 4:53 PM
Shivani 📚✍
Shivani 📚✍ - avatar