Skip to content

#110 Equality Check

Adam Kubiś edited this page Oct 28, 2026 · 1 revision

110 Equality Check

In this challenge, you must verify the equality of two different values given the parameters a and b. Both the value and type of the parameters need to be equal.The possible types of the given parameters are: Numbers Strings Booleans(false or true) Special values: undefined, null and NaN What have you learned so far that will permit you to do two different checks(value and type) with a single statement ? Implement a function that returns true if the parameters are equal, and false if they are not.

Current source and tests | Catalog | Testing and tooling

Run this solution

From the cloned repository root, after installing dependencies:

node "Edabit/110 Equality Check.js"

Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.

Current implementation and tests

This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.

/*In this challenge, you must verify the equality of two different values given the parameters a and b.
Both the value and type of the parameters need to be equal.The possible types of the given parameters are:
Numbers
Strings
Booleans(false or true)
Special values: undefined, null and NaN
What have you learned so far that will permit you to do two different checks(value and type) with a single statement ?
	Implement a function that returns true if the parameters are equal, and false if they are not.*/
function checkEquality(a, b) {
    return a === b;
}
import { assertEquals } from '../testHelper.js';
assertEquals(checkEquality(1, true), false, "Example #1")
assertEquals(checkEquality(0, "0"), false, "Example #2")
assertEquals(checkEquality(1, 1), true, "Example #3")
assertEquals(checkEquality(0, ""), false)
assertEquals(checkEquality(1, "1"), false)
assertEquals(checkEquality(0, false), false)
assertEquals(checkEquality(Number.NaN, Number.NaN), false)
assertEquals(checkEquality(null, undefined), false)
assertEquals(checkEquality(undefined, undefined), true)
assertEquals(checkEquality(false, null), false)

Clone this wiki locally