Hay, how would i go about rounded a number up the nearest multiple of 3?
ie
25 would return 27
1 would return 3
0 would return 3
6 would return 6
>
$(document).ready(function() {
var modulus = 3;
for (i=0; i < 21; i++) {
$("#results").append("- " + roundUp(i, modulus) + "
")
}
});
function roundUp(number, modulus) {
var remainder = number % modulus;
if (remainder == 0) {
return number;
} else {
return number + modulus - remainder;
}
}
Round up to nearest multiple of 3: