Font size
WorksheetsIT tutor
Total questions: 18
Worksheet time: 15mins
Which modifier performs case-insensitive matching in regular expressions?
(a)
What does the regular expression pattern [0-9] match?
Any letter from a to z
Any digit from 0 to 9
Any special character
Any whitespace character
Which metacharacter matches a digit in regular expressions?
(a)
What does the quantifier n+ match?
Zero or more occurrences of n
Exactly one occurrence of n
At least one occurrence of n
Zero or one occurrence of n
JavaScript Methods and Objects
What does the test() method of RegExp return?
The matched text
The index of the match
true or false
A new string
What will "Hello world!".repeat(2) return?
"Hello world!Hello world!"
"Hello world!2"
"Hello world! Hello world!"
An Error
None of the Above
What does the exec() method return when no match is found?
false
0
null
undefined
Which variable declaration cannot be reassigned?
(a)
What does x <<= y do?
Left shifts x by y bits and assigns result to x
Right shifts x by y bits and assigns result to x
Multiplies x by y
Divides x by y
Which assignment operator is equivalent to x = x + y?
(a)
Which of the following is true about Arrays In Javascript
Can only store values of the same type
Has fixed length
Can store values of different types
Cannot contain other arrays
What is a multidimensional array?
An array with multiple data types
An array that contains other arrays
An array with more than 100 elements
An array with string keys
Create a variable that cannot be changed called x and assign the value 5 to it
(a)
How do you write a single-line comment in JavaScript?
/* comment */
// comment
<!-- comment -->
# comment
Which of these is NOT a valid JavaScript variable declaration?
var x = 5;
let x = 5;
const x = 5;
int x = 5;
const num1 = 5;
const num2 = 6;
num1 = 10;
let total = num1 + num2;
total should also be const
price1 cannot be reassigned
Missing semicolons after each line
let should be var
function showSlide(n) {
let slides = document.getElementsByClassName("mySlides");
for (let i = 0; i <= slides.length; i++) {
slides[i].style.display = "none";
}
}
Missing Array.from() to convert HTMLCollection to an iterable array
slides[i] will throw undefined in the last iteration due to i <= slides.length
<= causes an off-by-one error
display = "none" breaks accessibility
Make an empty array called people
(a)
