Skip to content
Advertisement

Given a string, print its even-indexed and odd-indexed characters as space-separated strings on a single line

Given a string, print its even-indexed and odd-indexed characters as space-separated strings on a single line.

Example:

s = adbecf => Print abc def

My approach:

JavaScript

Advertisement

Answer

No need to use complex ways. here is a easy way to do it.

JavaScript

Input: adbecf

Output: abc def

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement