I am trying to write a block of code which will separate digits (with modulus operator) in a number first and count how many digit "6" are there in the number.
I tried so many things but I think I have logic problem with the way I think.
output = [];
var count = 0;
while (a > 0){
output.push(a % 10);
a = Math.floor(a/10);
if(a == 6){
count++;
}
}
When I run this code on Safari, It shows the entered number as it is, but it shows "0" for the variable count.
"6"es?