Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda