99 garrafas de suco

Direções:

Escreva um loop que exiba a canção a seguir. Começando em 99 e terminando em 1 garrafa (bottle).
99 bottles of juice on the wall! 99 bottles of juice! Take one down, pass it around... 98 bottles of juice on the wall!
98 bottles of juice on the wall! 98 bottles of juice! Take one down, pass it around... 97 bottles of juice on the wall!
...
2 bottles of juice on the wall! 2 bottles of juice! Take one down, pass it around... 1 bottle of juice on the wall!
1 bottle of juice on the wall! 1 bottle of juice! Take one down, pass it around... 0 bottles of juice on the wall!
Alguns detalhes:
  1. Observe a pluralização da palavra "bottle" quando você passa de 2 bottles para 1 bottle.
  2. Seu editor de texto provavelmente tentará corrigir suas reticências ... para o caractere . Não utilize o caractere de reticências neste quiz.


    Código
var x = 99;

while ( x > 0){
( x === 2 ) ? console.log ( x + " bottles of juice on the wall! " + x + " bottles of juice! Take one down, pass it around... " + (x - 1)  + " bottle es of juice on the wall! ") : (x === 1) ? console.log ( x + " bottle of juice on the wall! " + x + " bottle of juice! Take one down, pass it around... " + (x - 1) + " bottles es of juice on the wall!") : ( x > 2) ? 
console.log ( x + " bottles of juice on the wall! " + x + " bottles of juice! Take one down, pass it around... " + (x - 1) + " bottles es of juice on the wall!") : console.log ("end");

x = x - 1;
}

Comentários

Postagens mais visitadas deste blog

Quiz Verificando seu saldo

Quiz: Morrendo de rir 1 (5-1)