Font size
WorksheetsJavaScript-ITELECTIVE
Total questions: 50
Worksheet time: 25mins
These are used to put information that can be useful later, and in JavaScript these are ignored by the browser.
Comments
Case Sensitivity
Data Types
Statements
Names that refer to commands, functions, variables and keyword should be written correctly, variable “A” and “a” are two different variables.
Comments
Case Sensitivity
Data Types
Statements
It can be Numeric, String, Boolean or Null.
Comments
Case Sensitivity
Data Types
Statements
A term where a block of code that can run later, and can be run many times.
arguments
select
function
value
Which of the terms define as something that can happen on the webpage?
type
value
trigger
event
To declare a JavaScript variable, you should NOT use?
Let
Var
Const
Int
What is the output for this code?
The value of z is z
The value of z is 11
The value of z is: 11
The value of z is: x + y
What is the value of x?
3
83
80
803
Where JavaScript available in?
Opera
Microsoft Edge
Microsoft Word
Safari
Inside which HTML element do we put the JavaScript
<scripting>
<script>
<js>
<javascript>
How do you write "Hello World" in an alert box?
msg("Hello World");
alertBox("Hello World");
alert("Hello World");
msgBox("Hello World");
If I want to change the mathematical expression from addition into division, what symbol should I use?
/
*
-
x
JavaScript : What is the alert display for text3 ?
John Doe
JohnDoe
"John" " " "Doe"
"JohnDoe"
JavaScript : What is the alert display for z?
Hello5
10
55
Hello15
This data type consist of a string of characters the create words, phases, sentences, etc.
String
int
char
float
This programming concept allows programmers to create storage for data?
Control Strucutures
Variables
Selection Structures
Logic Operators
This operator assigns values. It also looks like an equal sign.
The boolean operator
The selection structure
The assignment operator
The logic operator
What kind of statement is an If statement?
comparison statement
anecdotal statement
conditional statement
looping statement
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
Which of these is not a type of loop in JavaScript?
while
for
do while
repeat
Which JavaScript event occurs when a user clicks on an HTML element?
hover
load
click
submit
What will be the output of this code?
Hi there
Goodbye
Ciao!
Goodbye
Ciao!
ReferenceError: wariable not defined.
What will be printed to the console?
This fruit is delicious!
This is delicious!
This apple is delicious!
This undefined is delicious!
Which of the following expressions can be used to select the element with the HTML attribute id="first"?
document.getElementById('first')
document.querySelector('first')
Changes the text color of the element with ID "myElement" to red.
Changes the background color of the element with ID "myElement" to red.
Appends the text "red" to the element with ID "myElement".
Selects the first element with the class "myElement" and changes its text color to red.
How can you attach a click event listener to a button with the id "myButton" using JavaScript?
querySelector("#myButton").addEventListener("click", myFunction);
getElementById("myButton").addEventListener("click", myFunction);
querySelector(".myButton").addEventListener("click", myFunction);
getElementsByTagName("myButton")[0].addEventListener("click", myFunction);
What does the innerHTML property do in JavaScript when used with an HTML element?
Retrieves or sets the content of an element, including HTML markup.
Retrieves or sets the value of an element's attribute.
Adds a new element inside the target element.
Removes the target element from the DOM.
If I click on the button 3 times, the message "Button Clicked" will be shown :
1 time
2 times
3 times
0 times
True or False
The '===' operator checks for both value and type equality.
True
False
True or False
Arrays in JavaScript are zero-indexed.
True
False
Predict the output of the following JavaScript code snippets.
8
Error
35
"35"
Which of these is not a valid JavaScript loop?
for
while
do...while
repeat...until
A (a) is a reusable piece of code that performs a specific task.
What is the output of: console.log(3 > 2 > 1)?
true
false
undefined
Error
Which of the following is not a valid way to declare a variable in JavaScript?
var x =5;
let y = 10;
const z = 15;
int w = 20;
What is the output of: console.log(1 + "2" + "2")?
"14"
"122"
5
"32"
Predict the output of the following JavaScript code snippets.
10
Error
11
0
Find and fix the error(s) in the following JavaScript code snippets.
Debug this code: Select the correct answer
