NEW
Font size
WorksheetsJava Script Certification Functions, Debugging & Loops
Total questions: 20
Worksheet time: 19mins
Which JavaScript statement should you use to test for a single condition and branch to a process?
for
while
if...else
if
Which of the following statements is true of control structures?
They are methods that return at least one value.
They are used in code to avoid program errors.
They are exclusive to JavaScript.
They make decisions based on Boolean values.
Which code will display an alert if the variable timerMinutes has a value 10?
if ("timerMinutes" = 10) { alert("Time Expired!"); }
if ("timerMinutes" == 10); { alert("Time Expired!"); }
if ("timerMinutes" = 10) alert("Time Expired!");
if (timerMinutes == 10) alert("Time Expired!");
What is the purpose of the switch statement?
To force the flow of control back to the top of a loop
To exit a loop that would otherwise continue to execute
To repeat a group of statements for some particular range of values
To compare a value against other values, to search for a match
Which JavaScript statement is used to force the flow of control back to the top of a loop?
while
for
continue
break
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?
4
5
100
6
Which type of statement provides a way to exit a loop that would otherwise continue to execute?
break
continue
for
while
What is casting in JavaScript?
Declaring all variables and creating all objects before programming procedures
Changing a variable from one data type to another
Repairing corrupted user input
Creating functions molded to pre-defined algorithms
What is an argument in JavaScript?
A value passed into a function from outside the function
A statement that transfers program execution to a subroutine
A named block of code that can be called
Any method that returns a value
How does a global variable differ from a local variable?
You can access a local variable value from any function or <script> block that you define on the HTML page.
You declare a global variable within a function.
You declare a local variable outside any function.
You can access a global variable value from any function or <script> block that you define on the HTML page.
Which code snippet demonstrates the correct syntax for a user-defined JavaScript function my_function?
function my_function() [
alert("test function");
alert(username);
]
function my_function [] {
alert("test function");
}
function my_function() {
alert("test function");
}
function my_function()
alert("test function");
}
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?
x * 2
myFunction = x * 2
x = x * 2
return x * 2
Which of the following functions is created at runtime and declared without a name?
Closure
Anonymous
Prototype
None of these
Which type of error causes no error alert in the browser?
Logic
Run Time
Load Time
Intepreter
Which type of error occurs after the script has loaded and is running?
Logic
Load Time
Run Time
Interpreter
Why is it generally easier to debug run-time and load-time errors than to debug logic errors?
Because logic errors cause error alerts
Because syntax errors are rarely caught by debugging tools
Because run-time and load-time errors prevent the script from rendering at all
Because logic errors are rarely caught by debugging tools
Which type of error is typically a syntax error?
Mathematical
Load Time
Run Time
Logic
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:
On Internet Explorer, Firefox, Chrome, and Safari.
On Firefox
On Chrome and Safari
On Edge, Firefox and Chrome
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?
Browser Version
Mobile Version
Mobile Device
Monitor Resolution
In programming, what term is used for the process of troubleshooting and repairing code that does not work properly?
Compiling
Interpreter
Debugging
Testing
