0% found this document useful (0 votes)
8 views8 pages

Js Programs

The document contains multiple HTML scripts demonstrating basic JavaScript functionalities, including arithmetic operations, user prompts, conditional statements, and loops. It showcases examples such as calculating sums, determining the largest of three numbers, checking voting eligibility based on age, and displaying even numbers using both for and while loops. Additionally, it includes interactive elements like buttons and confirmation dialogs.

Uploaded by

mutindaamos540
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)
8 views8 pages

Js Programs

The document contains multiple HTML scripts demonstrating basic JavaScript functionalities, including arithmetic operations, user prompts, conditional statements, and loops. It showcases examples such as calculating sums, determining the largest of three numbers, checking voting eligibility based on age, and displaying even numbers using both for and while loops. Additionally, it includes interactive elements like buttons and confirmation dialogs.

Uploaded by

mutindaamos540
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;

[Link]("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;

//[Link]("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)

[Link]("a is Larger");

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

[Link]("b is Larger");

if(c>a && c>b)

[Link]("c is Larger");

else

[Link]("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)

[Link]("Eligible to vote");

else

[Link]("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;

[Link]("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([Link]("one").value);

b=parseInt([Link]("two").value);

sum=a+b;

[Link]("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)

[Link]("You pressed OK!");

else

[Link]("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">
[Link](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)

[Link](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)

[Link](i+" ");

i++;

</script>

</head>

<body>

</body>

</html>

You might also like