This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

John McSweeney - picture detail

John McSweeney

February 5, 2012, 5:19 am

M150 Data, Computing and Information

JavaScript strings

 

This question tests the handling of string output, both to an alert box and to the browser.

Q1.
i)
a) Write code to output the following message in an alert box:
Here's some stuff about JavaScript
b) Write code to output the following message in a browser window:
Please note:
You do not require a dialogue box.

ii)
There are errors in the following code.

var aString;//declare a variable
aString = '"Help!"; /store a string in the variable
document.write('<EM> + aString + '</EM>, she cried.');

The code should output this line in a browser
"Help!", she cried.

Correct the code above accordingly.

Link to answer for Q1. Left click and a new window will open

 

Next page » Numbers

Previous page « Introduction to JavaScript