You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

562 B

splitStringIntoPairs

Instructions

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 ('_')

Expected function

function  splitStringIntoPairs(str) {
}

Usage

Here is a possible program to test your function :

console.log(splitStringIntoPairs("abc"));
console.log( splitStringIntoPairs("abcdef"));

And its output :

$ node index.js
$ ['ab', 'c_']
$ ['ab', 'cd', 'ef']