+ 1
I need explanation
Hi! I wrote such an answer for the test: function main() { var totalPrice = parseInt(readLine(), 10) if (totalPrice <= 999){ console.log("0%") } else if (totalPrice <= 2999) { console.log("10%") } else if (totalPrice <= 4999) { console.log("30%") } else { console.log("50%") } } I passed the test, but I have a question. If i write 800 - it is smaller, than 999, but it is also smaller, than 2999 and 4900. Why my solution is right?
2 Respostas
0
Is it possible to make such strings as 5<a>2 in js?
0
And when i write 800 it is true for every string. I know, that my answer is right, but i see no logic. Why it returns true for correct segment, while the number is correct for every one of them?