Skip to content

JS: Can't easily do assignments in loop conditions #134

@nwinter

Description

@nwinter

From the forum:

while (enemy=this.findNearestEnemy()) this.attack(enemy);

... gives a message like, "Fix Your Code: expected a conditional expression and instead saw an assignment". However, this workaround works:

while ((enemy=this.findNearestEnemy())) this.attack(enemy);

Haven't yet looked to see where in the process the assignment is being broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions