0% found this document useful (0 votes)
50 views6 pages

Practical 2

Practical 2 of CSS

Uploaded by

huzaifasajid73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views6 pages

Practical 2

Practical 2 of CSS

Uploaded by

huzaifasajid73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Practical 2

<html>
<head>
<title>If Statement</title>
</head>
<body>
<script>
var x= 7;
var y= 7;
if(x==y)
{
document.write("Both are
Equal !!");
}
</script>
</body>
</html>

2.
<html>
<head>
<title>If Else</title>
</head>
<body>
<script>
var age = 14;
if(age>=18)
{
document.write("Get driver licnce");
document.write("Get dads Car");
}
else
{
document.write("Ride a Bycycle");
document.write("we are only "+age);
}
</script>
</body>
</html>
3.
<html>
<head>
<title>If Else</title>
</head>
<body>
<script>
var age = 14;
var freind_age=16;
if(age>=18)
{
document.write("Get driver licnce");
document.write("Get dads Car");
}
else if(freind_age>=18)
{
document.write("Let This Freind Dirve the car");
}
else
{
document.write("Kids, stick to bycycle");
}
</script>
</body>
</html>

4.
<html>
<head>
<title>If Else</title>
</head>
<body>
<script>
var age = 15;
if(age<70)
{
if(age<30) {
document.write("Age is < 30");
}else {
document.write("Age is between 30 and
70");}
}else {
if(age>85) {
document.write("Age is > 85");
}else {
document.write("Age is between 70 and 85");
} }
</script>
</body>
</html>

5.
<html>
<body>
<script type="text/javascript">
var grade = "A";
document.write("Entering the 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("Enter a Valid Grade<br>");
}
document.write("Exiting Swicthc Block");
</script>
</body>
</html>
1.
<html>
<head>
<title>For Loop</title>
</head>
<body>
<script>
for (var x = 6; x <= 10; x++) {
document.write("The Number IS "+x + "<br>");
}
</script>
</body>
</html>

2.
<html>
<head>
<title>For In Loop</title>
</head>
<body>
<script type = "text/javaScript">
var lang = { first : "C", second : "Java",third : "Python", fourth : "PHP"};
for (prog in lang)
{
document.write(lang[prog] + "<br >");
}
</script>
</html>

3.
<html>
<head>
<title>While Loop</title>
</head>
<body>
<script>
var x = 3;
while (x <= 10) {
document.write("The Number IS "+x + "<br>");
x++;
}
</script>
</body>
</html>
4.
<html>
<head>
<title>For In Loop</title>
</head>
<body>
<script type = "text/javaScript">
var aProperty;
document.write("Navigator Object Properties<br />");
for (aProperty in navigator) {
document.write(aProperty);
document.write("<br />");
}
document.write("Exiting from the loop!");
</script>
</html>

5.

<html>
<head>
<title>Do While Loop</title>
</head>
<body>
<script>
var count = 0 ;
document.write("Starting Loop" + "<br>");
do {
document.write("Current Count : " + count + "<br>");
count++;
}while (count < 5);
document.write("Loop stopped!");
</script>
</html>
1.
<html>
<head>
<title>Break</title>
</head>
<body>
<script>
var x = 1;
document.write("Entering Loop" + "<br>");
while (x <= 20) {

if (x == 5) {
break;
}
x++;
document.write("The Number IS "+x + "<br>");
}
document.write("Exiting Loop!");
</script>
</html>

2.
<html>
<head>
<title>Break</title>
</head>
<body>
<script>
var x = 1;
document.write("Entering Loop" + "<br>");
while (x <= 20) {
x++;
if (x == 5) {
continue;
}
document.write("The Number IS "+x + "<br>");
}
document.write("Exiting Loop!");
</script>
</html>

You might also like