
Simple Pyramid
Given below is an example of a simple type of pyramid that you can easily create using the HTML as well as JavaScript code given below the example.*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
<!By GadTool.blogspot.com>
<!DOCTYPE html>
<html>
<body>
<p id="GadTool"></p>
</body>
<head>
<script>
var x, y, num=10;
var GT="";
for(x=1;x<=num;x++){
for(y=0;y<x;y++){
//Adding an Asterisk(*) followed by a space
GT=GT+"* ";
}
//Changing the line
document.getElementById("GadTool").innerHTML=GT;
GT=GT+"<br>";
}
</script>
</head>
</html>
<!DOCTYPE html>
<html>
<body>
<p id="GadTool"></p>
</body>
<head>
<script>
var x, y, num=10;
var GT="";
for(x=1;x<=num;x++){
for(y=0;y<x;y++){
//Adding an Asterisk(*) followed by a space
GT=GT+"* ";
}
//Changing the line
document.getElementById("GadTool").innerHTML=GT;
GT=GT+"<br>";
}
</script>
</head>
</html>
<!By GadTool.blogspot.com>
<!DOCTYPE html>
<html>
<body>
<p id="GadTool"></p>
</body>
<head>
<script>
var x, y, num=10;
var GT="";
for(x=1;x<=num;x++){
for(y=0;y<x;y++){
//Adding an Asterisk(*) followed by a space
GT=GT+"* ";
}
//Changing the line
document.getElementById("GadTool").innerHTML=GT;
GT=GT+"<br>";
}
</script>
</head>
</html>
Numbered Pyramid
Given below is an example of a pyramid that you can easily create using the HTML as well as JavaScript code given after the example.Here the asterisk(*) is replaced by numbers.
You are gonna understand the program in a better way seeing the below example⤵️
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
<!DOCTYPE HTML>
<!By GadTool.blogspot.com>
<html>
<body>
<p id="GadTool"></p>
</body>
<head>
<script>
var x, y, num=10;
var GT="";
var nomme=1;
for(x=1;x<=num;x++){
for(y=0;y<x;y++){
//Adding an Asterisk(*) followed by a space
GT=GT+nomme+" ";
nomme=nomme+1;
}
//Changing the line
document.getElementById("GadTool").innerHTML=GT;
GT=GT+"<br>";
nomme=1;
}
</script>
</head>
</html>
<!By GadTool.blogspot.com>
<html>
<body>
<p id="GadTool"></p>
</body>
<head>
<script>
var x, y, num=10;
var GT="";
var nomme=1;
for(x=1;x<=num;x++){
for(y=0;y<x;y++){
//Adding an Asterisk(*) followed by a space
GT=GT+nomme+" ";
nomme=nomme+1;
}
//Changing the line
document.getElementById("GadTool").innerHTML=GT;
GT=GT+"<br>";
nomme=1;
}
</script>
</head>
</html>
<!DOCTYPE HTML>
<!By GadTool.blogspot.com>
<html>
<body>
<p id="GadTool"></p>
</body>
<head>
<script>
var x, y, num=10;
var GT="";
var nomme=1;
for(x=1;x<=num;x++){
for(y=0;y<x;y++){
//Adding an Asterisk(*) followed by a space
GT=GT+nomme+" ";
nomme=nomme+1;
}
//Changing the line
document.getElementById("GadTool").innerHTML=GT;
GT=GT+"<br>";
nomme=1;
}
</script>
</head>
</html>
0 Comments