Professional Documents
Culture Documents
To enrich your learning experience at Boston even further, and to ensure that you are exposed to a
variety of resources in this module, announcements will be posted every week containing additional
It is important to note that these activities are neither compulsory nor weighted, but that it will be to your
advantage to participate. The purpose of the activities is to help you better understand the content of
your weekly unit/s of study, and it will assist in creating insight and deeper meaning.
This activity is based on Chapter 13 to Chapter 15 of the prescribed courseware for this module.
Question 1
In very simple terms, explain the use of JavaScript in developing web content.
Suggested solution:
JavaScript is a client-side scripting language that enables you to create dynamically updating content,
control multimedia, animate images, and pretty much everything else. The core client-side JavaScript
language consists of some common programming features that allow you to do things such as the
following:
1 HSYD300-1-Jan-June2022-T&L-StM-W7-Memo-V1-23032022
Question 2
Use the JavaScript if… statement to determine if a person qualifies to drive a vehicle on public roads.
In your code, put the age of 20 as input and use that to test if at that age, a person qualifies for driving.
Assume that the legal age for driving is over 16 years.
Suggested solution:
<html>
<body>
<script type = "text/javascript">
<!--
var age = 20;
</body>
</html>
Suggested solution:
The program delivers no output because the selection condition is not satisfied when the age is below
16 years. The refactored program is:
<html>
<body>
<script type = "text/javascript">
<!--
var age = 15;
2 HSYD300-1-Jan-June2022-T&L-StM-W7-Memo-V1-23032022
document.write("<b>Qualifies for driving</b>");
} else {
document.write("<b>Does not qualify for driving</b>");
}
//-->
</script>
<p>Set the variable to different value and then try...</p>
</body>
</html>
4.1 A Function?
Suggested solution:
A function is a subprogram designed to perform a particular task. Functions are executed when they
are called. This is known as invoking a function. Values can be passed into functions and used
within the function.
Functions are objects.
Functions always return a value. In JavaScript, if no return value is specified, the function will return
undefined.
4.2 A Function Declaration
Suggested solution:
A Function Declaration defines a named function. The function keyword followed by the name of the
function is used to create a function declaration. The general form of a function declaration is:
function name(parameters)
{
statements
}
4.3 A Function Expression
Suggested solution:
A Function Expressions defines a function. Unlike function declarations, a function Expression
cannot be used before they are defined.
3 HSYD300-1-Jan-June2022-T&L-StM-W7-Memo-V1-23032022