wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript

Total questions: 80

Worksheet time: 44mins

Name
Class
Date
1.
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
2.
What surrounds a string?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
3.
To display writing on the screen you must include this direction;
a)
Document Write
b)
documentWrite
c)
document.write( )
d)
document.write
4.
A variable;
a)
Expresses a true false statement
b)
stores a string, number, or boolean, and gives it a specific, case-sensitive name
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
5.
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
6.
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
7.
An if/else statement;
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
8.
What surrounds an if/else statement?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
9.
What surrounds an array?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
10.

What programming language did we learn in class this week?

a)

Karel

b)

Java

c)

JavaScript

d)

Visual Basic

11.

Which of these is a loop?

a)

if(x<10)

b)

while(x<10)

c)

var x=10;

d)

text(x,10;10)

12.

Which command provides a random color?

a)

Randomizer.color

b)

Randomizer.nextColor()

c)

RandColor;

d)

nextColor.Randomizer()

13.

Which of these will increase the value of the variable X?

a)

increment (x)

b)

x++;

c)

x=x;

d)

x+1;

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.

What is a variable

a)

Store values in containers so we can use them later.

b)

Store values in containers so we can use them never.

c)

Store values in containers so we can use them once.

d)

Store values in containers so we can't use them later.

21.

A short form writing the word variable is

a)

rav

b)

VAR

c)

var

d)

varia

22.
What command draws a rectangle?
a)
rec (10, 20, 100, 200);
b)
rect (10, 20, 100, 200)
c)
rect (10, 20, 100, 200);
d)
ellipse (10, 20, 40, 40)
23.
Which command colors the background of your canvas?
a)
background 
b)
endShape
c)
var = color
d)
fill
24.
What command removes the outlines from shapes?
a)
noOutline ();
b)
noColor();
c)
noBorder();
d)
noStroke ();
25.
What command draws a perfect circle?
a)
ellipse (80, 60, 100, 105);
b)
ellipse(80, 60, 100, 100);
c)
circle (80, 60, 80, 60):
d)
ellipse (80, 60, 105, 100);
26.
What command colors a shape?
a)
color (43, 255, 0);
b)
bucket (43, 255, 0);
c)
fill (43, 255, 0);
d)
bucket (43, 255, 0);
27.
What command draws a line?
a)
stroke (200, 220, 275, 220);
b)
line (200, 220, 275, 220);
c)
horizontal (200, 220,  60, 75);
d)
pencil (200, 220, 275, 220);
28.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
29.

The "stroke" command means

a)

color inside shape

b)

color outside shape

c)

color of blocks

d)

border

30.

What does the "fill" command do

a)

put letters in the shape

b)

put pictures in the shape

c)

put color in the shape

d)

put code in the shape

31.
Any code that is within the following draw function:
draw = function(){
......
}
a)
Will be performed twice
b)
Will not be performed
c)
Will be performed once
d)
Will be repeated over and over again
32.
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
33.
In a programming language, __________ are used to store data values.
a)
tags
b)
codes
c)
files
d)
variables
34.
JavaScript uses the _______ keyword to define variables.
a)
vrb
b)
var
c)
vari
d)
va
35.

This saves a value, which can be then assigned when writing code

a)

Parameter

b)

Function

c)

Variable

36.

Which tag indicates the presence of javascript

a)

<css>

b)

<script type="text/javascript">

c)

<?php>

d)

<style>

37.

javascript can be written within

a)

<head> tag only

b)

<body> tag only

c)

it can be written within both <head> and <body> tag

d)

none of the above

38.

When the javascript code is written inside html it will be saved as

a)

.html

b)

.css

c)

.js

d)

none of the above

39.

in javascript what command is equivalent to print statement of c program

a)

alert

b)

write

c)

print

d)

echo

40.

does javascript have functions

a)

yes

b)

no

41.

<html>

<head>

<script>

function add(){

var a=10;

var b=20;

document.write("sum is "+c);

</script></head>

<body>

<button onclick="add()">add 2 numbers</button>

</body>

</html>

a)

30

b)

40

c)

error

d)

none of the above

42.

WHAT IS THE OUTPUT

<html>

<head>

<script>

function add(){

document.getElementById("one").innerhtml="AFTER CHANGE";

</script></head>

<body>

<p id="one">BEFORE CHANGE</p>

<button onclick="add()">change</button>

</body>

</html>

a)

PARAGRAPH CONTENT CHANGED TO AFTER CHANGE

b)

PARAGRAPH CONTENT REMAINS SAME

c)

ERROR

d)

ONLY BUTTON WILL APPEAR

43.

Javascript is

a)

client side scripting language

b)

server side scripting language

c)

both client and server side scripting language

d)

none of the above

44.

Which of the following is correct

a)

document.getElementByID(" ")

b)

document.getElementByName(" ")

c)

document.getElementByClass(" ")

d)

all of the above

45.

Javascript is _________ language.

a)

Programming

b)

Scripting

c)

Application

d)

applet

46.

JavaScript is ______ Side Scripting Language.

a)

JSP

b)

Servlet

c)

Server

d)

Browser

47.

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

48.

JavaScript is can be written -

a)

directly into JS file and included into HTML

b)

directly into HTML pages

c)

directly on the Server Script

d)

None of these

49.

JavaScript is an ________ language.

a)

compiled

b)

interpreted

50.

Why JavaScript is called as Lightweight Programming Language ?

a)

because JS can provide programming functionality inside but up to certain extend.

b)

because JS is client side scripting

c)

because JS is available free of cost.

d)

because we can add programming functionality inside JS

51.

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

a)

HTML

b)

CSS

c)

js

d)

java

52.

JavaScript Code can be called by using _________.

a)

RMI

b)

Function / Method

c)

Triggering Event

d)

Preprocessor

53.

Is this correct syntax to include JS Code inside HTML Page ?

<script type="text/javascript">

...

</script>

a)

Yes

b)

No

54.

We cannot Place JS Code in the body tag . Say true/false.

a)

True

b)

False.

55.

What is the value of “a” in the following statement?

var a;

a)

undefined

b)

null

c)

0

d)

NaN

56.

What is the value of:

”41” + 1

a)

42

b)

“42”

c)

411

d)

“411”

57.

What is the value of:

”31” - 1

a)

“30”

b)

30

c)

“311”

d)

NaN

58.

JavaScript is a simpler form of Java.

a)

True

b)

False

59.

What is the extension for a JavaScript file?

a)

.java

b)

.jar

c)

.js

d)

.sj

60.

JavaScript functions can access variables defined in the same scope?

a)

True

b)

False

61.

Variables defined inside of functions are accessible outside of the function?

a)

True

b)

False

62.

The syntax for JavaScript objects is similar to the syntax for Python dictionaries?

a)

True

b)

False

63.

In JavaScript strings must be defined using only double quotes (“).

a)

True

b)

False

64.

What is the name of the JavaScript standard?

a)

JavaScript

b)

ECMA Script

c)

JS

d)

PEP

65.

It can be an assignment operation, a function call, or a control structure

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

66.

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

67.

Names that refer to commands, functions, variables and keyword should be written correctly, variable “A” and “a” are two different variables.

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

68.

A type of network that is limited to a school or a similar location.

a)

LAN

b)

MAN

c)

WAN

d)

CAN

69.

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

70.

Inside which HTML element do we put the JavaScript?

a)

<js>

b)

<script>

c)

<scripting>

d)

<javascript>

71.

The external JavaScript file must contain the <script> tag

a)

true

b)

false

72.

What other languages are typically used with JavaScript?

a)

Python

b)

Ruby

c)

HTML & CSS

d)

SQL

73.

What are the different ways to include JavaScript in your application? Choose all that apply.

a)

<script> alert('Hello'); </script>

b)

<link src='myjavascript.js'></link>

c)

<link href="myjavascript.js></link>

d)

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

74.

How would you declare a variable in JavaScript?

a)

var myName = "Sally"

b)

myName = "Sally"

c)

myName var = "Sally"

d)

var myName = Sally

75.

What is the difference between var and let in JavaScript?

a)

There are no differences, they are both the same.

b)

let is visible through blocks and accessed globally, var isn't.

c)

var is visible through blocks and accessed globally, let isn't.

d)

let is used more frequently, var isn't.

76.

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

a)

8

b)

62

c)

6+'2'

d)

6'2'

77.

What would alert('6'-2) show:

a)

An error Message

b)

62

c)

'6'-2

d)

4

78.

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

79.

Read the code below:


alert(true || false);


What would the output be?

a)

True

b)

False

80.

Read the code below:


alert(!false);


What would the output be?

a)

True

b)

False