Using the continue and break Statements : For : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » For »

 

Using the continue and break Statements



<html>
<head>
  <title>Using the continue and break Statements</title>
</head>
<body>
  <script type="text/javascript">
  <!--
    var highestNum = 0;
    var n = 201;
   
    for(var i = 0; i < n; ++i){
      document.write(i + "<br>");
      if(n < 0){
        document.write("n cannot be negative.");
        break;
      }
      if (i * i <= n) {
        highestNum = i;
        continue;
      }
      document.write("<br>Finished!");
      break;
    }
    document.write("<br>The integer less than or equal to the Square Root");
    document.write(" of " + n + " = " + highestNum);
  // -->
  </script>
</body>
</html>


           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» For