Node JS midterm exam verified 2025
Any code I write which executes in the browser will work in Node.js, but not vice-versa. -
ANSWER-False
Based on the code below, which of the following will trigger the if(err) to be true:
a) solveRect(12, 2)
b) solveRect(40, 12)
c) solveRect(12, -2)
d) None of the above - ANSWER-c) solveRect(12, -2)
Choose the incorrect statement below:
a) Callback functions can allow you to defer the execution of a particular function to a
later point in time
b) If a function takes a callback parameter, it is an asynchronous function
c) Callback functions can be created using an anonymous function which is directly
passed into another function
d) Callback functions can be created using function declarations whose reference is
passed into another function. - ANSWER-b) If a function takes a callback parameter, it
is an asynchronous function
Every callback function is also asynchronous - ANSWER-False
Every program needs a runtime environment in order to actually execute - ANSWER-
True
Explain how process.argv can be used in Node. - ANSWER-process.argv can be used
when a user inputs a command line with more arguments. For example, "node app.js
extra_argument1 extra_argument2". The property will store all the command line
arguments passed when you issue the command to start the node process. The
arguments are stored as an array inside the property.
For almost every async function built into Node.js, the convention is for the first
parameter passed to any callback you give to be an err parameter to check for any
errors. - ANSWER-True
function addTwo(num) {
return num + 2
}; - ANSWER-function declaration
function func2(num) {
return num > 2
}
let numberArr = [1, 2, 3, 4];
let greaterThanTwo = numberArr.filter(func2);
Any code I write which executes in the browser will work in Node.js, but not vice-versa. -
ANSWER-False
Based on the code below, which of the following will trigger the if(err) to be true:
a) solveRect(12, 2)
b) solveRect(40, 12)
c) solveRect(12, -2)
d) None of the above - ANSWER-c) solveRect(12, -2)
Choose the incorrect statement below:
a) Callback functions can allow you to defer the execution of a particular function to a
later point in time
b) If a function takes a callback parameter, it is an asynchronous function
c) Callback functions can be created using an anonymous function which is directly
passed into another function
d) Callback functions can be created using function declarations whose reference is
passed into another function. - ANSWER-b) If a function takes a callback parameter, it
is an asynchronous function
Every callback function is also asynchronous - ANSWER-False
Every program needs a runtime environment in order to actually execute - ANSWER-
True
Explain how process.argv can be used in Node. - ANSWER-process.argv can be used
when a user inputs a command line with more arguments. For example, "node app.js
extra_argument1 extra_argument2". The property will store all the command line
arguments passed when you issue the command to start the node process. The
arguments are stored as an array inside the property.
For almost every async function built into Node.js, the convention is for the first
parameter passed to any callback you give to be an err parameter to check for any
errors. - ANSWER-True
function addTwo(num) {
return num + 2
}; - ANSWER-function declaration
function func2(num) {
return num > 2
}
let numberArr = [1, 2, 3, 4];
let greaterThanTwo = numberArr.filter(func2);