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

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

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 Relatório

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 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