samedi 10 juin 2017

JavaScript While Loop with if-else if-else and counter

I am trying to make a code which printed the multiples of 10 up to 120. It should not print 100, and show a message after 120. But for some reason, it doesn't work. On running the code, nothing on the page is displayed, not even other text. Please Help!

 while (z<100){
   if (z==100){
        document.write("Cannot print 100!");
        continue;
   }
   else if (z==130){
    document.write("Cannot print after 120!");
    break;
   }
document.write(z+"<br>");
z+=10;
}

Aucun commentaire:

Enregistrer un commentaire