What is the difference between the 'break' and 'continue' statements in a loop?
'break' skips the current iteration, while 'continue' exits the loop entirely.
'break' and 'continue' both skip the current iteration.
'break' exits the loop entirely, while 'continue' skips the current iteration and continues with the next.
'break' and 'continue' both exit the loop entirely.
What is the purpose of the 'catch' block in a try...catch statement?
To re-throw the caught error
To handle the error thrown in the 'try' block
To specify the type of error to catch
To execute code only if an error doesn't occur
Which method is used to select an HTML element with a specific ID?
querySelectorAll()
querySelector()
getElementById()
getElementbyId()
What will the browser display after running this JavaScript code: alert('Hello') + ' World!'; ?
alert('Hello') + ' World!';
Hello
An error message
World!
Hello World!
Which block of code is executed regardless of whether an error is thrown or caught?
catch
throw
try
finally
Which data type represents a sequence of characters in JavaScript?
object
boolean
number
string
What value is returned by confirm('Are you sure?') if the user clicks the 'Cancel' button?
confirm('Are you sure?')
true
undefined
null
false
What is the correct way to add an element 'apple' to the end of the array fruits = ['banana', 'orange']?
fruits = ['banana', 'orange']
fruits = ['apple']
fruits.unshift('apple')
fruits[2] = 'apple'
fruits.push('apple')
What is the correct syntax to change the text content of an element with the ID 'myElement' to 'Hello World!'?
document.querySelector('#myElement').innerHTML = 'Hello World!';
document.querySelector('#myElement').textContent = 'Hello World!';
document.getElementById('myElement').textContent = 'Hello World!';
document.getElementById('myElement').innerText = 'Hello World!';
What does 'client-side' JavaScript refer to?
JavaScript code used for database management
JavaScript code used for server maintenance
JavaScript code executed on a web server
JavaScript code executed on the user's web browser