I am new to coding/JavaScript and I'm trying to understand why one of my loops refuses to run as I intended.
Basically, I am setting a loop that only outputs a certain part (fraction) of 100. As you can see in the snapshot, everything works fine when I am outputting quarters. However, when I attempt to output tenths, the loop stops after two-tenths, when it should output ten-tenths.
Both loops are exactly the same, syntax wise. Would anyone mind explaining why one runs, while the other doesn't? Thanks in advance!
var quarter = .25;
for (x = 1; x <=100; x++)
{
if (x / 100 === quarter)
{
console.log (x + " is one of the quarter");
quarter = quarter + .25;
}
}
console.log (" ");
var part = .1;
for (x = 1; x <=100; x++)
{
if (x / 100 === part)
{
console.log (x + " is one of the part");
part = part + .1;
}
}