NEW
Font size
WorksheetsJavascript Part 2
Total questions: 70
Worksheet time: 36mins
Indicates the beginning and the end of a JavaScript section. / Indique le début et la fin d'une section JavaScript.
<html> </html>
<style> </style>
<article> </article>
<script> </script>
How can a developer show a pop-up message to the user on the browser window? / Comment un développeur peut-il afficher un message contextuel à l'utilisateur dans la fenêtre du navigateur?
alert
prompt
console.log
<p> tag
Which message will the user see? / Quel message l'utilisateur verra-t-il?
"Hello user"
No message / Pas de message
"Goodbye user"
"message + user"
Which of the following JavaScript methods are you most likely to use to activate a button? / Laquelle des méthodes JavaScript suivantes êtes-vous le plus susceptible d'utiliser pour activer un bouton?
onmouseover
onload
whenclick
onclick
What DOM Property is used to update the text of an HTML tag? / Quelle propriété DOM est utilisée pour mettre à jour le texte d'une balise HTML?
id
innerHTML
src
style
What is one key characteristic of an id? / Quelle est une caractéristique clé d'un identifiant?
It must be capitalized / Il doit être capitalisé
It must be unique to one tag / Il doit être unique à une balise
It cannot include numbers / Il ne peut pas inclure de chiffres
It must go in the closing tag / Il doit aller dans la balise de fermeture
Which of the following is the proper way to call the testFunction() function when a button is clicked? / Laquelle des propositions suivantes est la bonne façon d'appeler la fonction testFunction () lorsqu'un bouton est cliqué?
onclick=testFunction
when button clicked = "testFunction()"
onclick="testFunction()"
onclick="testFunction"
DOM get element by id is? / DOM get élément par id est?
Document.Getelementbyid()
document.getElementById()
Document.getElementByID()
DOM.getElmentById()
How are the objects organized in the HTML DOM?
Class-wise
Queue
Hierarchy
Stack
The paragraph P Tag is a part of_______
<body>
<html>
<h1>
both <body> <html>
The node directly above a node is called
sibling
child
parent
ancestral
The primary purpose of the array map() function is that it __________
maps the elements of another array into itself
passes each element of the array and returns the necessary mapped elements
passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function
pass the elements of the array into another array
Which syntax is used to describe elements in CSS?
Protectors
Selectors
Both Protectors and Selectors
Protectors or Selectors
Remove an item from the end of an array.
let cats = ['Bob', 'Willy', 'Mini'];
cats.pop();
['Bob','willy','Mini'];
['Bob','willy'];
['willy','Mini'];
['Bob','Mini'];
What is first index value of an array?
-1
0
1
undefine
What is the length of this array?
Which definition below best describe an array?
An array is a function identifier that can hold more than one parameter.
An array is a beam of light.
An array is a special variable, which can hold more than one value at a time.
An array is a special function, which can hold more than one value at a time.
What is proper syntax for declaring a array in JavaScript?
var arrayName =[ ];
var arrayName[ ] ={ };
array arrayName ={ };
obj var arrayName =[ ];
Which of the variables below is an array?
var names="array"
var names = array;
var names = [];
var names[];
What will be the output to the console for the following code:
var colors =["Red", "Green", "Yellow", "Orange", "Blue"];
colors.splice(0,3, "Purple");
console.log(colors);
["Purple", "Green", "Yellow"]
["Purple", "Green", "Yellow", "Orange", "Blue"]
["Red", "Green", "Yellow", "Orange", "Blue"]
["Purple", "Orange", "Blue"]
What is the highest position in this array?
HINT: Remember arrays start at position 0!
arr = [1,2,3,4,5];
What would the array look like after we execute this?:
array.splice(0, 1);
The length() method for an array will return _____.
the number of elements in the array
the last index value of the array.
the length of the name of the array variable
the capacity of the array
The push() method adds a new element to the end of an array
true
false
What is proper syntax for declaring a array in JavaScript?
var arrayName =[ ];
var arrayName[ ] ={ };
array arrayName ={ };
obj var arrayName =[ ];
The push() method append to the _______ of the array.
beginning
middle
end
none of the above
The pop() method removes the _______ element of the array.
beginning
middle
end
none of the above
The push() method adds a new element to the beginning of an array.
true
false
The shift() method removes the first array element and "shifts" all other elements to a lower index.
true
false
The unshift() method adds a new element to an array (at the beginning), and "unshifts" older elements.
true
false
The sort() method sorts in JavaScript will arrange an array alphabetically, but will not sort numbers in ascending or descending order.
true
false
The sort() method sorts in JavaScript will arrange an array alphabetically, and arrange numbers in ascending order.
true
false
What will be the output to the console for the following code?
["New York", "Texas", "New Mexico", "Arizona"]
["New York", "Texas", "New Mexico", "Arizona", "Washington"]
["Texas", "New Mexico", "Arizona", "Washington"]
["Arizona", "New Mexico", "New York", "Texas", "Washington"]
What will be the output to the console for the following code:
var colors =["Red", "Green", "Yellow", "Orange", "Blue"];
colors.splice(0,3, "Purple");
console.log(colors);
["Purple", "Green", "Yellow"]
["Purple", "Green", "Yellow", "Orange", "Blue"]
["Red", "Green", "Yellow", "Orange", "Blue"]
["Purple", "Orange", "Blue"]
What will be the output to the console for the following code:
var colors =["Red","Green","Yellow","Orange","Blue"];
colors.reverse();
console.log(colors);
["Blue", "Green", "Orange", "Red", "Yellow"]
["Blue", "Orange", "Yellow", "Green", "Red"]
["Red", "Green", "Purple", "Yellow", "Orange", "Blue"]
["Red", "Purple", "Green", "Yellow", "Orange", "Blue"]
What will be the output to the console for the following code:
var colors =["Red", "Green", "Yellow", "Orange", "Blue"];
colors.splice(1,0, "Purple");
console.log(colors);
[ "Orange", "Purple", "Green", "Yellow"]
["Green", "Purple", "Yellow", "Orange", "Blue"]
["Red", "Green", "Purple", "Yellow", "Orange", "Blue"]
["Red", "Purple", "Green", "Yellow", "Orange", "Blue"]
What will be the output to the console for the following code:
var colors =["Red","Green","Yellow","Orange"];
colors.shift();
console.log(colors);
["Red","Green","Yellow"]
["Yellow","Orange"]
["Green", "Yellow", "Orange"]
["Red","Green","Yellow","Orange"]
What will be the output to the console for the following code:
var colors =["Red","Green","Yellow","Orange","Blue","Amber"];
colors.sort();
console.log(colors);
["Red","Green","Yellow","Orange","Blue"]
["Amber", "Blue", "Green", "Orange", "Red", "Yellow"]
["Amber", "Blue", "Green", "Orange", "Red"]
["Red","Green","Yellow","Orange","Blue","Amber"]
What will be the output to the console for the following code:
var colors =["Red","Green","Yellow","Orange"];
console.log(colors.length);
5
3
4
2
What will be the output to the console for the following code:
var numbers =[100,125,137,16];
numbers.sort()
console.log(numbers);
[100, 125, 137, 16]
[16,100, 125, 137]
[16,100, 137, 8]
[8,16,100, 137]
What will be the output to the console for the following code:
var numbers =["100","125","137","16"];
numbers.pop()
console.log(numbers);
["100", "137", "16"]
["125","137","16"]
["100","125","137","16"]
["100", "125", "137"]
To display information to the screen and not to the console which command should you use?
console.log()
display.write()
document.write( )
print.screen()
Single or Double Quotations
This variable is a non numeric data that cannot be mathematically manipulated
boolean
date
time
string
Numeric data that consist of numbers that can be used in arithmetic and relational operators
string
array
integer
boolean
Answerable by true or false
array
date
string
boolean
/* */
comments
arithmetic operators
relational operators
conditional operators
What Javascript code matches this statement:
Their name is Kim and they are less than 16 years old
if (name = "Kim" && age < 16 )
if (name = "Kim" || age < 16 )
if (name === "Kim" && age < 16 )
if (name === "Kim" || age < 16 )
How many choices are possible when using a single if-else statement?
1
2
3
4
What Javascript code matches this statement:
The player's health is 0 and they still have a life remaining.
if (health == "0" && lives > "0")
if (health === 0 && lives >= 0)
if (health <1 && lives > 0)
if (health === 0 && lives > 0)
What Javascript code matches this statement:
The player has gathered at least 300 coins or reached the end of the level.
if ("coins" >= 300 && "end" == true)
if (coins >= 300 || end == true)
if ("coins" >= 300 OR "end" == true)
if ("coins" >= 300 || "end" == true)
What kind of statement is an If statement?
comparison statement
anecdotal statement
conditional statement
looping statement
What kind of operators do If statements use to test conditions?
comparison operators
arithmetic operators
array operators
bitwise operators
What happens when an If statements conditional is not true?
the if statement executes
Nothing happens
the if statement start over
all options are correct
What will be the output of the following JavaScript code?
if (10 > 5) {
var outcome = "if block";
}
outcome;
10
5
if block
none
What will be the output of the following JavaScript code?
if ("cat" === "dog") {
var outcome = "if block";
} else {
var outcome = "else block";
}
outcome;
if block
else block
both a And b
none
Which of these is not a type of loop in JavaScript?
while
for
do while
repeat
Which of these expressions is NOT a valid way to add 1 to a variable in JavaScript?
x++
x+=1
x=x+1
x+
