WorksheetsChapter 6 : JavaScript Functions & Input/ Output
Total questions: 12
Worksheet time: 7mins
Which of these are correct methods to create a function?
function myFunction {
// Some code }
function myFunction[] {
// Some code }
function myFunction() {
// Some code }
function myFunction(x, y, z) {
// Some code }
Given the following code, which is considered the parameters of the function
function myFunction(a, b, c) {
var x = a + b + c;
}
x
a
b
c
Given the following code, what is the final value of x?
var x = 0;
function myXFunction() {
x = x + 10;
}
x = x + 1;
11
0
10
1
What should go into the indicated location make the final value of x = 11?
var x = 0;
function myXFunction() {
x = x + 10;
}
WRITE CODE HERE
x = x + 1;
function myXFunction()
MYXFUNCTION()
myXFunction()
myxfunction()
What will the final value of x be?
var x = 0;
function myXFunction() {
return 10;
}
x = x + 1;
x = myXFunction();
11
0
10
1
Given the following function.
function myFunction () {
//Some Code }
Which of the code below will allow the following button to invoke myFunction?
<input type="button" id="mybutton" value="Click Me"/>
var h = document.getElementById(“mybutton”); h.addEventListener(“click”, myFunction);
var h = document.getElementById(“mybutton”);
h.onclick(myFunction);
document.getElementById(“mybutton”).addEventListener(“click”, myFunction);
document.getElementById(“mybutton”).onclick(myFunction);
Fill in the blanks to allow the following button invoke the myFunction function when clicked
<button id="myButton" value="Click Me" (a) />
function myFunction() {
//Some Code }
Which of the following code will allow the button to invoke hisFunction?
<button id="myButton" value="Click Me" ________ />
function hisFunction(X, Y) {
//Some Code }
onclick = "hisFunction()"
onclick = "hisFunction"
onclick = "hisFunction(1)"
onclick = "hisFunction(1, 2)"
Which of this dialog boxes allows the user to verify or accept something?
alert()
confirm()
prompt()
What code will result in the above?
alert("Please enter your phone number:")
confirm("Please enter your phone number:")
prompt("Please enter your phone number:")
In which one of these lines of code is A, B and C considered arguments?
function myFunction(A, B, C) { ... }
function myFunction() {
var A; var B; var C; }
myFunction(A, B, C);
var x = function(A, B, C) { ... };
Identify the parameter in the following code:
function First(Second) {
var Third = 0;
}
First(Fourth);
First
Second
Third
Fourth
