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

112
Views
Unable to get output

I am trying to write code in JavaScript to get the same output as shown in this link http://www.99-bottles-of-beer.net/lyrics.html I guess I need to learn more about while loop. I tried to change the code many times like 10 maybe and Now I got frustrated.

My Code:-

function beer() {
  var count = 99;
  while (count >= 0) {
    var output = count + " bottles of beer on the wall, " + count +
    " bottles of beer. Take one down and pass it around, " + (count-1) + " bottles of beer on the wall.";
  }
  count--;
  console.log(output);
}
beer();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Make sure you handle, what to be looped. If you want to output something repeatedly, keep corresponding code in inside loop body. Also make sure loop condition is modifiable while loop is running. At somepoint loop should terminate. I have kept a running version of code here for ref. https://jsfiddle.net/a2qdk9t8/

function beer() {
  var count = 99;
  while (count >= 0) {
    var output = count + " bottles of beer on the wall, " + count +
    " bottles of beer. Take one down and pass it around, " + (count-1) + " bottles of beer on the wall.";
      count--;
  console.log(output);

  }
}
beer();
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!