JS basic grammar --- continue keyword

continue: in a loop if they continue keyword, just start the next cycle

 

As follows: continue before the counter, would have been circulating, the browser will crash, I broke down

      var i = 0;
      while (i < 10) {
        console.log ( "ha");
        continue;
        i++;
      }

 

Exercise 1: seek between all odd and 100-200 (with continue)

      was some = 0;
      was = 100;
      while (i <= 200) {
        // judgment is not an even number
        if (i % 2 == 0) {
          // If is even -----> skip this figure
          i++; //102
          continue;
        }
        sum += i;
        i++;
      }
      console.log(sum);

 

Exercise 2: Find the accumulated value an integer of 100 to 200, but requires skip all the bits number 3

      was some = 0;
      was = 100;
      while (i <= 200) {
        if (i % 10 == 3) {
          i++;
          continue;
        }
        sum += i;
        i++;
      }
      console.log(sum);

 

Guess you like

Origin www.cnblogs.com/jane-panyiyun/p/11919567.html