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

132
Vistas
javascript ( while loop )

hi everyone am fairly new to javascript , so i wrote this fizzbuzz challenge but somehow it wouldn't run i don't know what to do , thanks and here's the code :

var output = []
var count =1;

function fizzBuzz(){
  while(count<=100){
    if (count%3===0 && count%5===0){
     output.push("fizzbuzz");
    }else if (count%3===0){
      output.push("fizz");
    }else if (count%5===0){
      output.push("buzz");
    }else {
      output.push(count);
    }
    count++;
  }
  console.log(output);
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

i would have used a for loop there, even tho that would work fine, you didnt call the function. add fizzBuzz(); at the bottom

about 4 years ago · Juan Pablo Isaza Denunciar

0

var output = [];

function fizzBuzz(){
  for(var i=0; i<100; i++){
    if (i%3===0 && i%5===0){
     output.push("fizzbuzz");
    }else if (i%3===0){
      output.push("fizz");
    }else if (i%5===0){
      output.push("buzz");
    }else {
      output.push(i);
    }
    console.log(output);
  }
}

fizzBuzz();

for the while loop

that way you dont need a count variable and its much cleaner

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