April 19, 2024

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.

 

Next page » Numbers

Previous page « Introduction to JavaScript

 

 

 

 

 

 

 

Up to top of page