Commit c29c1f29 authored by Nikitha Moosapet's avatar Nikitha Moosapet

Commiting the JavaScript Assignments

parent 357d2c0e
<html>
<head>
<title>Arithematic Operators</title>
</head>
<body>
<h1>Introduction to Java Script Operators</h1>
<script type="text/javascript">
var a = 19;
var b =12;
var c = 15;
var linebreak = "<br/>";
document.write("a + b = ");
result = a + b;
document.write(result);
document.write(linebreak);
document.write("a - b = ");
result = a - b;
document.write(result);
document.write(linebreak);
document.write("a / b = ");
result = a / b;
document.write(result);
document.write(linebreak);
document.write("a % b = ");
result = a % b;
document.write(result);
document.write(linebreak);
document.write("a + b + c = ");
result = a + b + c;
document.write(result);
document.write(linebreak);
a = ++a;
document.write("++a = ");
result = ++a;
document.write(result);
document.write(linebreak);
b = --b;
document.write("--b = ");
result = --b;
document.write(result);
document.write(linebreak);
document.write("(a == b) => ");
result = (a == b);
document.write(result);
document.write(linebreak);
document.write("(a < b) => ");
result = (a < b);
document.write(result);
document.write(linebreak);
document.write("(a > b) => ");
result = (a > b);
document.write(result);
document.write(linebreak);
document.write("(a != b) => ");
result = (a != b);
document.write(result);
document.write(linebreak);
document.write("(a >= b) => ");
result = (a >= b);
document.write(result);
document.write(linebreak);
document.write("(a <= b) => ");
result = (a <= b);
document.write(result);
document.write(linebreak);
document.write ("((a > b) ? 100 : 200) => ");
result = (a > b) ? 100 : 200;
document.write(result);
document.write(linebreak);
document.write ("((a < b) ? 100 : 200) => ");
result = (a < b) ? 100 : 200;
document.write(result);
document.write(linebreak);
</script>
</body>
</html>
<html>
<head>
<title>If_ELSE</title>
</head>
<body>
<h1>Welcome to IF_ELSE Concept</h1>
<script type = "text/javascript">
var book = "Javascript";
if( book == "DBMS" ) {
document.write("<b>Database Management Systems Book</b>");
} else if( book == "Java" ) {
document.write("<b>Java Fundamentals Book</b>");
} else if( book == "Javascript" ) {
document.write("<b>Basic Concepts of Javascript</b>");
} else {
document.write("<b>Unknown Book</b>");
}
</script>
</body>
<html>
<html>
<head>
<title>Switch Statements</title>
</head>
<body>
<h1>Welcome to Switch Concept</h1>
<script type = "text/javascript">
var grade = 'A';
document.write("Entering switch block<br />");
switch (grade) {
case 'A': document.write("Good job<br />");
break;
case 'B': document.write("Pretty good<br />");
break;
case 'C': document.write("Passed<br />");
break;
case 'D': document.write("Not so good<br />");
break;
case 'F': document.write("Failed<br />");
break;
default: document.write("Unknown grade<br />")
}
document.write("Exiting switch block");
</script>
</body>
</html>
<html>
<head>
<title>Welcome to While Loops</title>
</head>
<body>
<h1>Welcome to While Loops</h1>
<script type = "text/javascript">
var count = 0;
document.write("Starting Loop ");
while (count < 10) {
document.write("Current Count : " + count + "<br />");
count++;
}
document.write("Loop stopped!");
</script>
</body>
</html>
<html>
<head>
<title>Welcome to Do - While Loops</title>
</head>
<body>
<h1>Welcome to D- While While Loops</h1>
<script type = "text/javascript">
var count = 1;
document.write("Starting Loop" + "<br />");
do {
document.write("Current Count : " + count + "<br />");
count++;
}
while (count < 5);
document.write ("Loop stopped!");
</script>
</body>
</html>
<html>
<head>
<title>Welcome to For Loop</title>
</head>
<body>
<h1>Welcome to For Loops</h1>
<script type = "text/javascript">
var count;
document.write("Starting Loop" + "<br />");
for(count = 0; count < 10; count++) {
document.write("Current Count : " + count );
document.write("<br />");
}
document.write("Loop stopped!");
</script>
</body>
</html>
<html>
<head>
<title>Welcome to For-In Loops</title>
</head>
<body>
<h1>Welcome to For-In Loops</h1>
<script type = "text/javascript">
const arr = [ 'Welcome', 'to', 'JavaScript' ];
// using for...in loop
for (let x in arr) {
console.log(arr[x]);
document.write(arr[x]);
}
</script>
</body>
</html>
<html>
<head>
<title>Welcome to Loop Control</title>
</head>
<body>
<h1>Welcome to Loop Control</h1>
<script type = "text/javascript">
var x = 0;
document.write("Entering the loop<br /> ");
while (x < 8) {
if (x == 4) {
break; // breaks out of loop completely
}
x++;
document.write( x + "<br />");
}
document.write("Exiting the loop!<br /> ");
</script>
</body>
</html>
<html>
<head>
<title>Functions</title>
</head>
<h1>Welcome to Functions</h1>
<script type = "text/javascript">
function myName(first, last) {
var name;
name = first + last;
return name;
}
function myFullName() {
var fullName;
fullName = myName('Nikitha', 'Moosapet');
document.write (fullName );
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "myFullName()" value = "Click">
</form>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment