Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda