Skip to content

Commit 9b49b37

Browse files
authored
Create To Be Or Not To Be
1 parent 4810cf9 commit 9b49b37

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

To Be Or Not To Be

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @param {string} val
3+
* @return {Object}
4+
*/
5+
6+
/*
7+
Example 1:
8+
9+
Input: func = () => expect(5).toBe(5)
10+
Output: {"value": true}
11+
Explanation: 5 === 5 so this expression returns true.
12+
13+
*/
14+
var expect = function(val) {
15+
return {
16+
toBe: (val2) => {
17+
if (val !== val2) throw new Error("Not Equal");
18+
else return true;
19+
},
20+
notToBe: (val2) => {
21+
if(val === val2) throw new Error("Equal");
22+
else return true;
23+
}
24+
}
25+
};
26+
27+
/**
28+
* expect(5).toBe(5); // true
29+
* expect(5).notToBe(5); // throws "Equal"
30+
*/

0 commit comments

Comments
 (0)