Index Shuffle

Published by Helen Yu in

Write a function that takes all even-indexed characters and odd-indexed characters from a string and concatenates them together.

To illustrate:

index_shuffle("abcd") ➞ "acbd"
// "ac" (even-indexed) + "bd" (odd-indexed)

Examples

index_shuffle("abcdefg") ➞ "acegbdf"

index_shuffle("holiday") ➞ "hldyoia"

index_shuffle("maybe") ➞ "myeab"

Notes

0 should be treated as an even number.

Watch a quick demo on how Edabit works.