const {sum, subtract} = require('./math')
let result, expected
result = sum(3, 7)
expected = 10
expect(result).toBe(expected)
function expect(actual) {
return {
toBe(expected) {
if (actual !== expected) {
throw new Error(`${actual} is not equal to ${expected}`)
}
},
}
}
is toBe{...} and object or a function?
It is used as a function when you call expect(result).toBe(expected).However, in the expect function definition it looks like an object because it doesn't have a function keyword. However objects do not accept parameters. Thank you in advance.