Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!