Scgreemer - 2 months ago 5x

Javascript Question

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`

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);
```

Source (Stackoverflow)

Comments