wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Do Now Lesson 2

Total questions: 15

Worksheet time: 10mins

Name
Class
Date
1.

Consider the following code snippet:

var myVar1 = "15"

var myVar1 = 15

What is the difference between myVar1 and myVar2?

a)

Scope

b)

Value

c)

No Difference

d)

Data Type

2.

Consider the following JavaScript codde snippet:

var counter = 0;

document.write(++counter);

document.write(++counter);

document.write(++counter);

What will be the result of this code snippet when run in the browser?

a)

000

b)

123

c)

012

d)

0++0++0++

3.

Which JavaScript operator indicates concatenantion?

a)

=

b)

+

c)

&&

d)

++

4.

Which of the following operators is an assignment operator?

a)

+=

b)

==

c)

%

d)

+

5.

Consider the following code snippet:

var age = 18'

var testValue = (age < 21) ? 'Teenager' : 'Adult';

What is the value of testValue in the given code snippet after execution.

a)

truet

b)

Teenager

c)

18

d)

21

6.

Which of the following methods lets you convey information to a user and doesn't record the user's response?

a)

prompt()

b)

open()

c)

confirm()

d)

alert()

7.

What is the value returned by the following expression?

(1 > 1) ? x : y

a)

false

b)

y

c)

True

d)

x

8.

consider the following code snippet:

var myVar;

myVar = confirm("continue?");

What is the data type of the value of myVar after execution?

a)

Depends on the user's input

b)

bit

c)

boolean

d)

undefined

9.

Consider the following JavaScript statement:

document.write(4/ 4 * 2 + 2 / 2);

What is the output of this statement?

a)

5

b)

1.5

c)

3

d)

2

10.

Which of the following operators is of the highest precedence?

a)

==

b)

>>

c)

++

d)

?:

11.

Which of the following data types is a non-primitive data type?

a)

null

b)

number

c)

array

d)

string

12.

Which of the following statement is true of JavaScript keywords and/or reserved words?

a)

all keyword are specific to particular versions of JavaScript

b)

You can use reserved words but not keywords as names for objects

c)

you can use reserved words as names for variables

d)

You cannot use reserved words as names for objects.

13.

What is the return type of the confirm() method

a)

Null

b)

Boolean

c)

String

d)

Integer

14.

Which of the following statments declares a variable whose value can't be altered throughout the script?

a)

const x = 5;

b)

var const = 5;

c)

const x; x = 10;

d)

let x = 10;

15.

Which of the following statements is true of the undefined data type?

Hint: This is the correction question. In JavaScript, any variable that is not assigned with any value has a default value of “undefined”

a)

It defines a value that does not exist

b)

It is the value taken by the variables that don't have any value assigned to them

c)

It is not similar to the null data type in any aspect

d)

It assigns a string value "undefined to the variable with data type ias undefined.