wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

javascript

Total questions: 100

Worksheet time: 55mins

Name
Class
Date
1.
A variable is used to:
a)
Store a value in memory
b)
Draw a circle
c)
Store a value that does not change
d)
Draw a rectangle
2.
The following code will:
x++;
a)
Add 1 to the previous value of x
b)
Add 1 to the previous value of y
c)
Subtract 1 from the previous value of x
d)
Give an error message
3.
In a programming language, __________ are used to store data values.
a)
tags
b)
codes
c)
files
d)
variables
4.
JavaScript uses the _______ keyword to define variables.
a)
vrb
b)
var
c)
vari
d)
va
5.
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
6.
What surrounds a string?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
7.
To display writing on the screen you must include this direction;
a)
Document Write
b)
documentWrite
c)
document.write( )
d)
document.write
8.
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
9.
A function;
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
10.
What surrounds an if/else statement?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
11.
An array is;
a)
Shapes
b)
Sizes
c)
Options
d)
Lists of data
12.
What surrounds an array?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
13.

Which of these is a loop?

a)

if(x<10)

b)

while(x<10)

c)

var x=10;

d)

text(x,10;10)

14.

Which of the following will decrease the value of x?

a)

x--;

b)

x-1;

c)

x=x;

d)

x=-x;

15.

Greater than or equal to

a)

> or =

b)

> || =

c)

>=

d)

<=

16.

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

a)

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

b)

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

c)

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

d)

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

17.

Repeat something 10 times

a)

repeat 10

b)

for (var i=0; i<10; i++)

c)

repeat { } until 10;

d)

while (i = 10)

18.

When we are done with a line what do we put at the end?

a)

a colon :

b)

a semi-colon ;

c)

a period .

d)

a quotation mark "

19.

When we surround a word with quotes "David" it's called ?

a)

a program

b)

a loop

c)

a string

d)

a command

20.

Javascript is _________ language.

a)

Programming

b)

Scripting

c)

Application

d)

applet

21.

JavaScript is ______ Side Scripting Language.

a)

JSP

b)

Servlet

c)

Server

d)

Browser

22.

JavaScript is designed for following purpose -

a)

To Style HTML Pages

b)

To Perform Server Side Scripting Opertion

c)

To add interactivity to HTML Pages.

d)

To Execute Query Related to DB on Server

23.

JavaScript Code is written inside file having extension __________.

a)

.jsc

b)

.jvs

c)

.js

d)

.javascript

24.

Local Browser used for validations on the Web Pages uses __________.

a)

HTML

b)

CSS

c)

js

d)

java

25.
Indicates the beginning  and the end of a JavaScript section.
a)
<html> </html>
b)
<style> </style>
c)
<article> </article>
d)
<script> </script>
26.
Which keyword do we need to define a function?
a)
function
b)
method
c)
onclick
d)
functionName()
27.
Which 1 of the following symbols is used for JavaScript comments?
a)
\\
b)
^
c)
?
d)
//
28.
What type of variable is
var typeOfApples="Fuji";
a)
Int
b)
Float
c)
Boolean
d)
String
29.

JavaScript is an ________ language.

a)

compiled

b)

interpreted

30.
Which message will the user see?
a)
"Hello user"
b)
No message
c)
"Goodbye user"
d)
"message + user"
31.

What attribute/value do we use to make a button execute JavaScript when clicked?

a)

onclick="doSomething;"

b)

on-click="doSomething;"

c)

onclick="doSomething();"

d)

onclick=doSomething();

32.
How do I declare a new variable?
a)
var newVariable = 5;
b)
Variable int = new Variable();
c)
var 5 = myVariable;
d)
int var = 5;
33.
What is CSS used for?
a)
styling web pages
b)
formatting script correctly
c)
client side scripting
d)
server side scripting
34.
How do we generate a random number?
a)
Math.random()
b)
random.number()
c)
number.random()
d)
Random.math()
35.

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>

36.

The simplest data-storing structure in any programming language

a)

Lists

b)

Array

c)

Queue

d)

List

37.

These are any variable names listed within a function's argument definition.


example: myFunction(x, y)

a)

Parameter

b)

Literals

c)

Constraints

d)

Variables

38.

This allows JS Scripts and applications to perform different actions based on given conditions.

a)

Variables

b)

Loops

c)

Conditional Statement

d)

Stacks

39.

Which of the following is NOT a valid component of a function declaration?

a)

Function keyword

b)

Function name

c)

Pair of Square Braces

d)

Pair of Curly Braces

40.

Method used to select the element with a given identifier represented by the HTML element property ID

a)

getElementByClassName() method

b)

getElementById() method

c)

getId()

d)

getElementByTagName()

41.

Which of the following operator is used for the Assignment Operator?

a)

==

b)

!

c)

=

d)

+

42.

What is the symbol pair used to write a new line within a string values?

a)

\*

b)

\'

c)

\n

d)

\br

43.

What is the symbol used for the INCREMENT operator in JS?

a)

+

b)

++

c)

=

d)

==

44.

Using object constructors what specific keyword is used to create new object?

a)

if

b)

var

c)

new

d)

this

45.

Conditions return values of which data type?

a)

Integer

b)

boolean

c)

floating-point

d)

string

46.

built in object in JS that allows a script to perform mathematical task

a)

Arithmetic

b)

Math Object

c)

Operation Object

d)

Mathematics Object

47.

Which type of array declaration allows for greater simplicity?

a)

Dynamic array

b)

Array Literals

c)

Standar Array Syntax

d)

Specified array declaration

48.

What is the name of the JavaScript standard?

a)

JavaScript

b)

ECMA Script

c)

JS

d)

PEP

49.

What is first index value of an array?

a)

2

b)

-1

c)

0

d)

1

50.

What will this code display?

a)

8, 2, 1, 4, 7

b)

82147

c)

Myarray.length

d)

5

51.

What will this code display?

a)

Hello Emma

b)

Hello user

c)

Hello+user

d)

nothing

52.

What would this piece of code do?

a)

change the background color of the word demo to red

b)

change the font color of the demo element to red

c)

this is not correct

d)

styles the element with the class demo

53.

Which of these is a method?

a)

getElementById( )

b)

style

c)

document

d)

color

54.

Which line is missing to return the result of the multiplication 10 x 5 ?

a)

result

b)

number 1 * number 2 ;

c)

let result = 10 x 5 ;

d)

var result = number 1 * number 2 ;

55.

Which of these methods removes the last element of an array?

a)

pop( )

b)

splice( );

c)

push( )

d)

split( )

56.

What would this piece of code display?

a)

10

20

30

40

b)

1

2

3

4

c)

10

20

30

40

50

d)

11

22

33

44

57.

What would this piece of code display?

a)

text

b)

John, Joe, Greg, Ruth

c)

John

Joe

Greg

Ruth

d)

4

58.

How would you declare a variable in JavaScript?

a)

var myName = "Sally"

b)

myName = "Sally"

c)

myName var = "Sally"

d)

var myName = Sally

59.

What would alert(6 + '2') show?

a)

8

b)

62

c)

6+'2'

d)

6'2'

60.

Look at the following code:


let attendees = 568;

attendees++

document.write(attendees)


What will print to the browser?

a)

568

b)

570

c)

569

d)

An error message

61.

Look at the following code:


let total_price = 40;

total_price--

--total_price

document.write(total_price)


What will print to the browser?

a)

39

b)

40

c)

38

d)

42

62.

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

63.

It can be Numeric, String, Boolean or Null.

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

64.

Developed by William Oughtred, the device consists of two movable rulers placed side by side.

a)

Pascal Calculator

b)

Abacus

c)

Slide Rule

d)

Leibnitz Calculator

65.

Determine what x would be when assignment operators are used given that  ×=6\times=6   y=12y=12   z=18z=18  
x−=3

x%=4

a)

4 and 5

b)

3 and 2

c)

3 and 7

d)

1 and 2

66.

Perform the operation on operands of different data types given that a = 4 , b = happy , c= people, d = 9 , e = memories


Solve: b + c

a)

happy people

b)

people happy

c)

happy memories

d)

happy plus

67.

Find the value of Z

var x = 5;

var y = x;

y++;

x--;

var z = x +y;

z++;

a)

10

b)

9

c)

11

d)

12

68.

Find the value of X

var i;

var x=0;

for(i =0; i>=10; i++){

x++;

}

a)

10

b)

11

c)

9

d)

12

69.

What is Javascript?

a)

programming language

b)

HTML tags

c)

CSS

d)

A web page

70.

Where do the <script></script> tags go in your document

a)

Within <img> tags

b)

In the <p></p> tags

c)

In the <title>

d)

In the <head> or <body>

71.

Choose the right Javascript event

a)

inmouseout

b)

anmouseout

c)

enmouseout

d)

onmouseout

72.

Javascript can:

a)

Interact with HTML

b)

Check or validate user input

c)

Can make your web pages dynamic

d)

All of the above

73.

Choose the correct Javascript mouse event

a)

inmouseover

b)

andmouseover

c)

enmouseover

d)

onmouseover

74.

JavaScript is used to enhance what kind of document?

a)

JS

b)

HTML

c)

Brackets

75.

How to get access to number 8 in the following array?

const arr = [[1, 2, 3], [[5, 6, 7, 8], 9]]

a)

arr[[[1,0,3]]]

b)

arr[1][0][3]

c)

arr[1,0,3]

d)

arr[1[0[3]]

76.

What would be the result of this?

const a = 20;

a = 10;

console.log(a)

a)

10

b)

20

c)

it would throw an error

d)

undefined

77.

What would the following comparison produce?

2 == "2"

a)

true

b)

false

c)

undefined

d)

error

78.

How to convert number n to string?

a)

n+''

b)

n.toString()

c)

toString(n)

d)

String(n)

79.

What would be the result of the following?

var arr = [1,2,3];

console.log(arr[0]);

a)

1

b)

2

c)

3

d)

undefined

80.

What is formatting in HTML?

a)

The HTML contains six types of headings which are defined with the <h1> to <h6> tags.

b)

a process of format the text for a better look and feel

c)

There are some HTML tags that don't need a closing tag.

d)

Content is placed between tags to display data on the web page.

81.

Identify the incorrect difference between HTML and DHTML?

a)

HTML is a mark-up language, while DHTML is a collection of technology

b)

HTML sites will be fast upon client-side technologies, while DHTML sites will be slow enough upon client-side technologies.

c)

DHTML creates dynamic web pages, whereas HTML creates static web pages.

d)

HTML cannot have any server side code but DHTML may contain server side code.

e)

DHML is basically using JavaScript and style sheets in an HTML page.

82.
array = [1,2,3,4,5]
What is the length of this array?
a)
5
b)
4
c)
0
d)
125.4
83.

Which definition below best describe an array?

a)

An array is a function identifier that can hold more than one parameter.

b)

An array is a beam of light.

c)

An array is a special variable, which can hold more than one value at a time.

d)

An array is a special function, which can hold more than one value at a time.

84.

Which of the variables below is an array?

a)

var names="array"

b)

var names = array;

c)

var names = [];

d)

var names[];

85.

What will be the output to the console for the following code:


var colors =["Red", "Green", "Yellow", "Orange", "Blue"];

colors.splice(0,3, "Purple");

console.log(colors);

a)

["Purple", "Green", "Yellow"]

b)

["Purple", "Green", "Yellow", "Orange", "Blue"]

c)

["Red", "Green", "Yellow", "Orange", "Blue"]

d)

["Purple", "Orange", "Blue"]

86.
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!";
87.
array = [1,2,3,4,5];
What is the highest position in this array?
HINT: Remember arrays start at position 0!
a)
4
b)
5
c)
0
d)
125.7
88.
What property tells you how many items are in an array?
a)
length
b)
count
c)
items
d)
num
89.
Which is the correct code to remove the 1 from this array?:
arr = [1,2,3,4,5];
a)
arr.append(6);
b)
arr.splice(0, 1);
c)
splice(arr, 6);
d)
append(arr, 6);
90.
array = [1,2,3,4,5]
What would the array look like after we execute this?:
array.splice(0, 1);
a)
[2,3,4,5]
b)
[2,3,4,5,1]
c)
[1,2,3,4]
d)
[5,4,3,2]
91.

The length() method for an array will return _____.

a)

the number of elements in the array

b)

the last index value of the array.

c)

the length of the name of the array variable

d)

the capacity of the array

92.
Which of these lines of code show how to validly store an array with 3 items?
a)
var nums = [42, 3, 7];
b)
var nums = 3, 42, 7;
c)
var nums = [3];
d)
var nums = (3, 42, 7);
93.
Which of these for loops would iterate through each item of the nums array (no more, no less)?
a)
for (var i = 0; i < nums; i++) { }
b)
for (var i = 1; i < nums.length; i++) { }
c)
for (var i = 1; i < nums; i++) { }
d)
for (var i = 0; i < nums.length; i++) { }
94.

JavaScript was originally developed under the name _______.

a)

ActionScript

b)

Mocha

c)

Sencha

d)

Oak

95.

JavaScript is designed for following purpose –

a)

To Style HTML Pages

b)

To Perform Server Side Scripting Operation

c)

To add interactivity to HTML Pages

d)

To Execute Query Related to DB on Server

96.
What type of variable is
var numApples = 2; 
a)
Int
b)
Float
c)
Boolean
d)
String
97.
What type of variable is
var age = "5" 
a)
Int
b)
Float
c)
Boolean
d)
String
98.
Which one of the following is the symbol for implementing the OR operator?
a)
**
b)
&&
c)
||
d)
!
99.
Which one of the following is the symbol for implementing the AND operator?
a)
&&
b)
**
c)
||
d)
++
100.
What character do we use for multiplication?
a)
#
b)
x
c)
*
d)
/