var expect = function(val) {
function toBe(num) {
if (num === val) {
return true;
} else {
throw new Error("Not Equal");
}
}
function notToBe(num) {
if (num !== val) {
return true;
} else {
throw new Error("Equal");
}
}
return { toBe, notToBe };
};
toBe
and notToBe
, we encapsulate these methods within the expect
function, providing a clean and organized structure.expect
function, allowing us to use them as methods on the returned object.By returning the functions, we can create flexible and maintainable code that adheres to the principles of modularity and separation of concerns.