Topic Description

To help developers test their code, you need to write a function named expect. This function can accept any value val and returns an object with the following two functionalities:

// Example 1
Input: func = () => expect(5).toBe(5)
Output: {"value": true}
Explanation: 5 === 5 so this expression returns true.

// Example 2
Input: func = () => expect(5).toBe(null)
Output: {"error": "Not Equal"}
Explanation: 5 !== null so this expression throws the error "Not Equal".

Answer

function expect(value) {
  function toBe(val){
	  if(value !== val){
		  throw new Error("Not Equal")
	  }
	  return true
  }
  
  function notToBe(val){
	  if(value == val){
		  throw new Error("Equal")
	  }
	  return true
  }
  
  return {
	  toBe,
	  notToBe
  }
}