JavaScript Questions
Question 1
What will the output be from the following code segment?var result;var problem = 37 % 7;document.write("
The value of result is " + problem +".
");
A. The value of result is 7.
B. The value of result is 5.2.
C. The value of result is 35.
D. The value of result is 2.
Question 2
Which of the following uses correct syntax to receive a value stored in totalCost? The value is beingreturned by a function named grandTotal (which is of type double)into a variable nameddiscountValue.
A. discountValue=grandTotal;
B. discountValue = totalCost;
C. grandTotal(totalCost)=discount(value);
D. discountValue = grandTotal(totalcost);
Question 3
What is the value of returnValue after the following code has been executed?x = "150";y = "100";returnValue= x + y;
A. You cannot perform a mathematical operation on these values. An error message will be generated.
B. 150100
C. 250
D. 150
Question 4
When you assign a string value to a variable, you must enclose the text in quotation marks.
True
False
Question 5
Web pages are identified by a unique address called a:
A. Uniform Resource Locator
B. Uniform Response Locator
C. Universal Resource Locator
D. Uniform Resource Link
Question 6
Declaring a variable is the same as initializing a variable.
True
False
Question 7
What is the value of returnValue after the following code has been executed?x = "150";y = "100";returnValue= x - y;
A. 50
B. You cannot perform a mathematical operation on these values. An error message will be generated.
C. 150100
D. 150
Question 8
An object name that is followed by parentheses represents an array.
True
False
Question 9
What is the printed after the following code has been executed?var x(10);var i = 3;x(i) = 7;document.write("
The stored value is " + x(3) +".
");
A. 10
B. 3
C. 7
D. 13
Question 10
A(n) _____ statement is used by a function to return a value.
A. return
B. Assignment
C. Call
D. Pass
Question 11
Define and discuss three of the following Array methods:
•join
•slice
•shift and unshift
•pop
•concat
•sort.