NEW
Font size
WorksheetsJavascript/DOM
Total questions: 30
Worksheet time: 19mins
What will this code display?
8, 2, 1, 4, 7
82147
Myarray.length
5
What will this code display?
Hello Emma
Hello user
Hello+user
nothing
What will this code display?
570
569
568
attendees
What would this piece of code do?
change the background color of the word demo to red
change the font color of the demo element to red
this is not correct
styles the element with the class demo
Which of these is a method?
getElementById( )
style
document
color
Which line is missing to return the result of the multiplication 10 x 5 ?
result
number 1 * number 2 ;
let result = 10 x 5 ;
var result = number 1 * number 2 ;
Correct this code so that
Hello!
is displayed in the paragraph
with the id "demo"
add
.style.text
after ("demo")
add
.innerHTML
after ("demo")
add a semi colon after myFunction()
Save "Hello" in a variable first
What would this piece of code display?
false
x!=8
true
8
Which of these methods removes the last element of an array?
pop( )
splice( );
push( )
split( )
What would this piece of code display?
text
John, Joe, Greg, Ruth
John
Joe
Greg
Ruth
4
What will this code do?
document.getElementById("demo").style.color = "blue";
Change the text color of the element with id "demo" to blue
Change the background color of the element with id "demo" to blue
Remove the element with id "demo"
Display an error
Which method would you use to add a new element to the end of an array?
unshift( )
shift( )
pop( )
push( )
Which of these is a valid way to declare a variable in JavaScript?
var myVar
let myVar = ;
const myVar = 5
myVar = 5
Which function is used to convert a string to a number in JavaScript?
parseInt( )
String( )
toString( )
Number( )
What does the following code do?
console.log(typeof 42);
Returns the type of 42
Throws an error
Logs 42 to the console
Logs the type of 42 to the console
Which operator is used to concatenate two strings in JavaScript?
-
+
*
/
What will this code return?
Math.max(1, 2, 3);
2
1
3
undefined
Which of these is a valid way to create a function in JavaScript?
function:myFunction() {}
myFunction() {}
myFunction() => {}
function myFunction() {}
What is the output of the following code?
javascript
console.log(typeof null);
"object"
"null"
"undefined"
"boolean"
let a = [1, 2, 3];
a[10] = 99;
console.log(a.length);
3
10
11
error
console.log([] + []);
[]
undefined
"[]"
"" (empty string)
var x = 10;
(function() {
console.log(x);
var x = 20;
})();
10
20
undefined
error
console.log([] == false);
true
false
NaN
undefined
let a = 1;
a++;
console.log(a++);
1
2
3
undefined
What will this code display?
121
123
321
error
What will this code display?
Alex likes reading, Alex likes cycling
undefined likes reading, undefined likes cycling
error
Nothing is logged
What will this code display?
Name: Guest, Age: 25 ... Name: Taylor, Age: 25 ... Name: Guest, Age: 30
Error
Name: Taylor, Age: undefined ... etc
Name: undefined, Age: undefined ... etc
What will this code display?
ext, null, text
text, null, 0
0, text, null
text, null, null
console.log(1 + 2 + "3" + 4 + 5);
12345
"3345"
"3345" (as a string)
"345"
What will be the result when the button is clicked?
The page shows the text Updated in normal font style
The heading text is replaced with italicized “Updated”
Nothing happens when the button is clicked
A new heading is added below the existing one
