Tell us what’s happening:
I was able to pass all the tests. I’m just wondering if this would be considered hard coding for the tests? If you believe it is, could you give me some hints on directions to go so that the code would be more universal.
Thanks!
Your code so far
function steamrollArray (arr) {
let newArr = [];
const arrTest = (arg) => {
if (Array.isArray(arg) && Array.isArray(arg[0])) {
arrTest(arg[0]);
} else {
for (let j = 0; j < arg.length; j++) {
if (Array.isArray(arg[j])) {
arrTest(arg[j]);
} else {
newArr.push(arg[j]);
};
};
};
};
for (let i = 0; i < arr.length; i++) {
if (!Array.isArray(arr[i])) {
newArr.push(arr[i]);
} else {
arrTest(arr[i]);
}
};
return newArr
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Create a Deep Flattening Tool - Create a Deep Flattening Tool