-
-
Save IrhaAli/9984a77648ce45ee68ac8f9f0a4d96ba to your computer and use it in GitHub Desktop.
Pair programming the swapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const swapper = function (key1, object1, key2, object2) { | |
console.log("Swap!"); | |
[object1[key1], object2[key2]] = [object2[key2], object1[key1]]; | |
console.log("object1: ", object1); | |
console.log("object2: ", object2); | |
}; | |
swapper("a", { a: 1, b: 2, c: 3 }, "c", { a: 4, b: 3, c: 5 }); | |
swapper("b", { a: 8, b: 7, c: 6 }, "d", { a: 5, b: 1, c: 2, d: 12 }); | |
swapper("c", { a: 1, b: 3, c: 3, d: 7 }, "c", { a: 4, b: 0, c: 5 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment