Write a programme using loop for star pattern;
<html>
<head><title>javascript</title>
<script>
function loop(){
let n = 8; let text ;
for (let i = 1; i <= n; i++) {
for (let j = 0; j < i; j++) {
text+= "*";
}
text+= "\n";
}
}
document.getElementById("demo").innerHTML=loop();
</script>
</head>
<body>
<p id="demo"></p>
</body>
</html>
output:-
*
**
***
****
*****
******
*******
********
Write a programme using loop for downward star pattern;
<html>
<head><title>javascript</title>
<script>
function loop(){
let n = 8; let string ;
for (let i = 0; i <= n; i++) {
for (let j = 0; j < n-i; j++) {
string += "*";
}
string += "\n";
}
}
document.getElementById("demo").innerHTML=loop();
</script>
</head>
<body>
<p id="demo"></p>
</body>
</html>
********
*******
******
*****
****
***
**
*