"loop" linter-jshint errors

loop 
{
    var enemy = this.findNearestEnemy();
    if (enemy) {
        this.attack(enemy);
    }
}

Linter-JSHint gave me those errors:
W030 - Expected an assignment or function call and instead saw an expression.at line 1 col 1
W033 - Missing semicolon.at line 1 col 5

I have lots of loop in my code from сodeсombat and each loop gives two errors.
Please explain me why they occur and how to get rid of these errors.

I think you need to move the first bracket on the same line as the loop, but I’m not sure. Either that, or CodeCombat has taken out the loop command.

No.
I searched for loop in the JavaScript and could not find it even exists in the JS.

Indeed, it does not exist in the real JavaScript programming language.

However, a (relatively) long time ago, CodeCombat added the loop construct to make syntax easier on beginners, so they could focus on the programming logic instead of the syntax intricacies.

More recently, CodeCombat decided to move from the non-standard loop construct to while (true) {} loops. This is being done progressively (courses already use while-true loops, not sure about the campaign’s state), so you may find some rough edges.

1 Like