0% found this document useful (0 votes)
19 views13 pages

Js Programs

The document contains multiple HTML scripts that demonstrate basic JavaScript functionalities, including arithmetic operations, conditional statements, loops, and user prompts. It showcases various examples such as calculating sums, determining the largest number among inputs, checking voting eligibility based on age, and displaying even and odd numbers. Each section is structured as a separate HTML document with corresponding JavaScript code embedded within.
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)
19 views13 pages

Js Programs

The document contains multiple HTML scripts that demonstrate basic JavaScript functionalities, including arithmetic operations, conditional statements, loops, and user prompts. It showcases various examples such as calculating sums, determining the largest number among inputs, checking voting eligibility based on age, and displaying even and odd numbers. Each section is structured as a separate HTML document with corresponding JavaScript code embedded within.
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

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var a,b,sum;

a=6;

b=10;

sum=a+b;

document.write("sumis"+sum);

alert("Sum is"+sum);

</script>

</head>

<body>

</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

let sum;

const a=parseFloat(prompt("enter first number"));

const b=parseFloat(prompt("enter secod number"));

sum=a+b;

//document.write("The sum is"+sum);

alert("Sum Is"+sum);

</script>

</head>

<body>
</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

//Prompt code section

const a=parseFloat(prompt("enter first number"));

const b=parseFloat(prompt("enter second number"));

const c=parseFloat(prompt("enter thirdumber"));

//Test Condition here

if(a>b && a>c)

document.write("a is Larger");

else if(b>a && b>c)

document.write("b is Larger");

if(c>a && c>b)

document.write("c is Larger");

else

document.write("Equal");

}
</script>

</head>

<body>

</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

const age=parseInt(prompt("Enter the age"));

if(age>=18)

document.write("Eligible to vote");

else

document.write("Not Legible");

</script>

</head>

<body>

</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

let area;

const l=parseInt(prompt("Enter Length"));


const w=parseInt(prompt("Enter Width"));

area=l*w;

document.write("Area is"+area);

</script>

</head>

<body>

</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

function adding()

var a,b,sum;

a=parseInt(document.getElementById("one").value);

b=parseInt(document.getElementById("two").value);

sum=a+b;

document.getElementById("answer").value=sum;

</script>

</head>

<body>

<p>ENTER FIRST NUMBER:<input id="one"></p>

<p>ENTER SECOND NUMBER:<input id="two"></p>

<button onClick="adding()">CALCULATE SUM</button>

<p>SUM IS:<input id="answer"></p>

</body>

</html>
<html>

<head>

<script type="text/javascript">

function show_confirm()

var r=confirm("Press a button");

if (r==true)

document.write("You pressed OK!");

else

document.write("You pressed Cancel!");

</script>

</head>

<body>

<input type="button" onclick="show_confirm()" value="Show confirm box" />

</body>

</html>

<html>
<head>
<script type="text/javascript">
function product(a,b)
{
return a*b;
}

</script>
</head>
<body>
<script type="text/javascript">
document.write(product(4,3));
</script>
</body>
</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

const a=parseInt(prompt("enter the first number"));

const b=parseInt(prompt("enter the second number"));

const c=parseInt(prompt("enter the third number"));

if(a>b && a>c)

alert("A is Larger");

else if(b>a && b>c)

alert("B is Larger");

else if(c>a && c>b)

alert("C is Larger");

else

alert("They are Equal");

</script>

</head>

<body>
<button onClick="map()">CLICK US</button>

</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i;

for(i=1;i<=10;i++)

if(i%2==0)

document.write(i+" ");

</script>

</head>

<body>

</body>

</html>

<html>

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i=1;

while(i<=10)

{
if(i%2==0)

document.write(i+" ");

i++;

</script>

</head>

<body>

</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

const x=parseInt(prompt("enter first number"));

const y=parseInt(prompt("enter second number"));

if(x>y)

alert("X is larger");

</script>

</head>

<body>

</body>

</html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

const x=parseInt(prompt("enter first number"));

const y=parseInt(prompt("enter second number"));

if(x>y)

alert("X is larger");

else

alert("Y is larger");

</script>

</head>

<body>

</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

const x=parseInt(prompt("enter first number"));

const y=parseInt(prompt("enter second number"));

const z=parseInt(prompt("enter third number"));

if(x>y && x>z)


{

alert("X is larger");

else if(y>x && y>z)

alert("Y is larger");

else if(z>x && z>y)

alert("Z is larger");

else

alert("They are Equal");

</script>

</head>

<body>

</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i;

for(i=1;i<=10;i++)

document.write(i+" ");

</script>
</head>

<body>

</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i;

for(i=1;i<=10;i++)

if(i%2==0)

document.write(i+"<br>");

</script>

</head>

<body>

</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i;
for(i=1;i<=10;i++)

if(i%2!=0)

document.write(i+"<br>");

</script>

</head>

<body>

</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i=1;

while(i<=10)

document.write(i+" ");

i++;

</script>

</head>

<body>
</body>

</html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<script type="text/javascript">

var i=1;

while(i<=10)

if(i%2!=0)

document.write(i+" ");

i++;

</script>

</head>

<body>

</body>

</html>

You might also like