I need explanation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

20th Dec 2020, 10:12 AM
Никита Андреев
Никита Андреев - avatar
2 Answers
0
Is it possible to make such strings as 5<a>2 in js?
20th Dec 2020, 11:29 AM
Никита Андреев
Никита Андреев - avatar
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?
20th Dec 2020, 12:33 PM
Никита Андреев
Никита Андреев - avatar