Problem: 2704. 相等还是不相等
123456789101112131415161718192021
/** * @param {string} val * @return {Object} */var expect = function(val) { return{ toBe : (val1) => { if(val1 !== val) throw new Error("Not Equal") return true }, notToBe : (val1) => { if(val1 === val) throw new Error("Equal") return true } }};/** * expect(5).toBe(5); // true * expect(5).notToBe(5); // throws "Equal" */
1234567891011121314151617181920212223
/** * @param {string} val * @return {Object} */var expect = function(val) { const ret= { toBe : (input) => { if(input !== val) throw new Error("Not Equal") return true }, notToBe : (input) => { if(input === val) throw new Error("Equal") return true } } return ret;};/** * expect(5).toBe(5); // true * expect(5).notToBe(5); // throws "Equal" */