Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Split Pairs solution in Uncategorized category for Split Pairs by vvm70
import assert from "assert";
var splitPairs = text => (text ? text.padEnd(text.length + text.length % 2, '_').match(/\w{2}/g) : []);
console.log('Example:');
console.log(splitPairs('abcd'));
// These "asserts" are used for self-checking
assert.deepEqual(splitPairs('abcd'), ['ab', 'cd']);
assert.deepEqual(splitPairs('abc'), ['ab', 'c_']);
assert.deepEqual(splitPairs('abcdf'), ['ab', 'cd', 'f_']);
assert.deepEqual(splitPairs('a'), ['a_']);
assert.deepEqual(splitPairs(''), []);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
June 20, 2020