Code Wars: Data Reverse (6 kyu)
Link to code challenge
Code efficiency: Loops through string once (from the end) and with one new variable. String splicing- consider its efficiency? Try not to manipulate data when looping for efficiency.
function dataReverse(data) {
let arr = [];
while (data.length) {
arr.push(...data.splice(data.length - 8, data.length));
}
return arr;
}
Comments
Post a Comment