What basic code is needed to define a function in JavaScript?
A. function myFunction { }
B. define myFunction() { }
C. function myFunction() { }
D. define myFunction { return value; }
Which statement will correctly call a JavaScript function without error?
A. var myFunction()
B. initiate myFunction()
C. call myFunction()
D. myFunction()
Consider the following code:
What is the expected result when you run this script in the browser?
A. There will be no visible output, but the script will count down to 0.
B. The script will output a countdown from 15 to 0 in the client window.
C. The script will output a countdown from 15 to 1 in the client window.
D. The script will output 15, then 1, because it will only write the first and last values of a while? statement.
Consider the following code:
Which statement could be used to determine the value of the first radio button?
A. document.rdoGroup1.value
B. document.myForm.rdoGroup1[0].value
C. document.getElementById(rdoGroup1).value
D. document.getElementById("rdoGroup1").value
Which choice best defines events and event handlers?
A. An event can be an action initiated by the user, and an event handler specifies how JavaScript will react to the action.
B. An event is an action initiated by the operating system, and an event handler is a function defined by the user.
C. An event handler can be an action initiated by the user, and an event specifies how JavaScript will react to the action.
D. An event is initiated by an error in JavaScript, and an event handler will attempt to bypass the error and continue.
You want to add a personalized interaction with your users when they enter your Web site. To do this, you can display a JavaScript prompt on the home page that asks the user to enter her name. When the user enters text and clicks the OK button, an alert dialog box will appear and display the text "Welcome, name" (where name is the text entered by the user). Which choice shows the correct JavaScript code for this action?
A. alert("Welcome, " + prompt("What is your name?", ""));
B. alert("Welcome, ") + prompt("What is your name?", "");
C. prompt("What is your name?", "") + alert("Welcome, ");
D. prompt("What is your name?", "" + alert("Welcome, "));
Consider the following code:
What is the expected result when you run this script in the browser?
A. A window alert box will display Hello.
B. A window alert box will display Goodbye.
C. No window alert box will appear because there is an error in the code.
D. A window alert box will display Hello then a second alert box will display Goodbye.
Consider the following code:
What output will appear in the browser when you run this script?
A. "1, 2, 3, 4, 5, 6, 7, 8, 9"
B. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
C. 1, 2, 3, 4, 5, 6, 7, 8, 9,
D. "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
Consider the following code:
When a user clicks on the displayed link, which site will he navigate to?
A. www.msn.com
B. www.yahoo.com
C. www.google.com
D. No other site, because there is a runtime error
Consider the following code using a checkbox object:
Which checkbox property was used by JavaScript?
A. checked
B. onclick()
C. checkThis
D. z-index