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

85
Vistas
Comparison operators - if / else if statements

This exercise was already posted here a few years ago How to use comparison operators however the solution presented is not working for me.

The question is:

On the editor to your right you find a variable named charmanderLevel, to which a value between 1 and 100 will be assigned.

Using else if statements print to the console which evolution of Charmander corresponds to that experience level. Consider an else statement if the experience level ever go above 100 that should print 'Charizard is as good as it gets '.

Here's a chart with the evolution which corresponds to each level:

Charmander - 1 to 15 Charmeleon - 16 to 35 Charizard - 36 to 100"

The solution was

var charmanderLevel = Math.ceil(Math.random() * 100);

if (charmanderLevel >= 1 && charmanderLevel <= 15) {
  console.log('Charmander');
} else if (charmanderLevel >= 16 && charmanderLevel <= 35) {
  console.log('Charmeleon');
} else if (charmanderLevel >= 36 && charmanderLevel <= 100) {
  console.log('Charizard');
} else {
  console.log('Charizard is as good as it gets');
}

And I created literally the same

var charmanderLevel = Math.ceil(Math.random() * 100);

if (charmanderLevel >= 1 && charmanderLevel <= 15) {
  console.log("Charmander");
} else if (charmanderLevel >= 16 && charmanderLevel <= 35) {
  console.log("Charmeleon");
} else if (charmanderLevel >= 36 && charmanderLevel <= 100) {
  console.log("Charizard");
} else {
  console.log('Charizard is good as it gets');
}

But my console keeps saying

"Code is incorrect You should only print to the console the Charmander evolution level, nothing else".

They suggested that I opened a new question regarding this to ask to some of you some lights please, why it worked for some and mine is not.

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I had to use a file comparer to see the slightly detail.

In case of level > 100, your message is "Charizard is good as it gets", you miss the little "as" of the right answer.

This answer show how to compare files in vscode.

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