Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
I am trying to find total Number of Digits using counter variable in javascript but output is always 324+ than the required
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)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!