Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) If you pass the values 100 and .00224 to the calculateTax function, what valu

ID: 3638098 • Letter: 1

Question


1) If you pass the values 100 and .00224 to the calculateTax function,
what value will be returned?

var calculateTax = function ( subtotal, taxRate )
{
var tax = subtotal * taxRate;
tax = parseFloat( tax.toFixed(2) );
return tax;
}
Choose one answer.
a. .224
b. 2.24
c. .22
d. .23


2) In the code that follows, document is a/an ____________________________.

document.getElementById("emailAddress");

3) When will the code for the third function run?
var $ = function ( id )
{
return document.getElementById( id );
}

var display_name_click = function ()
{
$("name_text_box").value = "Mike";
}

window.onload = function ()
{
$("display_button").onclick = display_name_click;
}
Choose one answer.
a. When the name is displayed.
b. When the user clicks on the button.
c. As the page is loaded in the browser.
d. After the page is loaded in the browser.

4) After the statement that follows is executed, rateText contains
var rateText = document.getElementById("rate");
Choose one answer.
a. the string that was entered in the XHTML element with "rate" as its id
b. a reference to the XHTML element with "rate" as its id
c. the value that was entered in the XHTML element with "rate" as its id
d. the XHTML element with "rate" as its id

5) When you declare a variable and assign a string expression to it, a/an _______________________ is created.

6) If you split a JavaScript statement over two lines in the wrong place, JavaScript will put a/an ______________________ at the end of the first line, and that will sometimes cause an error.

7) In a simple assignment statement, you use the ______________ operator.

8) Assuming the web page for this script has a text field with an id attribute of name_text_box and a button with an id attribute of display_button, what will happen when the user clicks the button?
var $ = function ( id )
{
return document.getElementById( id );
}

var display_name_click = function ()
{
$("name_text_box").value = "Mike";
}

window.onload = function ()
{
$("display_button").onclick = display_name_click;
}
Choose one answer.
a. The application will display "Mike" in a dialog box.
b. The application will display "Mike" in the text field named name_text_box.
c. The application will display "Mike" in the button named display_button.
d. The application won't display anything.

9) After the if statement that follows is executed, what will the value of discountAmount be?

var discountAmount;
var orderTotal = 200;

if (orderTotal > 200)
{
discountAmount = orderTotal * .3;
}
else if (orderTotal > 100)
{
discountAmount = orderTotal * .2;
}
else
{
discountAmount = orderTotal * .1;
}
Choose one answer.
a. 0.0
b. 20.0
c. 40.0
d. 60.0


10) If an arithmetic expression isn't evaluated the way you want it to be due to the order of precedence, you can override that order by using ____________________.

After the statements that follow are executed, guest contains
var guest = "Ray Harris";
var quest = guest.substr(0,3).toUpperCase();
Choose one answer.
a. "Ray Harris"
b. "RAY Harris"
c. "Ray"
d. "RAY"

11) When you call a function that returns a value, you usually ________________ the result of the function to a variable.

12) An identifier in JavaScript cannot contain ___________________ words.

13) In a web browser, the ____________________ object is the object that's always available to JavaScript so you don't have to code its name when you call one of its methods.

14) If you want to store a true or false value in a variable, you use the __________________ data type.

15) If possible, the parseInt method converts the string that's passed to it to a/an _____________________________.

16) You can use the event handler for the __________________ event of the web page to assign event handlers to the click event of a button.

17) What will futureValue contain after the for loop has been executed one time?

var years = 10;
var annualRate = 10;
var futureValue = 1000;

annualRate = annualRate / 100;

for ( i = 1; i <= years; i++ )
{
futureValue = futureValue * (1 + annualRate);
}
Choose one answer.
a. 1000
b. 1100
c. 11000
d. 1010

Explanation / Answer

1) b.2.24 2)Get admin username 3)b. When the user clicks on the button. 4)c. the value that was entered in the XHTML element with "rate" as its id 5)String variable assignment 6) JavaScript will not realize that the string 7) variable 8)d. The application won't display anything. 9)c. 40.0 10)b. "RAY Harris" c. 11000