JS-Dev-101 Practice Exam Tests Latest Updated on May-2026 [Q79-Q101]

Share

JS-Dev-101 Practice Exam Tests Latest Updated on May-2026

Pass JS-Dev-101 Exam in First Attempt Guaranteed Dumps!

NEW QUESTION # 79
Refer to the code below:
let timeFunction =() => {
console.log('Timer called.");
};
let timerId = setTimeout (timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?

  • A. removeTimeout(timerId);
  • B. removeTimeout(timedFunction);
  • C. clearTimeout(timerId);
  • D. clearTimeout(timedFunction);

Answer: C


NEW QUESTION # 80
Refer to the code:
const pi = 3.1415926;
What is the data type of pi?

  • A. Decimal
  • B. Double
  • C. Float
  • D. Number

Answer: D


NEW QUESTION # 81
Which two code snippets show working examples of a recursive function?

  • A. let countingDown = function(startNumber) {
    if (startNumber > 0) {
    console.log(startNumber);
    return countingDown(startNumber - 1);
    } else {
  • B. const factorial = numVar => {
    if (numVar < 0) return;
    if (numVar === 0) return 1;
    return numVar * factorial(numVar - 1);
    };
  • C. const sumToTen = numVar => {
    if (numVar < 0)
    return;
    return sumToTen(numVar + 1);
    };
  • D. function factorial(numVar) {
    if (numVar < 0) return;
    if (numVar === 0) return 1;
    return numVar - 1;
    }

Answer: A,B

Explanation:
return startNumber;
}
};
(Note: Option D is shown here with corrected syntax: lowercase return and matching parentheses.) Explanation:
Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge:
A recursive function is a function that calls itself and has a base case to terminate the recursion.
Evaluate each option:
Option A:
const sumToTen = numVar => {
if (numVar < 0)
return;
return sumToTen(numVar + 1);
};
This function calls itself: sumToTen(numVar + 1) - so it is recursive.
However, the base condition is if (numVar < 0) return;.
If you call sumToTen(0):
numVar < 0 is false, so it calls sumToTen(1), then sumToTen(2), and so on, incrementing forever.
There is no condition to stop the recursion when numVar increases; it will eventually cause a stack overflow.
This code does not represent a properly working recursive function with a valid termination for increasing values and is not a good example of correct recursion.
Option B:
function factorial(numVar) {
if (numVar < 0) return;
if (numVar === 0) return 1;
return numVar - 1;
}
This function does not call itself anywhere.
It has conditional returns, but there is no recursive call such as factorial(numVar - 1).
Therefore, it is not recursive at all.
Option C:
const factorial = numVar => {
if (numVar < 0) return;
if (numVar === 0) return 1;
return numVar * factorial(numVar - 1);
};
This is a classic recursive factorial implementation.
It calls itself with a smaller argument: factorial(numVar - 1).
Base cases:
If numVar < 0, it simply returns (could be treated as invalid input).
If numVar === 0, it returns 1, which is the mathematical definition of 0! (zero factorial).
For positive integers, it correctly multiplies numVar by factorial(numVar - 1) until it reaches the base case.
This is a correct and working recursive function.
Option D (corrected):
let countingDown = function(startNumber) {
if (startNumber > 0) {
console.log(startNumber);
return countingDown(startNumber - 1);
} else {
return startNumber;
}
};
This function also calls itself: countingDown(startNumber - 1).
Base case:
When startNumber is not greater than 0 (i.e., 0 or negative), it returns startNumber and stops recursing.
For example, countingDown(3) would:
Log 3, call countingDown(2)
Log 2, call countingDown(1)
Log 1, call countingDown(0)
At 0, it hits the else branch and returns 0, ending the recursion.
This is a valid working recursive function structure (once syntax is corrected).
Therefore, the snippets that show working recursive functions are:
Answe r: C, D
Study Guide / Concept Reference (no links):
Definition of recursion: a function calling itself
Base case vs recursive step
Recursive factorial implementation
Recursive countdown example
Importance of a terminating condition to avoid infinite recursion


NEW QUESTION # 82
Function to test:
01 const sum3 = (arr) => {
02 if (!arr.length) return 0;
03 if (arr.length === 1) return arr[0];
04 if (arr.length === 2) return arr[0] + arr[1];
05 return arr[0] + arr[1] + arr[2];
06 };
Which two assert statements are valid tests for this function?

  • A. sum3([0])
  • B. console.assert(sum3([0]) === 0);
  • C. console.assert(sum3([1, '2']) == 12);
  • D. console.assert(sum3([-3, 2]) === -1);
  • E. console.assert(sum3(['hello', 2, 3, 4]) === NaN);

Answer: B,D

Explanation:
Length 1 → returns arr[0] → 0.
Assertion: 0 === 0 → true.
Also a correct and meaningful test.
Therefore, the valid and logically correct tests here are C and D.
Explanation:
Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge:
Evaluate each test:
A). sum3([1, '2'])
Array length is 2 → line 4: arr[0] + arr[1] → 1 + '2' → '12' (string).
Assertion: '12' == 12 is true (type coercion).
However, this "test" is not logically correct: a numeric sum function should not be expected to return '12' as a string. It passes only because of weak equality coercion, so it is not a good/valid test of correct behavior.
B). sum3(['hello', 2, 3, 4])
Length ≥ 3 → line 5: 'hello' + 2 + 3 → 'hello2' + 3 → 'hello23'.
'hello23' === NaN is always false because NaN is never equal to anything, not even itself.
This assertion fails and also misunderstands how NaN comparisons work.
C). sum3([-3, 2])
Length 2 → -3 + 2 = -1.
Assertion: -1 === -1 → true.
This is a correct and meaningful test.


NEW QUESTION # 83
Given two expressions, `exp1` and `exp2`, which two valid ways to return the logical AND of the two expressions and ensure it is a boolean?

  • A. Boolean(var1 66 var2)
  • B. Boolean(exp1) && Boolean(exp2)
  • C. Boolean(var1) 66 Boolean(var2)
  • D. exp1 & exp2

Answer: A,C


NEW QUESTION # 84
Given the code below:

What is logged to the console'

  • A. 2 5 3 4 1
  • B. 1 2 5 3 4
  • C. 2 5 1 3 4
  • D. 1 2 3 4 5

Answer: A


NEW QUESTION # 85
Value of true + 3 + '100' + null:

  • A. "4100null"
  • B. 0
  • C. "4100"
  • D. "2200null"

Answer: A


NEW QUESTION # 86
Given the code below:
01 function GameConsole (name) {
02 this.name = name;
03 }
04
05 GameConsole.prototype.load = function(gamename) {
06 console.log( ` $(this.name) is loading agame : $(gamename) ...`);
07 )
08 function Console 16 Bit (name) {
09 GameConsole.call(this, name) ;
10 }
11 Console16bit.prototype = Object.create ( GameConsole.prototype) ;
12 //insert code here
13 console.log( ` $(this.name) is loading a cartridge game :$(gamename) ...`);
14 }
15 const console16bit = new Console16bit(' SNEGeneziz ');
16 console16bit.load(' Super Nonic 3x Force ');
What should a developer insert at line 15 to output the following message using the method ?
> SNEGeneziz is loading a cartridgegame: Super Monic 3x Force . . .

  • A. Console16bit.prototype.load(gamename) {
  • B. Console16bit = Object.create(GameConsole.prototype).load = function(gamename) {
  • C. Console16bit.prototype.load = function(gamename) {
  • D. Console16bit.prototype.load(gamename) = function() {

Answer: C


NEW QUESTION # 87
Given the JavaScript below:

Which code should replace the placeholder comment on line 05 to highlight accounts that match the search string'

  • A. 'none1 : "yellow'
  • B. 'yellow' : null
  • C. null : 'yellow'
  • D. 'yellow : 'none'

Answer: D


NEW QUESTION # 88
Refer to the code below:
01 let timedFunction = () => {
02 console.log('Timer called.');
03 };
04
05 let timerId = setInterval(timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?

  • A. removeInterval(timedFunction);
  • B. removeInterval(timerId);
  • C. clearInterval(timerId);
  • D. clearInterval(timedFunction);

Answer: C

Explanation:
Comprehensive and Detailed Explanation From JavaScript Knowledge:
The code:
let timerId = setInterval(timedFunction, 1000);
setInterval schedules timedFunction to run every 1000 ms.
It returns an interval ID (here stored in timerId), which is used to cancel the interval later.
To cancel:
Use clearInterval(timerId);
This is the standard browser (and Node.js) API:
let id = setInterval(fn, delay);
clearInterval(id); stops future executions of that interval.
Check other options:
B . removeInterval(timerId);
There is no removeInterval function in the standard JavaScript timer API.
C . removeInterval(timedFunction);
Again, no such function; and timers are cancelled by ID, not by the callback function reference.
D . clearInterval(timedFunction);
clearInterval expects the ID returned by setInterval, not the callback function.
Passing the function does not cancel the timer.
Therefore, the correct statement is:
Answe r: A
Study Guide / Concept Reference (no links):
Timer APIs: setInterval and clearInterval
Relationship between timer ID and cancellation
Difference between interval ID and callback function
Basic async timing patterns in JavaScript


NEW QUESTION # 89
A team that works on a big project uses npm to deal with projects dependencies.
A developer added a dependency does not get downloaded when they execute npm install.
Which two reasons could be possible explanations for this?
Choose 2 answers

  • A. The developer added the dependency as a dev dependency, andNODE_ENVIs set to production.
  • B. The developer missed the option --add when adding the dependency.
  • C. The developer missed the option --save when adding the dependency.
  • D. The developer added the dependency as a dev dependency, andNODE_ENV is set to production.

Answer: A,C,D


NEW QUESTION # 90
Refer to the code below:
Function Person(firstName, lastName, eyecolor) {
this.firstName =firstName;
this.lastName = lastName;
this.eyeColor = eyeColor;
}
Person.job = 'Developer';
const myFather = new Person('John', 'Doe');
console.log(myFather.job);
What is the output after the code executes?

  • A. ReferenceError: assignment to undeclared variable "Person"
  • B. ReferenceError: eyeColor is not defined
  • C. Undefined
  • D. Developer

Answer: C


NEW QUESTION # 91
Correct implementation of try...catch for countsDeep():

  • A. try {
    setTimeout(function() {
    countSheep();
    }, 1000);
    } catch (e) {
    handleError(e);
    }
  • B. try {
    countsDeep();
    } handleError (e){
    catch(e);
    }
  • C. setTimeout(function() {
    try {
    countsDeep();
    } catch (e) {
    handleError(e);
    }
    }, 1000);
  • D. try {
    setTimeout(function() {
    countsDeep();
    }, 1000);
    } catch (e) {
    handleError(e);
    }

Answer: C

Explanation:
Errors thrown inside a setTimeout callback are asynchronous.
A try...catch around setTimeout (options C and D) can't catch errors thrown inside the callback later.
You must put the try...catch inside the timeout callback (option B).
A is nonsense syntax, D also calls countSheep() instead of countsDeep().


NEW QUESTION # 92
Given the following code:
let x = null;
console.log(typeof x);
What is the output?

  • A. "null"
  • B. "undefined"
  • C. "x"
  • D. "object"

Answer: D


NEW QUESTION # 93
Which statement accurately describes an aspect of promises?

  • A. Arguments for the callback function passed to .then() are optional.
  • B. In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise.
  • C. .then() manipulates and returns the original promise.
  • D. .then() cannot be added after a catch.

Answer: A


NEW QUESTION # 94
A test has a dependency on database. query. During the test, the dependency is replaced with an object called database with the method, Calculator query, that returns an array. The developer does notneed to verify how many times the method has been called.
Which two test approaches describe the requirement?
Choose 2 answers

  • A. White box
  • B. Substitution
  • C. Black box
  • D. Stubbing

Answer: A,B


NEW QUESTION # 95
Given a value, which two options can a developer use to detect if the value is NaN?

  • A. value === Number.NaN
  • B. Object.is(value, NaN)
  • C. isNaN(value)
  • D. value == NaN

Answer: B,C

Explanation:
Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge:
We already know NaN is special: it is not equal to itself.
Check each:
A . value === Number.NaN
Number.NaN is NaN.
NaN === NaN is always false.
This will never be true; cannot reliably detect NaN.
B . value == NaN
NaN == NaN is also always false.
Again, this never detects NaN.
C . isNaN(value)
Global isNaN converts its argument to a number and then checks if the result is NaN.
This can detect NaN, but it may also return true for non-number values that coerce to NaN, such as isNaN('foo').
Regardless, it is a standard way to detect if a value is "NaN-like" in JavaScript.
D . Object.is(value, NaN)
Object.is(NaN, NaN) returns true.
This is a strict way to detect a value that is exactly NaN (no coercion).
Therefore, among the given choices, the two viable ways to detect NaN are:
isNaN(value)
Object.is(value, NaN)
________________________________________


NEW QUESTION # 96
A developer executes:
document.cookie;
document.cookie = 'key=John Smith';
What is the behavior?

  • A. Cookies are read, but the key value is not set because the value is not URL encoded.
  • B. Cookies are read and the key value is set, and all cookies are wiped.
  • C. Cookies are read and the key value is set, the remaining cookies are unaffected.
  • D. Cookies are not read because line 01 should be document.cookies, but the key value is set and all cookies are wiped.

Answer: C

Explanation:
________________________________________
Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge document.cookie retrieves the cookie string.
Setting document.cookie = 'key=John Smith' adds or updates only that one cookie.
Important details:
Writing to document.cookie does not overwrite all cookies.
The browser does not require URL encoding, though it is recommended. Non-encoded spaces are allowed and automatically handled.
document.cookies does not exist; the correct property is document.cookie.
Therefore, the correct behavior:
Cookies are read.
A new cookie key=John Smith is set.
Existing cookies remain.
________________________________________
JavaScript Knowledge Reference (text-only)
Writing document.cookie appends or updates cookies, not replaces them.
document.cookie is both getter and setter for cookie strings.


NEW QUESTION # 97
Refer to the code below:

Which value can a developer expect when referencing country,capital,cityString?

  • A. undefined
  • B. 'London'
  • C. 'NaN'
  • D. An error

Answer: C


NEW QUESTION # 98
Given the following code:
let x = ('15' + 10) * 2;
What is the value of x?

  • A. 0
  • B. 1
  • C. 2
  • D. 3

Answer: C

Explanation:
________________________________________
Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge String + Number results in String concatenation When JavaScript evaluates:
'15' + 10
the + operator sees a string on the left ('15') and a number on the right (10).
In JavaScript, when one operand is a string, the + operator performs string concatenation.
Thus:
'15' + 10 → '1510'
After concatenation, multiplication forces numeric conversion
The expression becomes:
'1510' * 2
The * operator always expects numeric operands.
When given a string, JavaScript attempts numeric conversion using the internal ToNumber operation.
'1510' becomes:
1510
Then:
1510 * 2 = 3020
But 3020 is not in the answer choices-however note the answers represent:
A . 1520
B . 50
C . 35
D . 3020
The correct numeric calculation yields 3020, which matches option D.
But wait-did we misread?
Let's double-check:
('15' + 10) * 2
= '1510' * 2
= 3020
Correct value is 3020.
Therefore the right answer is D.
________________________________________
JavaScript Knowledge Reference (text-only)
The + operator concatenates if either operand is a string.
The * operator always performs numeric coercion.
'numberString' * number converts the string to a number before multiplication.


NEW QUESTION # 99
Given the HTML below:
<div>
<div id="row-uc">Universal Containers</div>
<div id="row-as">Applied Shipping</div>
<div id="row-bt">Burlington Textiles</div>
</div>
Which statement adds the priority-account CSS class to the Applied Shipping row?

  • A. document.querySelector('#row-as').classes.push('priority-account');
  • B. document.querySelectorAll('#row-as').classList.add('priority-account');
  • C. document.querySelector('#row-as').classList.add('priority-account');
  • D. document.getElementById('row-as').addClass('priority-account');

Answer: C

Explanation:
document.querySelector('#row-as') returns the single element with id row-as.
That element has a classList property with add, remove, etc.
Correct usage:
document.querySelector('#row-as').classList.add('priority-account');
Why others are wrong:
A: querySelectorAll returns a NodeList, not a single element, so it does not have a classList property.
C: DOM elements do not have a classes array or push; they have classList.
D: document.getElementById('row-as') is fine to get the element, but there is no addClass method in standard DOM; that's a jQuery-style API, not vanilla JS.
________________________________________


NEW QUESTION # 100
Given the code:
01 function GameConsole(name) {
02 this.name = name;
03 }
04
05 GameConsole.prototype.load = function(gamename) {
06 console.log('${this.name} is loading a game: ${gamename}....');
07 }
08
09 function Console16bit(name) {
10 GameConsole.call(this, name);
11 }
12
13 Console16bit.prototype = Object.create(GameConsole.prototype);
14
15 // insert code here
16 console.log('${this.name} is loading a cartridge game: ${gamename}....');
17 }
18
19 const console16bit = new Console16bit('SNEGeneziz');
20 console16bit.load('Super Monic 3x Force');
What should a developer insert at line 15?

  • A. Console16bit.prototype.load(gamename) {
  • B. Console16bit = Object.create(GameConsole.prototype).load = function(gamename) {
  • C. Console16bit.prototype.load = function(gamename) {
  • D. Console16bit.prototype.load(gamename) = function() {

Answer: C

Explanation:
________________________________________
Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge A subclass created by:
Console16bit.prototype = Object.create(GameConsole.prototype);
inherits all prototype methods from GameConsole, including load.
To override the inherited method, the correct syntax is to assign a new function to the method name on the prototype:
Console16bit.prototype.load = function(gamename) {
console.log(`${this.name} is loading a cartridge game: ${gamename}....`);
};
Why the other options are wrong:
A assigns something to the constructor function itself, not to the prototype method. Invalid.
B attempts to call a function in the left-hand side of an assignment; invalid syntax.
C also uses invalid syntax-prototype methods cannot be defined this way.
D is the correct definition of a prototype method override.
________________________________________
JavaScript Knowledge Reference (text-only)
Methods are overridden by assigning functions to Subclass.prototype.methodName.
Object.create() establishes prototype inheritance.
Constructor functions require prototype method attachment using assignment syntax.


NEW QUESTION # 101
......

Salesforce Developers Free Certification Exam Material from RealVCE with 149 Questions: https://examcollection.realvce.com/JS-Dev-101-original-questions.html