Skip to content

#076 Case Insensitive Comparison

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

076 Case Insensitive Comparison

Write a function that validates whether two strings are identical. Make it case insensitive.

Current source and tests | Catalog | Testing and tooling

Run this solution

From the cloned repository root, after installing dependencies:

node "Edabit/076 Case Insensitive Comparison.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.

//Write a function that validates whether two strings are identical. Make it case insensitive.
function match(s1, s2) {
    return s1.toLowerCase() === s2.toLowerCase();
}
import { assertEquals } from '../testHelper.js';
assertEquals(match("hello", "hELLo"), true)
assertEquals(match("hey", "hey"), true)
assertEquals(match("venom", "VENOM"), true)
assertEquals(match("maGIciAN", "magician"), true)
assertEquals(match("stupIFy", "stupifY"), true)

assertEquals(match("bald", "blad"), false)
assertEquals(match("motive", "emotive"), false)
assertEquals(match("mask", "mAskinG"), false)
assertEquals(match("skim", "skimp"), false)
assertEquals(match("EXCEl", "exceLs"), false)

Clone this wiki locally