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

Popular posts from this blog

Code Wars: longest_palindrome (6 kyu)

Code Wars: Find the odd int