Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Shortest solution possible solution in Clear category for Split Pairs by _Gregory
import assert from "assert";
function splitPairs(text: string): string[] {
return (text + "_").match(/(\w.)/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!");
Oct. 10, 2020
Comments: