Exchange two values.
function swap(x, k, l) // x: entries // k: a key // l: another key
const entries = require('extra-entries'); var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4]]; [...entries.swap(x, "a", "b")]; // → [ [ "a", 2 ], [ "b", 1 ], [ "c", 3 ], [ "d", 4 ] ] [...entries.swap(x, "a", "d")]; // → [ [ "a", 4 ], [ "b", 2 ], [ "c", 3 ], [ "d", 1 ] ]
There was an error while loading. Please reload this page.