FSD Exp 8
FSD Exp 8
from the user and outputs HTML text that displays the larger number followed by
the words “LARGER NUMBER” in an information message dialog. If the numbers are
equal, output HTML text as “EQUAL NUMBERS”.
Source code:
<!doctype html>
<html>
<head>
<script>
let a, b, c;
a = parseInt(prompt("Enter an integer",0));
alert("a ("+a+") is the LARGEST among given three integers a, b and c ("+a+", "+b+", and
"+c+")");
else if(b>c)
alert("b ("+b+") is the LARGEST among given three integers a, b and c ("+a+", "+b+", and
"+c+")");
else
alert("c ("+c+") is the LARGEST among given three integers a, b and c ("+a+", "+b+", and
"+c+")");
</script>
</head>
<body>
</body>
</html>
Write a program to print 1 to 10 numbers using for, while and do-while loops.
Source code:
8_d.js
let i;
function display_while()
{
i=1;
while(i<=10)
{
document.write(i);
i=i+1;
}
}
function display_doWhile()
{
i=1;
do{
document.write(i);
i++;
}while(i<=10);
}
function display_for()
{
for(i=1; i<=10; i++)
{
document.write(i)
}
}
8_d.html
Source code:
<!-- Armstrong number verification -->
<!doctype html>
<html>
<head>
</head>
<body>
<script>
sum = 0;
while(n>0)
rem = Math.floor(n%10);
n = n/10;
if(sum==m)
else
</script>
</body>
</html>
Write aprogram to print data in object using for-in, for-each and for-of loops
Source code:
<!doctype html>
<html>
<head>
</head>
<body>
<h1>For Variations</h1>
<script>
let student = {
name:"Ram",
age:19,
gender:"Male",
course:"B.Tech.",
branch:"CSE",
year:1,
sem:1
document.write("<hr/><b>For Of</b><br/>")
let text;
for(let x of arr)
document.write(x + "<br/>")
document.write("<hr/><b>For In</b><br/>");
document.write(student[key]+"<br/>")
for(let x in arr)
document.write(x+":"+arr[x]+"<br/>");
document.write("<hr/><h3>For Each</h3>")
marks.forEach(findSum);
function findSum(curr,index,m)
if(m[index]<=95)
m[index] = curr + 5;
document.write(marks)
</script>
</body>
</html>