I’m not 100% sure how to ask this question so please dont mark me down for that.. I will do my best.
how do I work out what range my number falls in?
eg:
var range = 100;
var myNum = 320;
Therfore my result would be 300 as that is the range 320 falls into.
further exampes would be:
var range = 100;
var myNum = 190;
result: 100
var range = 100;
var myNum = 864;
result: 800
and lastly:
var range = 50;
var myNum = 864;
result: 850
Hope this make sence.
This is the logic you’re looking for:
Replace
Math.floorbyMath.ceilif you want to find the upper bound of the “range”.The code above is an implementation of:
rangesuit inrange?range