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

156
Views
Started learning JS a weak ago, I'm getting this SyntaxError: Unexpected keyword 'else'

To start, I'm well aware that there have been many similar questions, trust me, I wouldn't have gone through the effort of making an account if I hadn't check those first. I've been coding on Python for around 3 years so I'm no stranger to programming logic, here's the code:

digest (FoodItem) {
        uk = upkeep();
        x = this.fullness + FoodItem.filling;
        y = this.Capacity + FoodItem.filling * 0.5;
        if (x>y) {
            return "Can't eat this"
        };
        else {
            this.fullness = x;
            z = 1;
            if (this.fullness > this.Saturation) {
                z = 1 + (this.fullness - this.Saturation)*0.1;
                z = z.toFixed(1);
            };
            if (this.quota < uk) {
                this.quota = this.quota + FoodItem.mass * z;
            };
            else {
                ...;
            };  
        };      
    };

Now, I know that removing the second else doesn't solve the issue so the main problem lies with the first one, I think but as to why it's not working I have no idea.

about 4 years ago · Juan Pablo Isaza
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!