MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / expect

Function expect

javascript/2704-to-be-or-not-to-be.js:9–17  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

7 * - notToBe(expected): Returns true if val !== expected, otherwise throws an error "Equal".
8 */
9const expect = (val) => {
10 const throwError = (message) => {
11 throw new Error(message);
12 };
13 return {
14 toBe: (expected) => val === expected || throwError('Not Equal'),
15 notToBe: (expected) => val !== expected || throwError('Equal'),
16 };
17};
18
19// Example usage:
20// expect(5).toBe(5); // returns true

Callers

nothing calls this directly

Calls 1

throwErrorFunction · 0.85

Tested by

no test coverage detected