+ 1
How to get code to work
A store is offering a tiered discounts based on the purchase total. 5000 and above => 50% 3000-4999 => 30% 1000-2999 => 10% 1-999 => 0% Write a program that takes the total price as input and outputs the corresponding discount to the console.
5 Respostas
+ 2
Fix your conditions. You need to use correct comparison operators on both sides of && to achieve the "between" condition. Like this:
if (x >= 0 && x < 1000)
+ 1
Appreciate it Santa.
0
function main() {
var totalPrice = parseInt(readLine(), 10)
if (totalPrice >= 5000 ){
console.log("50%");
} else if (totalPrice !== 4999 && 3000){
console.log("30%");
} else if (totalPrice >= 1000 && 2999){
console.log("10%");
} if (totalPrice <= 999 && 1){
console.log("0%");
}}
0
Thats my code but i cant get all values to output correctly
0
Ive tried almost every combination to get the code to work. What am i doing wrong?