wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Web JavaScript

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the value of:

”41” + 1

a)

42

b)

“42”

c)

411

d)

“411”

2.

What is the extension for a JavaScript file?

a)

.java

b)

.jar

c)

.js

d)

.sj

3.

What is the name of the JavaScript standard?

a)

JavaScript

b)

ECMAScript

c)

JS

d)

PEP

4.
Indicates the beginning  and the end of a JavaScript section.
a)
<html> </html>
b)
<style> </style>
c)
<article> </article>
d)
<script> </script>
5.
How do we generate a random number?
a)
Math.random()
b)
random.number()
c)
number.random()
d)
Random.math()
6.

What is the correct syntax for referring to an external JavaScript script?

a)

<script src="myscript.js"></script>

b)

<script href="myscript.js"></script>

c)

<js href="myscript.js"></js>

d)

<js src="myscript.js"></js>

7.

Which of these is a loop?

a)

if(x<10)

b)

while(x<10)

c)

var x=10;

d)

text(x,10;10)

8.

His name is Fred and he is less than 16 years old

Which of the following is the best way to write the above statement?

a)

if (name = "fred" && age < 16 )

b)

if (name == "fred" && age < 16 )

c)

if (name = "fred" || age < 16 )

d)

if (name == "fred" || age < 16 )

9.

Which of the following methods can be used to display data in some form using Javascript?

a)

document. write()

b)

console.log()

c)

window.alert()

d)

All of the above

10.

Which of the following keywords is used to define a variable in Javascript?

a)

Var

b)

Let

c)

Both Var and Let

d)

None of the above

11.

How would you change the first element in an array?

a)

nums[1] = "New!";

b)

nums = "New!";

c)

var nums[1] = "New!";

d)

nums[0] = "New!";

12.

Which of these are correct methods to create a function?

a)

function myFunction {

// Some code }

b)

function myFunction[] {

// Some code }

c)

function myFunction() {

// Some code }

d)

def myFunction(x, y, z) {

// Some code }

13.

Given the following code, what is the final value of x?


var x = 0;

function myXFunction() {

x = x + 10;

}

x = x + 1;

a)

11

b)

0

c)

10

d)

1

14.

What will the final value of x be?


var x = 0;

function myXFunction() {

return 10;

}

x = x + 1;

x = myXFunction();

a)

11

b)

0

c)

10

d)

1

15.

const [b,c,a] = "abc"

Value of c?

a)

a

b)

b

c)

c

d)

null