var num = 233826;
var count = 0;
do {
num = num/10;
++count;
} while (num > 0)
document.write("Total words are ", count);
output is >>>>>Total words are 330
if I write >>>>> document.write("Total words are ", count-324) then it gives me the required output which is (6)
You need to check for > 1 not > 0 but you can also get the string length (as long as it is a positive integer)
let num = 233826;
let count = 0;
document.write('hmm: ',num.toString().length,'<br>');
do {
num = num/10;
++count;
} while (num > 1)
document.write("Total words are ", count);