gambar javascript

1. <!DOCTYPE html> <html> <body> <h2>GAMBAR SEGITIGA TEGAK</h2> <p></p> <p id="demo"></p> <script> let text = ""; let n = 10; for (let i = 0; i < n; i++) { for (let j = 0; j <= i; j++){ text += "*"; } text +="<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>
2. <!DOCTYPE html> <html> <body> <h2>GAMBAR SEGITIGA TERBALIK</h2> <p></p> <p id="demo"></p> <script> let text = ""; let n = 10; for (let i = 0; i < n; i++) { for (let j = i; j < n; j++){ text += "*"; } text +="<br>"; }
3. <!DOCTYPE html> <html> <body> <h2>GAMBAR BEBAS</h2> <p></p> <p id="demo"></p> <script> let text = ""; let n = 10; for (let i = 0; i < n; i++) { for (let j = 0; j <= i; j++){ text += "*"; } text +="<br>"; } for (let i = 0; i < n; i++) { for (let j = 0; j <= i; j++){ text += "&nbsp&nbsp"; } for (let j = i; j < n; j++){ text += "*"; } text +="<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>

HOME