wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

#100 Devs - LwL - class 15

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What are variables?

a)

They are ways to store data in the computer memory

b)

Data Buckets

c)

Boxes

d)

All are correct

2.

How to declare and assign values to variables?

a)

let variableName = "this is a string"

b)

variableName = "this is a string"

3.

Ways to assign values to a string type of variable?

a)

single quote', "double quote", or `backticks`

b)

single quote', "double quote"

4.

What is the difference between === and ==

a)

Three equal signs compares type and value, and two equal signs compares only value

b)

Three equal signs compares only value, and two equal signs compares type and value

5.

const age = 17

if (age >= 18){

console.log("you can get in")

} else if (age > 16) {

console.log("you're not quite ready")

}else {

console.log("You're too young")

}

What will this code return?

a)

"you're not quite ready"

b)

"you can get in"

c)

"You're too young"

6.

const fishSpecies = "clownfish"

const inhabitat = "anemone"


if (fishSpecies === "clownfish" && inhabitat === "anemone"){

console.log("welcome home, nemo")

} else{

console.log("only clownfish is allowed in the anemone")

}

What will this return?

a)

"welcome home, nemo"

b)

"only clownfish is allowed in the anemone"

7.

if (name === "leon" && hair ==="gorgeous"{ //run code } What must be true so the code runs?

a)

name must be Leon and hair must be gorgeous

b)

Either name must be Leon or hair must be gorgeous

8.

What are functions?

a)

They are sets of instructions, that can be reused whenever called/run

b)

They are instructions to be used once

9.

function add(??, ???){

// function body

}

a)

parameters

b)

arguments

10.

add( ??, ???)

a)

arguments

b)

parameters

11.

What are truthy values?

a)

Truthy values are evaluated as true in a boolean context.

if (2) {

//do something - will always execute because number 2, when evaluated, will be true just for existing

}

b)

Truthy values are values that can be evaluated as true or false in a boolean context.

if (0) {

//do something

}

12.

What values are always evaluated as falsy?

a)

false, 0,"", null, undefined, and NaN

b)

false, null, undefined, and NaN

13.

What is the structure of a for loop?

a)

for(let i = 0; i < 5; i++) {

//do something with i

}

b)

for (i = 0, i++, i < 5){

//do something with i

}

c)

let i = 0

while (i < 5){

//do something with i

i++

}

14.

When should you choose a while loop instead of a for loop?

a)

When you don't know exactly when you reach the end condition

b)

When you know exactly when to end the loop

15.

What is an array?

a)

It is a way to organize multiple "things" in JS using a single structure

b)

It is a named indexed structure in JS, as in "name" : "Leon Noel"

16.

How to declare an array with literal notation?

a)

let leonsArray = [ ]

b)

let leonsArray = new Array()

17.

How to store the first element from an array in a variable?

a)

let firstElement = array[0]

b)

let firstElement = array[1]

18.

How to figure out the length of an array?

a)

leonsArray.length

b)

leonsArray.length()

19.

let leonsArray = [1,2,3,4]

How to console.log the last element of an array?

a)

leonsArray[leonsArray.length-1]

b)

leonsArray[4]

20.

let leonsArray = [1,2,3,4]

what will console.log(leonsArray[5]) return?

a)

undefined

b)

5

c)

""

21.

let leonsArray = [1,2,3,4]

How can we redefine the second element of the array to 7?

a)

leonsArray[1] = 7

b)

leonsArray[2] = 7

22.

let leonsArray = [1,2,3,4]

How can we element in the first index of the array to 7?

a)

leonsArray[0] =7

b)

leonsArray[1] = 7

23.

let leonsArray = [1,2,3,4]

What will


for( i = 0; i < leonsArray.length; i++){

console.log(leonsArray[i]+3)

}


do?

a)

It will log every single element added by 3 on the console

b)

It will log every array index added by 3 on the console

c)

It will log every element and index added by 3 on the console

24.

let leonsArray = [1,2,3,4]

What will


leonsArray.forEach(element => {

console.log(element)

})


do?

a)

It will log each element of the array: 1, 2, 3 and 4

b)

It will log the indexes of the array: 1, 2, 3, 4

25.

This is a trick question:


let leonsArray = [1,2,3,4]

leonsArray.forEach(element => {

element + 3

})


What will console.log(leonsArray) return?

a)

[1,2,3,4]

Do you know why? If not, MDN array forEach

b)

[4,5,6,7]

Do you know why? If not, MDN array forEach