[go: up one dir, main page]

0% found this document useful (0 votes)
9 views9 pages

PRACTICAL NO 2 - Harshal - Css

Uploaded by

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

PRACTICAL NO 2 - Harshal - Css

Uploaded by

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

PRACTICAL NO 2

ROLL NO:- 243222

Exp2_st1: Design a javascript to demonstrate the use of control flow


statement.

Program:-

<html>
<head>
<title>
Exp2_1
</title>
</head>

<body>
<script language="javascript" type="text/javascript">

var marks=80;

if (marks < 40) {


document.write("Marks: " + marks + ", Grade: Fail");
} else if (marks >= 40 && marks < 50) {
document.write("Marks: " + marks + ", Grade: Pass");
} else if (marks >= 50 && marks < 60) {
document.write("Marks: " + marks + ", Grade: Second Class");
} else if (marks >= 60 && marks < 75) {
document.write("Marks: " + marks + ", Grade: First Class");
} else if (marks >= 75 && marks <= 100) {
document.write("Marks: " + marks + ", Grade: Distinction");
} else {
document.write("Marks: " + marks + ", Grade: Invalid marks");
}

</script>
</body>
</html>
OUTPUT:-
Exp2_st1_2:

PROGRAM:

<html>
<head>
<title>
Exp2_2
</title>
</head>

<body>
<script language="javascript" type="text/javascript">
var num=23;

if(num<18)
{
document.write(num+" "+"IS SMALLER THAN 18");
}
else if(num>25)
{
document.write(num+" "+"IS GREATER THAN 25");
}
else
{
document.write(num+" "+"IS SMALLER THAN 25");
}
</script>
</body>
</html>
OUTPUT:-
Ex[2_St2:Design a javascript to Display odd numbers upto 20 by for
loop.

<html>
<head>
<title>
Exp2_3
</title>
</head>

<body>
<script language="javascript" type="text/javascript">
document.write("ODD NUMBERS UP TO 20 <br>");
for(var i=0;i<20;i++)
{
if(i%2!=0)
{
document.write(i+"<br>");

}
}
</script>
</body>
</html>

OUTPUT:-
Exp2_Ex1:Declare ,initialize values to the given variable.

PROGRAM:-

<!DOCTYPE html>
<head>
<title>Document</title>
</head>
<body>
<script type="text/javascript">
document.write("<center><b>DECLARATION AND
INITIALIZATION OF VARIABLE IN JS</b></center><br>");

var name="HARSHAL";
var age=19;

document.write("VALUES ASSIGNED TO VARIABLES:-<br>");


document.write("NAME="+name+" "+"AGE="+age);
</script>
</body>
</html>

OUTPUT:-
Ex2_ex2:-Develop Javascript to implement the while loop:

Program:

<html>
<head>
<title>q</title>
</head>
<body>
<script type="text/javascript">
var count=1;
document.write("STARTING LOOP<br>");
while(count<=10)
{
document.write("CURRENT COUNT:-"+count+"<br>");
count++;
}
document.write("LOOP STOPED!");
</script>
</body>
</html>

OUTPUT:-
Exp2_ex3:Create and access object properties to solve the given
problem:-

Program:-

<html>
<head>
<title>exp2</title>
</head>
<body>
<script type="text/javascript">
var person=
{
firstName : "XYZ",
LastName : "ABC",
age : 30,
Eyecolor : "BLUE",

document.write("BEFORE DELETING EYE COLOR<br>");

for(var i in person)
{
document.write(i+":"+person[i]+"<br>");
}

document.write("AFTER DELETING EYE COLOR<br>");


delete person.Eyecolor;

for(var j in person)
{
document.write(j+":"+person[j]+"<br>");
}
</script>
</body>
</html>
OUTPUT:-

You might also like