Created
November 8, 2015 19:01
-
-
Save kuanyingchou/fd7c11ab2c45d53799eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let a = [1, 2, 3, 4, 5]; | |
let index = 2; | |
let inc = i => i+1; | |
let dec = i => i-1; | |
let b = [...a.slice(0, index).map(inc), dec(a[index]), ...a.slice(index+1).map(inc)]; | |
console.log(`a=[${a}]`); | |
console.log(`b=[${b}]`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment