CodeWars || Split Strings || JavaScript || Code Challenge

preview_player
Показать описание
Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_').

Examples:

solution('abc') // should return ['ab', 'c_']
solution('abcdef') // should return ['ab', 'cd', 'ef']
Рекомендации по теме
Комментарии
Автор

this one was so clever, thanks so much for the walkthrough!!

xpiator
Автор

Awesome video! Keep up the great work :)

ComputerScienceSimplified
Автор

very good, you way is more smoother than mine; mine had 25 lines

CMT-pq
Автор

import re
def split_string(s):
re.findall(".{2}", s + '_')

Regular expressions :)

osbornghampson
Автор

Hi, thanks for the video! Could you clarify why you added the line that goes i +=2? Might be a silly question, but it would mean a lot if you could explain? Thank you!

marijastrahinjic
join shbcf.ru