Ad
  • Custom User Avatar

    A wonderfully simple and optimizable problem. Good job!

    You could add a more annotated example to make things super clear, though. It's hard to describe "2 from the left, 2 from the right" and so on. Here's an example; you can use it if you wish.

    charConcat("abc!def")
    //          ^     ^    // 0 from the left, 0 from the right
    //          a     f  1 // plus the iteration number
    //          -^   ^-    // 1 from the left, 1 from the right
    //           b   e   2 // plus the iteration number
    //          --^ ^--    // 2 from the left, 2 from the right
    //            c d    3 // plus the iteration number
    //          ---^---    // central character is ignored
                          === 'af1be2cd3'