Skip to content

Commit 2bfda53

Browse files
committed
Completed interpret
1 parent 79f95ad commit 2bfda53

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Sprint-2/interpret/invert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ function invert(obj) {
2727
// d) Explain why the current return value is different from the target output
2828
// This is because the function is not correctly inverting the key and value.
2929
// e) Fix the implementation of invert (and write tests to prove it's fixed!)
30+
31+
module.exports = invert;

Sprint-2/interpret/invert.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const invert = require("../interpret/invert");
2+
3+
test(`Should return {"10": "x", "20": "y"} when given { x: 10, y: 20 } `, () => {
4+
expect(invert({ x: 10, y: 20 })).toEqual({ 10: "x", 20: "y" });
5+
});
6+
7+
test(`Should return {"2": "bounce", "100": "high"} when given { bounce: 2, high: 100 } `, () => {
8+
expect(invert({ bounce: 2, high: 100 })).toEqual({
9+
2: "bounce",
10+
100: "high",
11+
});
12+
});
13+
14+
test(`Should return {"foot": "ball"} when given { "ball": "foot" } `, () => {
15+
expect(invert({ ball: "foot" })).toEqual({ foot: "ball" });
16+
});

0 commit comments

Comments
 (0)