2704. To Be Or Not To Be
Write a function expect that helps developers test their code. It should take in any value val and return an object with the following two functions.
  • toBe(val) accepts another value and returns true if the two values === each other. If they are not equal, it should throw an error "Not Equal".
  • notToBe(val) accepts another value and returns true if the two values !== each other. If they are equal, it should throw an error "Equal".
/**
 * @param {string} val
 * @return {Object}
 */
var expect = function(val) {
    // your code...
};

/**
 * expect(5).toBe(5); // true
 * expect(5).notToBe(5); // throws "Equal"
 */
Решение
var expect = function(val) {
    return {
        toBe: (value) => {
            if (value !== val) {
                throw new Error('Not Equal');
            } else {
                return true;
            }
        },
        notToBe: (value) => {
            if (value === val) {
                throw new Error('Equal');
            } else {
                return true;
            }
        }
    }
};
Для решения задачи нужно вернуть объект с 2-мя функциями, в которых будет логика с условием проверки значений.