-1

I'm trying to break out of my update() function. Here is what I've tried:

if (score.l1 > 20) {
  break;
}

but it just returns "Illegal break statement"

Ori Drori
  • 166,183
  • 27
  • 198
  • 186

1 Answers1

0

break only works inside a loop. What you can do is return; instead.

if (score.l1 > 20) {
    return;
}
Vighnesh Raut
  • 1,254
  • 7
  • 19
  • 1
    All of the basic questions about JavaScript have been asked and answered. Better to mark something as a duplicate than to post yet another answer. – T.J. Crowder Jan 11 '20 at 16:40