NEW
Font size
WorksheetsJavaScript -MIDTERM EXAM
Total questions: 60
Worksheet time: 52mins
What is JavaScript primarily used for?
Database management
Web programming
Desktop applications
Mobile app development
Which of the following is NOT a language that all web developers must learn?
JavaScript
Python
CSS
HTML
What does the assignment operator (=) do in JavaScript?
Compares two values
Assigns a value to a variable
Performs arithmetic operations
Declares a function
Which operator is used for logical 'and' in JavaScript?
||
!
&&
&
What type of values can a variable hold in JavaScript?
Only boolean values
Any type of data
Only strings
Only numbers
What is the purpose of methods in JavaScript?
To store data
To define variables
To create new objects
To perform actions on objects
Which of the following is an example of a JavaScript event?
function doWhatever
var month
document.write
onClick
What does the 'document' refer to in JavaScript?
A property of the window
A method for writing data
An object representing the web page
A type of variable
How can JavaScript be included in an HTML document?
Only in the
sectionOnly in the
sectionJavaScript cannot be included in HTML
In both
and sectionsWhat is the correct syntax to create a variable in JavaScript?
month var = 'April';
var month = 'April';
var = month 'April';
var month = April;
What is the purpose of using comment tags in JavaScript?
To create functions
To define variables
To hide scripts from browsers
To execute code
Which of the following is a valid JavaScript data type?
Integer
String
ArrayList
Character
What does the 'onLoad' event do in JavaScript?
Triggers when a form is submitted
Triggers when an image is hovered
Triggers when a button is clicked
Triggers when the page is loaded
What is the purpose of the 'alert' function in JavaScript?
To create a new variable
To log messages to the console
To define a new function
To display a message to the user
Which of the following is a correct way to define a function in JavaScript?
function doWhatever: { }
doWhatever() function { }
function: doWhatever() { }
function doWhatever() { }
What is a property in JavaScript?
A method of a function
A function of an object
An attribute of an object
A type of variable
Which operator is used for comparison in JavaScript?
==
===
!=
All of the above
What does the 'var' keyword do in JavaScript?
Assigns a value
Creates an object
Defines a function
Declares a variable
What is the output of the following code: console.log(typeof 'Hello')?
String
Number
Undefined
Boolean
Which of the following is NOT a type of operator in JavaScript?
Logical Operators
Comparison Operators
String Operators
Arithmetic Operators
How do you write "Hello, World!" in an alert box?
alert("Hello, World!");
msgBox("Hello, World!");
msg("Hello, World!");
alertBox("Hello, World!");
Which operator is used to assign a value to a variable?
=
==
===
=>
How do you write a single-line comment in JavaScript?
<!-- This is a comment -->
// This is a comment
/* This is a comment */
** This is a comment **
Which of the following is the correct way to write an if statement in JavaScript?
if i == 5 then
if (i == 5) {}
if i = 5 {}
if (i = 5) then {}
What is the correct syntax for referring to an external script called "app.js"?
"<script href="app.js"></script>"
"<script name="app.js"></script>"
"<script src="app.js"></script>"
"<script link="app.js"></script>"
How do you declare a constant variable in javascript?
var
let
constant
const
What is the '&&' operator used for in javascript?
Logical AND operation
Assignment operation
Bitwise AND operation
Concatenation operation
Which method is used to write into an HTML element in JavaScript?
document.write()
getElementById()
window.alert()
console.log()
What are the two types of comments in JavaScript?
Single line and multi-line
Inline and block
Header and footer
Function and variable
What is a primitive data type in JavaScript?
Number
Object
Array
Function
What is the primary benefit of client-side scripting in terms of usability?
It allows access to server's private data
It can write files and connect to databases
It can modify a page without posting back to the server
It provides better browser compatibility
Which of the following is NOT a key characteristic of JavaScript compared to Java?
It has looser data types
It is compiled rather than interpreted
It has more relaxed syntax rules
It focuses on functions rather than classes
How does JavaScript differ from PHP in terms of execution?
JavaScript is compiled while PHP is interpreted
JavaScript runs on the server while PHP runs on the client
JavaScript runs on the client's browser while PHP runs on the web server
JavaScript is procedural while PHP is object-oriented
What is the proper placement of JavaScript code in an HTML document?
Only in the body section
Only in the head section
In a separate .js file linked to the HTML document
Anywhere within the HTML document
Using the javascript, evaluate the following
var x=10, y=5, z=2;
document.write (x + y * z / z - x);
5
10
15
1
Using the javascript, evaluate the following
var x=10, y=5, z=2;
document.write (x + y z / z - x > x*x);
15
1
true
false
Using the javascript, evaluate the following
var x=10, y=5, z=2;
document.write ((x >= x) || (x x / y > y x));
15
1
true
false
Using the javascript, evaluate the following
var x=10, y=5, z=2;
document.write (x * x / y == y * x);
15
1
true
false
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).
event management system
event-driven programming / application
action respondent
object-oriented programming
var typeOfApples="Fuji";
How can a developer show a pop-up message to the user?
alert
prompt
console.log
<p> tag
What is the limit of parameters a function can have?
3
No limit
10
5
Is JavaScript case sensitive language?
Yes
No
Depends on the browser
Depends on the platform
What is the output of the following script?
function display() { document.writeln(10+20+"30"); } display();
60
30"30"
3030
102030
Determine what x would be when assignment operators are used given that ×=6 y=12 z=18
x−=3
x%=4
4 and 5
3 and 2
3 and 7
1 and 2
Perform the operation on operands of different data types given that:
a = 4 , b = happy , c= people, d = 9 , e = memories
Solve : a - d
13
5
8
9
Perform the operation on operands of different data types given that a = 4 , b = happy , c= people, d = 9 , e = memories
Solve: b + c
happy people
people happy
happy memories
happy plus
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)
False
True
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")
True
False
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)
True
False
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)
True
False
Which of the following keywords is the example of client-side scripting language?
Ruby
Javascriipt
PHP
Python
Which of the following methods that displays a dialog box that prompts the user for input?
alert()
prompt()
window.location()
document.write()
Which of the following methods used for parses a value as a string and returns the first integer?
alert()
prompt()
parseInt()
document.write()
Which of the following methods used that writes directly to an open (HTML) document stream?
alert()
prompt()
parseInt()
document.write()
