Untitled
4 years ago in Plain Text
var TEST = function () {
return {
exec: function (str, rowNum) {
if (rowNum === 1) { return str; }
let wordRecord = new Array(rowNum);
wordRecord.fill('');
let rowPtr = 0, rowInc = -1, wordPtr = -1, bot = rowNum-1;
while (str[++wordPtr]) {
wordRecord[rowPtr] += str[wordPtr];
if (rowPtr === bot || rowPtr === 0) {
rowInc = rowInc * -1;
}
rowPtr += rowInc;
}
return wordRecord.join('');
}
};
}();