Split Strings

by Igor Cuckovic

JavaScript

function solution(fullText) {
    var tempArr = fullText.match(/../g);
    var last = fullText.charAt(fullText.length-1);
    return tempArr.length < (fullText.length / 2) ? tempArr.concat(last + '_') : tempArr; 
}

console.log(solution('abc'));