wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Script Certification Functions, Debugging & Loops

Total questions: 20

Worksheet time: 19mins

Name
Class
Date
1.

Which JavaScript statement should you use to test for a single condition and branch to a process?

a)

for

b)

while

c)

if...else

d)

if

2.

Which of the following statements is true of control structures?

a)

They are methods that return at least one value.

b)

They are used in code to avoid program errors.

c)

They are exclusive to JavaScript.

d)

They make decisions based on Boolean values.

3.

Which code will display an alert if the variable timerMinutes has a value 10?

a)

if ("timerMinutes" = 10) {   alert("Time Expired!"); }

b)

if ("timerMinutes" == 10); {   alert("Time Expired!"); }

c)

if ("timerMinutes" = 10) alert("Time Expired!");

d)

if (timerMinutes == 10) alert("Time Expired!");

4.

What is the purpose of the switch statement?

a)

To force the flow of control back to the top of a loop

b)

To exit a loop that would otherwise continue to execute

c)

To repeat a group of statements for some particular range of values

d)

To compare a value against other values, to search for a match

5.

Which JavaScript statement is used to force the flow of control back to the top of a loop?

a)

while

b)

for

c)

continue

d)

break

6.

Consider the following code snippet:

var x = 100; while (x > 5) { x--; }

What will be the value of x after the execution of the given code snippet?

a)

4

b)

5

c)

100

d)

6

7.

Which type of statement provides a way to exit a loop that would otherwise continue to execute?

a)

break

b)

continue

c)

for

d)

while

8.

What is casting in JavaScript?

a)

Declaring all variables and creating all objects before programming procedures

b)

Changing a variable from one data type to another

c)

Repairing corrupted user input

d)

Creating functions molded to pre-defined algorithms

9.

What is an argument in JavaScript?

a)

A value passed into a function from outside the function

b)

A statement that transfers program execution to a subroutine

c)

A named block of code that can be called

d)

Any method that returns a value

10.

How does a global variable differ from a local variable?

a)

You can access a local variable value from any function or <script> block that you define on the HTML page.

b)

You declare a global variable within a function.

c)

You declare a local variable outside any function.

d)

You can access a global variable value from any function or <script> block that you define on the HTML page.

11.

Which code snippet demonstrates the correct syntax for a user-defined JavaScript function my_function?

a)

function my_function() [

alert("test function");

alert(username);

]

b)

function my_function [] {

alert("test function");

}

c)

function my_function() {

alert("test function");

}

d)

function my_function()

alert("test function");

}

12.

Consider the following JavaScript function:

function myFunction(x) { //Insert Code Here }

Which code statement should be added to the function to return to the value of x multiplied by 2 to the calling statement?

a)

x * 2

b)

myFunction = x * 2

c)

x = x * 2

d)

return x * 2

13.

Which of the following functions is created at runtime and declared without a name?

a)

Closure

b)

Anonymous

c)

Prototype

d)

None of these

14.

Which type of error causes no error alert in the browser?

a)

Logic

b)

Run Time

c)

Load Time

d)

Intepreter

15.

Which type of error occurs after the script has loaded and is running?

a)

Logic

b)

Load Time

c)

Run Time

d)

Interpreter

16.

Why is it generally easier to debug run-time and load-time errors than to debug logic errors?

a)

Because logic errors cause error alerts

b)

Because syntax errors are rarely caught by debugging tools

c)

Because run-time and load-time errors prevent the script from rendering at all

d)

Because logic errors are rarely caught by debugging tools

17.

Which type of error is typically a syntax error?

a)

Mathematical

b)

Load Time

c)

Run Time

d)

Logic

18.

You should always test your script on as many browsers as possible and use as many resolutions as feasible. But at a minimum, you should test your Webpages:

a)

On Internet Explorer, Firefox, Chrome, and Safari.

b)

On Firefox

c)

On Chrome and Safari

d)

On Edge, Firefox and Chrome

19.

Which of the following requires additional testing of the code and also helps to develop customized pages for different display sizes and methods of interaction?

a)

Browser Version

b)

Mobile Version

c)

Mobile Device

d)

Monitor Resolution

20.

In programming, what term is used for the process of troubleshooting and repairing code that does not work properly?

a)

Compiling

b)

Interpreter

c)

Debugging

d)

Testing