Rabu, 04 Juni 2014

Latihan Dasar JavaScript

Membuat Bentuk Belah Ketupat Menggunakan JavaScript
Berikut Scriptnya :
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <meta name="author" content="endar" />

    <title>endar belah ketupat</title>
    <script type="text/javascript">
        var i,j,y;

            for(i=10;i>0;i--){
                for(j=1;j<=i-1;j++){
                document.write("&nbsp&nbsp&nbsp");
                }
            for(y=1;y<=10-i+1;y++){
                document.write(" * ");
                }
            for(l=1;l<=10-i;l++){
                document.write(" * ");
                }
                document.write("<br>");
                }
            for(i=1;i<=10;i++){
            for(j=1;j<=i;j++){
                document.write("&nbsp&nbsp&nbsp");
                }
            for(y=1;y<=10-i;y++){
                document.write(" * ");
                }
            for(l=1;l<10-i;l++){
                document.write(" * ");
                }
                document.write(" <br> ");
                }
    </script>
</head>
<body>
</body>
</html>
Dibawah ini hasil jadinya !
Selamat Mencoba !

Tidak ada komentar:

Posting Komentar