I am trying to execute the following code
var n = 100;
var sum =0;
while(n>0)
{
sum = sum + n%10;
n = n/10;
}
console.log(sum);
The result should be 1 but javascript is returning
1.1111111111111112
Also, when I ran individual statements it is giving perfectly fine result, what could be the possible reason?