Skip to content

Instantly share code, notes, and snippets.

@omas-public
Last active November 14, 2022 12:51
Show Gist options
  • Save omas-public/9d69092ecab84952afa4542732838605 to your computer and use it in GitHub Desktop.
Save omas-public/9d69092ecab84952afa4542732838605 to your computer and use it in GitHub Desktop.
// 1114.js
const arr = [0, 1, 12, 24, 36]
const start = 2
const f1 = (arr, start) => {
const head = arr.slice(0, 2)
const tail = arr.slice(start + 2)
return [...head, 16, 25, ...tail]
}
const f2 = (arr, start) => {
const head = arr.slice(0, 2)
const tail = arr.slice(start)
return [...head, 4, 9, ...tail]
}
const f3 = (arr, start) => {
const head = arr.slice(0, 2)
const tail = arr.slice(start + 2)
return [...head, ...tail]
}
const f4 = (arr, start) => {
const head = arr.slice(0, 2)
return head
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment