wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript-ITELECTIVE

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

These are used to put information that can be useful later, and in JavaScript these are ignored by the browser.

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

2.

Names that refer to commands, functions, variables and keyword should be written correctly, variable “A” and “a” are two different variables.

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

3.

It can be Numeric, String, Boolean or Null.

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

4.
To display writing on the screen you must include this direction;
a)
Document Write
b)
documentWrite
c)
document.write( )
d)
document.write
5.
An if/else statement;
a)
Expresses a true false statement
b)
can contain letters, numbers, spaces, and symbols.
c)
takes in an input, does something with it, and then returns an output.
d)
Runs a boolean (true/false) statement based on data entered
6.
What surrounds an if/else statement?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
7.
An array is;
a)
Shapes
b)
Sizes
c)
Options
d)
Lists of data
8.

A term where a block of code that can run later, and can be run many times.

a)

arguments

b)

select

c)

function

d)

value

9.

Which of the terms define as something that can happen on the webpage?

a)

type

b)

value

c)

trigger

d)

event

10.

To declare a JavaScript variable, you should NOT use?

a)

Let

b)

Var

c)

Const

d)

Int

11.

What is the output for this code?

a)

The value of z is z

b)

The value of z is 11

c)

The value of z is: 11

d)

The value of z is: x + y

12.

What is the value of x?

a)

3

b)

83

c)

80

d)

803

13.

Where JavaScript available in?

a)

Opera

b)

Microsoft Edge

c)

Microsoft Word

d)

Safari

14.

Inside which HTML element do we put the JavaScript

a)

<scripting>

b)

<script>

c)

<js>

d)

<javascript>

15.

How do you write "Hello World" in an alert box?

a)

msg("Hello World");

b)

alertBox("Hello World");

c)

alert("Hello World");

d)

msgBox("Hello World");

16.

If I want to change the mathematical expression from addition into division, what symbol should I use?

a)

/

b)

*

c)

-

d)

x

17.

JavaScript : What is the alert display for text3 ?

a)

John Doe

b)

JohnDoe

c)

"John" " " "Doe"

d)

"JohnDoe"

18.

JavaScript : What is the alert display for z?

a)

Hello5

b)

10

c)

55

d)

Hello15

19.
To display writing on the screen you must include this direction;
a)
Document Write
b)
documentWrite
c)
document.write( )
d)
document.write
20.
What surrounds a string?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
21.
A string;
a)
Expresses a true false statement
b)
can contain letters, numbers, spaces, and symbols.
c)
takes in an input, does something with it, and then returns an output.
d)
Runs a boolean (true/false) statement based on data entered
22.
A variable;
a)
Expresses a true false statement
b)
stores a string, number, or boolean, and gives it a specific, case-sensitive name
c)
takes in an input, does something with it, and then returns an output.
d)
Runs a boolean (true/false) statement based on data entered
23.
A boolean;
a)
Expresses a true false statement
b)
can contain letters, numbers, spaces, and symbols.
c)
takes in an input, does something with it, and then returns an output.
d)
Runs a boolean (true/false) statement based on data entered
24.
What surrounds an if/else statement?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
25.

This data type consist of a string of characters the create words, phases, sentences, etc.

a)

String

b)

int

c)

char

d)

float

26.

This programming concept allows programmers to create storage for data?

a)

Control Strucutures

b)

Variables

c)

Selection Structures

d)

Logic Operators

27.

This operator assigns values. It also looks like an equal sign.

a)

The boolean operator

b)

The selection structure

c)

The assignment operator

d)

The logic operator

28.

What kind of statement is an If statement?

a)

comparison statement

b)

anecdotal statement

c)

conditional statement

d)

looping statement

29.

What happens when an If statements conditional is not true?

a)

the if statement executes

b)

Nothing happens

c)

the if statement start over

d)

all options are correct

30.

What will be the output of the following JavaScript code?


if (10 > 5) {


var outcome = "if block";


}​


outcome;

a)

10

b)

5

c)

if block

d)

none

31.

Which of these is not a type of loop in JavaScript?

a)

while

b)

for

c)

do while

d)

repeat

32.

Which JavaScript event occurs when a user clicks on an HTML element?

a)

hover

b)

load

c)

click

d)

submit

33.

What will be the output of this code?

a)

Hi there
Goodbye

b)

Ciao!
Goodbye

c)

Ciao!
ReferenceError: wariable not defined.

34.

What will be printed to the console?

a)

This fruit is delicious!

b)

This is delicious!

c)

This apple is delicious!

d)

This undefined is delicious!

35.

Which of the following expressions can be used to select the element with the HTML attribute id="first"?

a)

document.getElementById('first')

b)

document.querySelector('first')

36.
a)

Changes the text color of the element with ID "myElement" to red.

b)

Changes the background color of the element with ID "myElement" to red.

c)

Appends the text "red" to the element with ID "myElement".

d)

Selects the first element with the class "myElement" and changes its text color to red.

37.

How can you attach a click event listener to a button with the id "myButton" using JavaScript?

a)

querySelector("#myButton").addEventListener("click", myFunction);

b)

getElementById("myButton").addEventListener("click", myFunction);

c)

querySelector(".myButton").addEventListener("click", myFunction);

d)

getElementsByTagName("myButton")[0].addEventListener("click", myFunction);

38.

What does the innerHTML property do in JavaScript when used with an HTML element?

a)

Retrieves or sets the content of an element, including HTML markup.

b)

Retrieves or sets the value of an element's attribute.

c)

Adds a new element inside the target element.

d)

Removes the target element from the DOM.

39.

If I click on the button 3 times, the message "Button Clicked" will be shown :

a)

1 time

b)

2 times

c)

3 times

d)

0 times

40.

True or False

The '===' operator checks for both value and type equality.

a)

True

b)

False

41.

True or False

Arrays in JavaScript are zero-indexed.

a)

True

b)

False

42.

Predict the output of the following JavaScript code snippets.

a)

8

b)

Error

c)

35

d)

"35"

43.

 Which of these is not a valid JavaScript loop?


a)

for

b)

while

c)

do...while

d)

repeat...until

44.

A (a)   is a reusable piece of code that performs a specific task.

45.

What is the output of: console.log(3 > 2 > 1)?

a)

true

b)

false

c)

undefined

d)

Error

46.

Which of the following is not a valid way to declare a variable in JavaScript?

a)

var x =5;

b)

let y = 10;

c)

const z = 15;

d)

int w = 20;

47.

What is the output of: console.log(1 + "2" + "2")?

a)

"14"

b)

"122"

c)

5

d)

"32"

48.

Predict the output of the following JavaScript code snippets.

a)

10

b)

Error

c)

11

d)

0

49.

Find and fix the error(s) in the following JavaScript code snippets.


a)

b)

c)

d)

50.

Debug this code: Select the correct answer

a)

b)

c)

d)