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

2 TT284 JavaScript

The document consists of multiple HTML examples demonstrating JavaScript functionalities including prompts, alerts, mathematical operations, conditional statements, loops, and functions. Each section showcases different programming concepts such as user input handling, arithmetic operations, and function definitions. The examples are structured to illustrate basic JavaScript syntax and usage in a web environment.

Uploaded by

jota.0100100
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)
2 views8 pages

2 TT284 JavaScript

The document consists of multiple HTML examples demonstrating JavaScript functionalities including prompts, alerts, mathematical operations, conditional statements, loops, and functions. Each section showcases different programming concepts such as user input handling, arithmetic operations, and function definitions. The examples are structured to illustrate basic JavaScript syntax and usage in a web environment.

Uploaded by

jota.0100100
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

TT284 JavaScript

<html>
<head>
<script >
number = prompt("Enter number ");
1.
</script> Prompt
</head>
<body>
</body>
</html>

<html>
<body>

<script>
2. [Link]("Hello AOU students");
[Link]
</script>

</body>
</html>

<html>
<body>

<script>
3. alert("Hello AOU students");
alert
</script>

</body>
</html>

<html>
<body>

<script>
4. [Link](Date());
Date()
</script>

</body>
</html>

1
TT284 JavaScript
<html>
<body>

<script>

num1 = 12;
num2 = 5;
Result = num1 + num2;
[Link]("<br>" + "sum = " + Result);
Result = num1 - num2;
[Link]("<br>" + "sum = " + Result);
5. Result = num1 * num2; Mathematical
[Link]("<br>" + "sum = " + Result); Operators
Result = num1 / num2;
[Link]("<br>" + "sum = " + Result);
Result = num1 % num2;
[Link]("<br>" + "sum = " + Result);

</script>

</body>
</html>

<html>
<body>

<script>
num1 = Number(prompt("Enter number "));
num2 = Number(prompt("Enter number "));

Result = num1 + num2;


[Link]("<br>" + "Result = " + Result);
Result = num1 - num2;
[Link]("<br>" + " Result = " + Result);
6.
Result = num1 * num2; Input
[Link]("<br>" + " Result = " + Result);
Result = num1 / num2;
[Link]("<br>" + " Result = " + Result);
Result = num1 % num2;
[Link]("<br>" + " Result = " + Result);

</script>

</body>
</html>

2
TT284 JavaScript
<html>
<body>

<script>

num1 = Number(prompt("Enter number "));


num2 = Number(prompt("Enter number "));

Result = num1 + num2;


[Link]("<br>" + "sum = " + Result);
7. Selection
if (Result > 10)
if
{
[Link]("<br>" + Result + " is High Number");
}

</script>

</body>
</html>

<html>
<body>

<script>
num1 = Number(prompt("Enter number "));
num2 = Number(prompt("Enter number "));

Result = num1 + num2;


[Link]("<br>" + "Result = " + Result);

if (Result > 10)


8. { Selection
[Link]("<br>" + Result + " is High Number"); If .. else
}
else if (Result == 0)
[Link]("<br>" + Result + " is Normal Number ");
else
[Link]("<br>" + Result + " is Small Number ");

</script>

</body>
</html>

3
TT284 JavaScript
<html>
<body>

<script>

num1 = Number(prompt("Enter number "));


num2 = Number(prompt("Enter number "));

Result = num1 + num2;


[Link]("<br>" + "sum = " + Result);

if (Result > 10)


{
9. Selection
[Link]("<br>" + Result + " is High Number");
Nested
}
else if (Result == 0)
[Link]("<br>" + Result + " is Normal Number ");
else
[Link]("<br>" + Result + " is Small Number ");

</script>

</body>
</html>

<html>
<body>

<script>

num1 = Number(prompt("Enter number "));


num2 = Number(prompt("Enter number "));

if (num1 > 10 && num2< 5)


10. [Link]("<br>" + "It is normal numbers"); Selection
And
else
[Link]("<br>" + "It is not normal numbers");

</script>

</body>
</html>

4
TT284 JavaScript
<html>
<body>

<script>
num1 = Number(prompt("Enter number "));
num2 = Number(prompt("Enter number "));

if (num1 > 10 || num2< 5)


[Link]("<br>" + "It is normal numbers");
11. Selection
Or
else
[Link]("<br>" + "It is not normal numbers");

</script>

</body>
</html>

<html>
<body>

<script>

for (i=1;i<5;i++)
12. [Link]("<br>" + i);
Loop
</script>

</body>
</html>

<html>
<body>

<script>

for (i=1;i<3;i++)
13. for (j=1;j<2;j++) Loop
[Link]("<br>" + "TT284"); nested

</script>

</body>
</html>

5
TT284 JavaScript
<html>
<body>

<script>

function sum()
{
num1 = 10;
num2 = 5;
14.
sum = 0; Functions
sum = num1 + num2;
[Link]("sum = " , sum);
}
sum();

</script>

</body>
</html>
<html>
<body>

<script>

function sum(num1, num2)


{
sum = num1 + num2;
15. Functions
[Link]("sum = " , sum);
parameters
}
sum(10,5);

</script>

</body>
</html>

<html>
<head>
<script src="[Link]"> </script>
</head>
<body>
16. Functions
<script>Hello();</script>
Src
</body>
</html>
---------------------------------------------------------------
function Hello() {
[Link]("Hello AOU students"); }

6
TT284 JavaScript
<html>
<head>

<script src="[Link]"> </script>


</head>
<body>
<script>calc();</script>
</body>
</html>
17.
Example1
---------------------------------------------------------------

function calc()
{
num1 = Number(prompt("Enter number "));
num2 = Number(prompt("Enter number "));

Result = num1 + num2;


[Link]("<br>" + "Result = " + Result);
}
<html>
<head>

<script src="[Link]"> </script>


</head>
<body>

<script>

num1 = Number(prompt("Enter number "));


num2 = Number(prompt("Enter number "));

calc(num1,num2);
18.
Example2
</script>

</body>
</html>

---------------------------------------------------------------

function calc(x,y)
{

Result = x + y;
[Link]("<br>" + "Result = " + Result);
}

7
TT284 JavaScript
<html>
<head>

<script src="[Link]"> </script>


</head>
<body>
<script>
name = Number(prompt("Enter name "));
19.
welcome(name); Example3
</script>
</body>
</html>
---------------------------------------------------------------

function welcome(x)
{
[Link]("Welcome " + x);
}

You might also like