1.
Basic JavaScript (Introduction & Syntax)
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Introduction</title>
</head>
<body>
<h2>JavaScript Introduction</h2>
<script>
[Link]("Hello, JavaScript!");
</script>
</body>
</html>
2. Variables Example
<!DOCTYPE html>
<html>
<head><title>Variables</title></head>
<body>
<script>
var name = "John";
var age = 22;
[Link]("Name: " + name + "<br>");
[Link]("Age: " + age);
</script>
</body>
</html>
3. Operators Example
<!DOCTYPE html>
<html>
<head><title>Operators</title></head>
<body>
<script>
var a = 10;
var b = 5;
[Link](a + b);
</script>
</body>
</html>
4. If-Else Example
<!DOCTYPE html>
<html>
<body>
<script>
var marks = 65;
if(marks >= 50){
[Link]("Pass");
}else{
[Link]("Fail");
}
</script>
</body>
</html>
5. Loop Example
<!DOCTYPE html>
<html>
<body>
<script>
for(var i=1;i<=5;i++){
[Link](i + "<br>");
}
</script>
</body>
</html>
6. Function Example
<!DOCTYPE html>
<html>
<body>
<button onclick="greet()">Click</button>
<script>
function greet(){
alert("Hello!");
}
</script>
</body>
</html>
7. Function with Parameters
<!DOCTYPE html>
<html>
<body>
<script>
function add(a,b){
return a+b;
}
[Link](add(5,3));
</script>
</body>
</html>
8. Button Event
<!DOCTYPE html>
<html>
<body>
<button onclick="show()">Click</button>
<script>
function show(){
alert("Clicked!");
}
</script>
</body>
</html>
9. Form Event
<!DOCTYPE html>
<html>
<body>
<input type="text" onkeyup="show([Link])">
<p id="demo"></p>
<script>
function show(val){
[Link]("demo").innerHTML = val;
}
</script>
</body>
</html>