Advertisement
bebo231312312321

Untitled

Mar 10th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function foo(arr1, arr2) {
  2.     for (let i = 0; i < arr1.length; i++) {
  3.         if (arr1[i] === arr2[0]) {arr1.splice(i - arr2[1] > 0 ? i - arr2[1] : 0, arr2[1] * 2 + 1)
  4.             i = 0
  5.         }
  6.     }
  7.     console.log(arr1.reduce((a, v) => a + v, 0))
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement