Scgreemer Scgreemer - 3 months ago 19
Javascript Question

Every 10 mango remove 1 mango

I want to know if someone have the formula to count every 10. Because I already have the formula to remove 1 it's :

var mango = 20
var a = mango / 10
var result = mango - a


But if
mango = 6
il still calculating.

Answer

You need only the integer part of the calculation, because the rule says every 10 just one.

var mango = 25,
    a = Math.floor(mango / 10), // get only the integer part of calculation
    result = mango - a;

console.log(result);

Comments