0% found this document useful (0 votes)
100 views1 page

0319 Wta T6

This document contains a tutorial on JavaScript control statements, including questions about variable naming, multiplication, and the writeln method. It provides code snippets with errors to identify and correct, involving if/else statements, while loops, and incrementing variables. The goal is to practice JavaScript control flow and debugging syntax errors in short code segments.

Uploaded by

wirdina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views1 page

0319 Wta T6

This document contains a tutorial on JavaScript control statements, including questions about variable naming, multiplication, and the writeln method. It provides code snippets with errors to identify and correct, involving if/else statements, while loops, and incrementing variables. The goal is to practice JavaScript control flow and debugging syntax errors in short code segments.

Uploaded by

wirdina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

15/05/2019 March 2019

BMIS 32152 – Web Techniques and Applications


Tutorial Lecture 7 – JS: Control Statement I

1. Which of the following is not a valid variable name? Why?


a. %ofTax
b. eightball_8
c. 12footage
d. pageNumber1200
2. Write four JavaScript statements that each multiply 1 to variable m, which contains a number.
3. In the following line, the word writeln performs a task or action in the script. What it is called?

document.writeln("Hello World");

4. Write a JavaScript statement to accomplish each of the following tasks:


a) Declare variables total and w.
b) Assign 1 to variable w.
c) Assign 0 to variable total.
d) Add variable w to variable total, and assign the result to variable total.
e) Print "The total is: ", followed by the value of variable total.
5. Identify and correct the errors in each of the following segments of code. [Note: There may be more than
one error in each piece of code; unless declarations are present, assume all variables are properly declared
and initialized.]
a. if ( age >= 65 );
document.writeln( "Age greater than or equal to 65" );
else document.writeln( "Age is less than 65" );
b. var x = 1, total;
while ( x <= 10 )
{ total += x; ++x; }
c. var x = 1; var total = 0;
While ( x <= 100 )
total += x; ++x;
d. var y = 5;
while (y> 0 )
{ document.writeln( y );
++y;

Submit your work after the class ends

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy