You hand in this assignment by showing it to the lecturer when it is completed. This assignment contains some syntax errors you should correct and it works well when you can run it without an error message been displayed and the 10 randomly chosen numbers analyzed correctly.
Please refer to this page for information on how to work on your assignment.
Most of a web page is written in Hypertext Markup Language (HTML). But this page contains also some parts in JavaScript. Note that there is an other programming language with the name Java, but JavaScript shares with it just the name. These parts are mixed into the HTML page. In order to make it easier for you to learn to program with JavaScript, you receive almost ready programs. So you do not need to learn HTML.
Follow the link for an introduction to JavaScript.
This exercise is quite easy. Its main task is to teach you to find typing errors in a program, this process is called debugging. The given program has errors in seven lines and you should find and correct them all; some of the faulty statements are superfluous and can be deleted, others have to be corrected.
Your web browser provides help for finding JavaScript bugs. You have two browsers available in the lab: Mozilla Firefox 24 and Internet Explorer 7. We recommend you to choose Firefox, as it strongly adheres to web standards and its version is quite up-to-date, unlike Internet Explorer. However instructions are given for both.
Since 2013, Firefox is installed with a complete set of tools for web
development purposes. You can enable these tools it for a given page
from Tools
, Web Developer
, Toggle Tools
(or Ctrl+Shift+I on your keyboard). The main tool you will be using at
first is the Console
one. You can restrict the sources to only JS
by clicking (and disabling) the other tags (Net, CSS, Security, Logging).
Having done this, you should on the one hand edit the file with the text
of this page and on the other hand press the Reload Current Page
button of the browser to see the effect of what you are doing.
It also provides you with an inline JavaScript interpreter so you can type some code and immediately see the results.
These explanations have been verified for Internet Explorer version 7 only, upper versions might have a different layout and/or behaviour. You have to change the default settings:
Toolsand then to the last row
Internet Options.
Internet Optionspops up. Go to the
Advancedentry in the list of subwindows on the top.
Display a notification about every script errorbox (sixth box under the
Browsingentry).
OKin the lowest row to finish.
Having done this, you should on the one hand edit the file with the text
of this page and on the other hand press the refresh
or
reloading
button of the browser to see the effect of what you are
doing. Note that you should view the details of the announced JavaScript
errors to get the line numbers.
The corrected program computes the divisors of 10 randomly chosen numbers between 1 and 99 and then checks whether the chosen number is prime, square or having only one decimal digit. The number and the diagnosis about it are printed out.