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

134
Vistas
Im doing a JavaScript CodeHS course, but what am I doing wrong?

Im doing intro to JS in a site called CodeHS. I believe I did the assignment its asking of me right but it says its wrong?

Here is what it wants me to do:

What it wants me to do

Here is what I did:

What I did

Heres what I apparently got wrong:

What I got wrong???

Ive run this code many times and it worked flawlessly, so why does it give me these errors?

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

0

You forgot to add a blank line inside the end of your while block, which also accounts for the line number. You should check the IMPORTANT note on the assignment.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I agree with @Jorge. You need to include the new line character '\n' at the end of the appropriate print statements, for the sake of the marking program. Try it like this:

while(numItems > 0) {
        println('We have ' + numItems + ' in inventory.');
        var buy = readInt('How many items would you like to buy?');
        if(buy <= numItems) {
            numItems -= buy; 
            println('Now we have ' + numItems + ' left.' + '\n');
        } else {
            println('There is not enough in inventory for that purchase.' + '\n');
        }
    }
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