How can I round to whole numbers in JavaScript?
//method 1Math.ceil(); // rounds upMath.floor(); // rounds downMath.round(); // does method 2 in 1 call//method 2var number = 1.5; //floatvar a = parseInt(number); // to intnumber -= a; // get numbers on right of decimalif(number < 0.5) // if less than round down round_down();else // round up if more than round_up();
either one or a combination will solve your question