0% found this document useful (0 votes)
99 views7 pages

ICT Worksheet 1

The key difference between addProg#1 and addProg#2 is that addProg#1 prompts the user to enter numbers and directly calculates and displays the sum, while addProg#2 prompts for input, but also displays the individual values entered by the user in addition to the sum.

Uploaded by

kumi
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)
99 views7 pages

ICT Worksheet 1

The key difference between addProg#1 and addProg#2 is that addProg#1 prompts the user to enter numbers and directly calculates and displays the sum, while addProg#2 prompts for input, but also displays the individual values entered by the user in addition to the sum.

Uploaded by

kumi
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/ 7

Name: ​Date: / /2021

ICT-CBP Performance Task- Sheet: 


Pre-Activity:
~ ​Name the data types for JavaScript Language
A. Copy and Paste the source code in your text editor. Save it as
operatorSample.html. Find the element tag you need to remove to run the
html. Give the output in the provided box. (15pts)

<!DOCTYPE html>
<html>
<body>
<script type = "text/javascript">
/*
var a = 33;
var b = 10;
var linebreak = "<br />";

document.write("Value of a => (a = b) => ");


result = (a = b);
document.write(result);
document.write(linebreak);

document.write("Value of a => (a += b) => ");


result = (a += b);
document.write(result);
document.write(linebreak);
document.write("Value of a => (a -= b) => ");
result = (a -= b);
document.write(result);
document.write(linebreak);

document.write("Value of a => (a *= b) => ");


result = (a *= b);
document.write(result);
document.write(linebreak);

document.write("Value of a => (a /= b) => ");


result = (a /= b);
document.write(result);
document.write(linebreak);

document.write("Value of a => (a %= b) => ");


result = (a %= b);
document.write(result);
document.write(linebreak);
*/
</script>
<p>Set the variables to different values and different operators and then
try...</p>
</body>
</html>
Output:
B. Analyze the following source code. Give the function of the following: (5pts)
● prompt()
● parseFloat()
● parseInt()
● document.write()
● alert()
● <br>

C. Directions: (15pts)
1. Copy and paste the source code and save it as html file, with a file name
addProg#1​ .
2. Add a ​comment​ in each line to describe the function of each syntax.
3. Provide the complete ​output​ in the box provided.

<!DOCTYPE html>
<html>
<head>
<title>First Adding Program</title>
</head>
<body>
<script type="text/javascript">
var a
var b
var c
a=prompt("Please enter a number:",0)
b=prompt("Please enter another number:",0)
c=parseFloat(a) + parseFloat(b)
document.write("The sum is:",c)
</script>
</body>
</html>
Output:
D. Directions: (20)
1. Copy and paste the source code and save it as html file, with a file name
addProg#2​ .
2. Add a ​comment​ in each line to describe the function of each syntax.
3. Provide the complete ​output​ in the box provided.
4. Analyze the difference between ​addProg#1 & addProg#2​. Type your
answer in one paragraph.

<!DOCTYPE html>
<html>
<head>
<title>Adding Program</title>
</head>
<body>
<script type="text/javascript">
var a=0
var b=0
a=prompt("Please enter a number:",0)
b=prompt("Please enter another number:",0)
c=parseInt(a)+parseInt(b)
document.write("The first value:",a)
document.write("<br>The second value is:",b)
document.write("<br>The sum of the two values is:",c)
</script>
</body>
</html>
Output:

You might also like