Get the resulting number with js

So basically my problem is that am trying to figure out how to calculate and return a number with JS according to the following logic.

Ex: i have a number of 120 i want to check well is the number greater than 100 ( yes ) okay is the number less than 200 ( yes ) then return ( 1 * 300 )

Ex : another number as 230 is the number greater than 200 ( yes ) okay is the number less than 300 ( yes ) then return ( 2 * 300 )

and sooo on.

i made it through switch case but it think it is too odd to do this and it is possible to deal with large numbers like 10000 , 20000 so i will need endless switch cases or if conditions

i hope you got my point

>Solution :

As per the comment above, not considering edge cases (negative numbers for example), you might go with:

Math.floor(n / 100) * 300

Leave a Reply