Google search

Basic and advanced computer skills like Excel with macros, How to speed up your PC, C, CPP, Java programming, HTML, JavaScript, PHP, Wordpress, all web tools, Android tutorials, MySQL Tutorials, WAMP server installation. etc.

Javascript programs

1. FOR Loop using Javascript

1. Print 1-10 numbers using FOR loop program
<html>
<head>
<title> Javascript looping program </title> 
</head>
<body>
<script language="javascript">
var i
document.write("<h1>"+"FOR Looping program" +"</h1>")
for(i=1; i<=10; i++)
{
document.write(i+"<br>")
}
</script>
</body>
</html>

2. WHILE Loop using Javascript

2. Print 1-10 numbers using WHILE loop program
<html>
<head>
<title> Javascript while loop program </title> 
</head>
<body>
<script language="javascript">
var i=1
document.write("<h1>"+"WHILE Loop program" +"</h1>")
while(i<=10)
{
document.write(i"+<br>")
i++
}
</script>
</body>
</html>

3. DO WHILE Loop using Javascript

3. Print 1-10 numbers using DO WHILE loop 
<html>
<head>
<title> Javascript while loop program </title> 
</head>
<body>
<script language="javascript">
var i=1
document.write("<h1>"+"DO WHILE Loop program" +"</h1>")
do
{
document.write(i"+<br>")
i++
}
while(i<=10);
</script>
</body>
</html>

4. Largest of two numbers

<html>
<head>
<title> Using Javascript </title>
</head>
<body>
<script language="javascript">
var a,b
a=prompt("Enter a value:")
b=prompt("Enter b value:")
if(a>b)
document.write("a is big")
else
document.write("b is big")
</script>
</body>
</html>

No comments:

Post a Comment