Javascript : Proses Berulang : Pernyataan While dan Do While

Selasa, 26 Februari 2019

Javascript : Proses Berulang : Pernyataan While dan Do While


Proses Berulang : Pernyataan While, Do While







 Script While :
<HTML>
<HEAD>
<TITLE>Contoh while</TITLE>
</HEAD>
<BODY>

<SCRIPT LANGUAGE = "JavaScript">
var bilangan = 0;
   while (bilangan < 5) {
      
document.write("JavaScript<BR>");
      
bilangan++;
   }</SCRIPT>
</BODY>
</HTML>

Hasil : 



Script Do While :
<HTML>
<HEAD>
<TITLE>Contoh do while</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">var bilangan = 1;
   do {
      
document.write(bilangan + "<BR>");
      
bilangan++;
   } while (bilangan < 6);

</SCRIPT>
</BODY>
</HTML>


Hasil :

 

0 komentar :

Posting Komentar