Slip 28 - A) Write a JavaScript program to construct the following pattern up to n lines, using a nested for loop.

Solution:


<HTML>
<head>
<script>
function find()
{
var no1=parseInt(frm.txt1.value);
for (i=1; i<=no1; ++i)
43
{
for (j=1; j<=i; ++j)
{
document.write("* ");
}
document.write("<br>");
}
}
</script>
</head>
<body>
<form name="frm">
Enter a Number:<input name="txt1" type="text" /><br><br>
<input name="b1" onclick="find();" type="button" value="display" /></form>
</BODY>
</HTML>

Post a Comment

0 Comments