wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript -MIDTERM EXAM

Total questions: 60

Worksheet time: 52mins

Name
Class
Date
1.

What is JavaScript primarily used for?

a)

Database management

b)

Web programming

c)

Desktop applications

d)

Mobile app development

2.

Which of the following is NOT a language that all web developers must learn?

a)

JavaScript

b)

Python

c)

CSS

d)

HTML

3.

What does the assignment operator (=) do in JavaScript?

a)

Compares two values

b)

Assigns a value to a variable

c)

Performs arithmetic operations

d)

Declares a function

4.

Which operator is used for logical 'and' in JavaScript?

a)

||

b)

!

c)

&&

d)

&

5.

What type of values can a variable hold in JavaScript?

a)

Only boolean values

b)

Any type of data

c)

Only strings

d)

Only numbers

6.

What is the purpose of methods in JavaScript?

a)

To store data

b)

To define variables

c)

To create new objects

d)

To perform actions on objects

7.

Which of the following is an example of a JavaScript event?

a)

function doWhatever

b)

var month

c)

document.write

d)

onClick

8.

What does the 'document' refer to in JavaScript?

a)

A property of the window

b)

A method for writing data

c)

An object representing the web page

d)

A type of variable

9.

How can JavaScript be included in an HTML document?

a)

Only in the section

b)

Only in the section

c)

JavaScript cannot be included in HTML

d)

In both and sections

10.

What is the correct syntax to create a variable in JavaScript?

a)

month var = 'April';

b)

var month = 'April';

c)

var = month 'April';

d)

var month = April;

11.

What is the purpose of using comment tags in JavaScript?

a)

To create functions

b)

To define variables

c)

To hide scripts from browsers

d)

To execute code

12.

Which of the following is a valid JavaScript data type?

a)

Integer

b)

String

c)

ArrayList

d)

Character

13.

What does the 'onLoad' event do in JavaScript?

a)

Triggers when a form is submitted

b)

Triggers when an image is hovered

c)

Triggers when a button is clicked

d)

Triggers when the page is loaded

14.

What is the purpose of the 'alert' function in JavaScript?

a)

To create a new variable

b)

To log messages to the console

c)

To define a new function

d)

To display a message to the user

15.

Which of the following is a correct way to define a function in JavaScript?

a)

function doWhatever: { }

b)

doWhatever() function { }

c)

function: doWhatever() { }

d)

function doWhatever() { }

16.

What is a property in JavaScript?

a)

A method of a function

b)

A function of an object

c)

An attribute of an object

d)

A type of variable

17.

Which operator is used for comparison in JavaScript?

a)

==

b)

===

c)

!=

d)

All of the above

18.

What does the 'var' keyword do in JavaScript?

a)

Assigns a value

b)

Creates an object

c)

Defines a function

d)

Declares a variable

19.

What is the output of the following code: console.log(typeof 'Hello')?

a)

String

b)

Number

c)

Undefined

d)

Boolean

20.

Which of the following is NOT a type of operator in JavaScript?

a)

Logical Operators

b)

Comparison Operators

c)

String Operators

d)

Arithmetic Operators

21.

How do you write "Hello, World!" in an alert box?

a)

alert("Hello, World!");

b)

msgBox("Hello, World!");

c)

msg("Hello, World!");

d)

alertBox("Hello, World!");

22.

Which operator is used to assign a value to a variable?

a)

=

b)

==

c)

===

d)

=>

23.

How do you write a single-line comment in JavaScript?

a)

<!-- This is a comment -->

b)

// This is a comment

c)

/* This is a comment */

d)

** This is a comment **

24.

Which of the following is the correct way to write an if statement in JavaScript?

a)

if i == 5 then

b)

if (i == 5) {}

c)

if i = 5 {}

d)

if (i = 5) then {}

25.

What is the correct syntax for referring to an external script called "app.js"?

a)

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

b)

"<script name="app.js"></script>"

c)

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

d)

"<script link="app.js"></script>"

26.

How do you declare a constant variable in javascript?

a)

var

b)

let

c)

constant

d)

const

27.

What is the '&&' operator used for in javascript?

a)

Logical AND operation

b)

Assignment operation

c)

Bitwise AND operation

d)

Concatenation operation

28.

Which method is used to write into an HTML element in JavaScript?

a)

document.write()

b)

getElementById()

c)

window.alert()

d)

console.log()

29.

What are the two types of comments in JavaScript?

a)

Single line and multi-line

b)

Inline and block

c)

Header and footer

d)

Function and variable

30.

What is a primitive data type in JavaScript?

a)

Number

b)

Object

c)

Array

d)

Function

31.

What is the primary benefit of client-side scripting in terms of usability?

a)

It allows access to server's private data

b)

It can write files and connect to databases

c)

It can modify a page without posting back to the server

d)

It provides better browser compatibility

32.

Which of the following is NOT a key characteristic of JavaScript compared to Java?

a)

It has looser data types

b)

It is compiled rather than interpreted

c)

It has more relaxed syntax rules

d)

It focuses on functions rather than classes

33.

How does JavaScript differ from PHP in terms of execution?

a)

JavaScript is compiled while PHP is interpreted

b)

JavaScript runs on the server while PHP runs on the client

c)

JavaScript runs on the client's browser while PHP runs on the web server

d)

JavaScript is procedural while PHP is object-oriented

34.

What is the proper placement of JavaScript code in an HTML document?

a)

Only in the body section

b)

Only in the head section

c)

In a separate .js file linked to the HTML document

d)

Anywhere within the HTML document

35.

Using the javascript, evaluate the following

var x=10, y=5, z=2;

document.write (x + y * z / z - x);

a)

5

b)

10

c)

15

d)

1

36.

Using the javascript, evaluate the following

var x=10, y=5, z=2;

document.write (x + y z / z - x > x*x);

a)

15

b)

1

c)

true

d)

false

37.

Using the javascript, evaluate the following

var x=10, y=5, z=2;

document.write ((x >= x) || (x x / y > y x));

a)

15

b)

1

c)

true

d)

false

38.

Using the javascript, evaluate the following

var x=10, y=5, z=2;

document.write (x * x / y == y * x);

a)

15

b)

1

c)

true

d)

false

39.

It means a program's flow is determined by events, like user actions (clicks, key presses), system notifications, or data availability, with the program responding to these events by executing specific functions (event handlers). 

a)

event management system

b)

event-driven programming / application

c)

action respondent

d)

object-oriented programming

40.
Which 1 of the following symbols is used for JavaScript comments?
a)
\\
b)
^
c)
?
d)
//
41.
What type of variable is
var typeOfApples="Fuji";
a)
Int
b)
Float
c)
Boolean
d)
String
42.

How can a developer show a pop-up message to the user?

a)

alert

b)

prompt

c)

console.log

d)

<p> tag

43.
What surrounds an if/else statement?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
44.
Which one of the following is the symbol for implementing the AND operator?
a)
&&
b)
**
c)
||
d)
++
45.
A user-defined name for a memory location whose value can change over time.
a)
variable
b)
syntax
c)
operator
d)
token
46.
In JavaScript, you should include a semi-colon at the end of each statement.
a)
yes
b)
no
47.

What is the limit of parameters a function can have?

a)

3

b)

No limit

c)

10

d)

5

48.

Is JavaScript case sensitive language?

a)

Yes

b)

No

c)

Depends on the browser

d)

Depends on the platform

49.

What is the output of the following script?


function display() { document.writeln(10+20+"30"); } display();

a)

60

b)

30"30"

c)

3030

d)

102030

50.

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

51.

Perform the operation on operands of different data types given that:

a = 4 , b = happy , c= people, d = 9 , e = memories


Solve : a - d

a)

13

b)

5

c)

8

d)

9

52.

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

53.

Determine what result each expression yields if it is True or False. Given that x= 8 and y= 16.


(x!== 9 && y===16 ) || ( x>10 || y!=16)

a)

False

b)

True

54.

Determine what result each expression yields if it is True or False. Given that x= 8 and y= 16.


( x === 8 || y > 5) && ( x! == 7 && y > "11")

a)

True

b)

False

55.

Determine what result each expression yields if it is True or False. Given that x= 7 and y= 9.


( x >2 && y ! == 9)&&( x>= 6 && y ==9)

a)

True

b)

False

56.

Determine what result each expression yields if it is True or False. Given that x= 5 and y= 3.


( x==2 || y == 3 )||( x<6 && y<9)

a)

True

b)

False

57.

Which of the following keywords is the example of client-side scripting language?

a)

Ruby

b)

Javascriipt

c)

PHP

d)

Python

58.

Which of the following methods that displays a dialog box that prompts the user for input?

a)

alert()

b)

prompt()

c)

window.location()

d)

document.write()

59.

Which of the following methods used for parses a value as a string and returns the first integer?

a)

alert()

b)

prompt()

c)

parseInt()

d)

document.write()

60.

Which of the following methods used that writes directly to an open (HTML) document stream?

a)

alert()

b)

prompt()

c)

parseInt()

d)

document.write()