<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>star</title>
</head>
<body>
<input type="text" name="" id="given_number"><br><br>
<button onclick="star_looping()">Click</button>
<br><br>
<div id="result"></div>
<script>
function star_looping() {
var number = parseInt(document.getElementById('given_number').value);
var result = "*";
var star;
for (var i = 0; i < number; i++) {
if (star == undefined) {
star = result + "<br>";
} else {
star = star + result + "<br>";
}
result = result + "*";
}
document.getElementById("result").innerHTML = star;
}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>star</title>
</head>
<body>
<input type="text" name="" id="given_number"><br><br>
<button onclick="star_looping()">Click</button>
<br><br>
<div id="result"></div>
<script>
function star_looping() {
var number = parseInt(document.getElementById('given_number').value);
var result = "*";
var star;
for (var i = 0; i < number; i++) {
if (star == undefined) {
star = result + "<br>";
} else {
star = star + result + "<br>";
}
result = result + "*";
}
document.getElementById("result").innerHTML = star;
}
</script>
</body>
</html>
No comments:
Post a Comment