wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS - Knowledge Check

Total questions: 14

Worksheet time: 31mins

Name
Class
Date
1.

Create a variable called carName, assign the value Volvo to it.

let ________ = "________"

(a)  

2.

Fill in the Blank( See Picture )

Display the sum of 5 + 10, using two variables: x and y.



(a)  

3.

Fill in the Blanks ( See Picture )

Create a variable called z, assign x + y to it, and display the result in an alert box.

(a)  

4.

Fill in the Blanks (See Picture)

On one single line, declare three variables with the following names and values:

firstName = "John"
lastName = "Doe"
age = 35

(a)  

5.

Fill in the Blanks ( See Picture )

Make the function return "Hello".

(a)  

6.

Fill in the Blanks ( See Picture )

Create a function called "myFunction".

(a)  

7.

What is the correct JavaScript syntax to change the content of the HTML element below?

<p id="demo">This is a demonstration.</p>

a)

document.getElementByName("p").innerHTML = "Hello World!";

b)

#demo.innerHTML = "Hello World!";

c)

document.getElementById("demo").innerHTML = "Hello World!";

d)

document.getElement("p").innerHTML = "Hello World!";

8.

What will the following code output?

console.log(10 + "5");

a)

15

b)

105

c)

TypeError

d)

NaN

9.

How do you write a conditional statement in JavaScript?

a)

if i = 5 then

b)

if (i == 5)

c)

if i = 5

d)

if i == 5 then

10.

Which function is used to print something in the browser console?

a)

console.print()

b)

print()

c)

log()

d)

console.log()

11.

How do you create a function in JavaScript?

a)

function myFunction() {}

b)

myFunction = function() {}

c)

def myFunction():

d)

create function myFunction() {}

12.

Which method is used to add a new element at the end of an array?

a)

push()

b)

add()

c)

append()

d)

insertLast()

13.

What does the following JavaScript code do?

var x = 85;

var y = "5";

var z = x + y;

a)

Adds x and y together

b)

Concatenates x and y

c)

Multiplies x and y

d)

Raises x to the power of y

14-15.

Create A Function in JavaScript

14.

create a function named add that takes two parameters a and b and returns their sum:

4 lines
15.

create a loop that prints numbers from 1 to 5

4 lines