WorksheetsJavascript Quiz 1
Total questions: 9
Worksheet time: 9mins
What range of numbers will the following print out?
console.log( Math.floor(Math.random() * 20) );
0 to 20
0.0 to 19.999999999
0 to 19
0.0 to 20.0
1 to 21
What range of numbers will the following print out?
console.log( Math.floor(Math.random() * 10) + 3 );
0 to 10
0.0 to 9.999999999
3 to 12
3.0 to 13.0
3 to 13
What will the following if statement print?
let x = 10;
if( x > 12 ) {
console.log("Pog");
}
else {
console.log("Squid");
}
Pog
Squid
Pog Squid
It will cause an error.
What will the following print out?
let age = 26;
if(age > 25) {
console.log("Hello");
}
if(age > 40) {
console.log("Boomer");
}
else {
console.log("Youngster");
}
}
Hello
Boomer
Hello
Boomer
Youngster
Hello
Youngster
What will the following print out?
console.log(30 == "30");
true
false
pog
It will cause an error.
uh...
choice = "2";
if(choice === 2) {
alert("Leet");
}
else {
console.log("Haxxor");
}
Leet
Haxxor
Leet
Haxxor
Neither prints out but no error occurs.
An error occurs.
What does the following print out?
let x = -25;
let y = 100;
if(Math.abs(x) > 0) {
console.log(x);
}
else if (y < 99) {
console.log(y);
}
-25
25
Nothing will be printed but it won't cause an error.
100
It will cause an error.
let score = 5;
if(score > 1) {
console.log("GG");
}
if(score < 10) {
console.log(" noob");
}
else {
console.log(" gamer");
}
noob
GG
gamer
GG
GG
noob
gamer
function myFun(stuff) {
console.log("stuff " + stuff);
}
myFun("a");
a
stuff a
stuff stuff
It will cause an error.
stuff
