Belah ketupat Java Script dengan while

<html>
<title> belah ketupat </title>
<body>
<script type="text/javascript">
var bil=5;
var i= bil;
while(i>0){

var j=1;
while(j<=i-1){
document.write('&nbsp&nbsp');
j++;
}

var y=1;
while(y<=bil-i+1){
document.write('*');
y++;
}

var l=1;
while(l<=bil-i){
document.write('*');
l++;
}
document.write('<br>');
i--;
}

var i=1;
while(i<=bil)

{
var j=1;
while(j<=i){
document.write('&nbsp&nbsp');
j++;
}

var y=1;
while(y<=bil-i){
document.write('*');
y++;

}

var l=1;
while(l<bil-i){
document.write('*');
l++;
}
document.write('<br>');
i++;
}
</script>
</body>
</html>


outputnya :

0 komentar:

Poskan Komentar