https://leetcode.com/problems/to-be-or- ... 1627481169
/**
* @param {string} val
* @return {Object}
*/
var expect = function (val) {
return {
toBe: function (otherVal) {
if (val === otherVal) return true;
else throw new Error("Not Equal");
},
notToBe: function (otherVal) {
if (val !== otherVal) return true;
else throw new Error("Equal");
}
};
};
expect(5).toBe(5); // true
expect(5).notToBe(5); // throws "Equal"< /code>
< /div>
< /div>
< /p>
ошибка: < /p>
Line 16 in solution.js
throw new Error("Equal");
^
Error: Equal
Line 16: Char 23 in solution.js (Object.notToBe)
Line 27: Char 12 in solution.js (Object.\)
at Module.\_compile (node:internal/modules/cjs/loader
at Object..js (node:internal/modules/cjs/loader
at Module.load (node:internal/modules/cjs/loader
at Function.\_load (node:internal/modules/cjs/loader
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Function.executeUserEntryPoint \[as runMain\] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49
Node.js v22.14.0
Подробнее здесь: https://stackoverflow.com/questions/796 ... -not-to-be
Мобильная версия