loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9204342195785233","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"Y29uc3QgaW5wdXQgPSBbIDEsIDIsIHsnYSc6Mi41fSwgMywgWzQsIFs1LCBbNiwgN10sIDgsIFs5LCAwXV1dIF07DQoNCmNvbnN0IGZsYXR0ZW4gPSAoYXJyKSA9PiB7DQogIGZvcih2YXIgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspew0KICAgIGlmKEFycmF5LmlzQXJyYXkoYXJyW2ldKSl7DQogICAgICBhcnIuc3BsaWNlKGksIDEsIC4uLmFycltpXSkNCiAgICAgIGktLTsgDQogICAgfQ0KICB9DQogIHJldHVybiBhcnI7DQp9Ow0KDQpmbGF0dGVuKGlucHV0KTs="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
const input = [ 1, 2, {'a':2.5}, 3, [4, [5, [6, 7], 8, [9, 0]]] ];

const flatten = (arr) => {
  for(var i = 0; i < arr.length; i++){
    if(Array.isArray(arr[i])){
      arr.splice(i, 1, ...arr[i])
      i--; 
    }
  }
  return arr;
};

flatten(input);
node v10.16.0