-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
  • 183,571
  • 29
  • 224
  • 209

1 Answers1

0

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

if (score.l1 > 20) {
    return;
}
vighnesh153
  • 4,354
  • 2
  • 13
  • 27
  • 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