Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short solution in Clear category for [old] Flatten a List by SaintDron
"use strict";
var flatList = (array) => array.join().split(',').filter(v => v).map(v => +v);
var assert = require('assert');
if (!global.is_checking) {
assert.equal(flatList([1, 2, 3]), [1, 2, 3], "First");
assert.equal(flatList([1, [2, 2, 2], 4]), [1, 2, 2, 2, 4], "Second");
assert.equal(flatList([[[2]], [4, [5, 6, [6], 6, 6, 6], 7]]), [2, 4, 5, 6, 6, 6, 6, 6, 7], "Third");
assert.equal(flatList([-1, [1, [-2], 1], -1]), [-1, 1, -2, 1, -1], "Four");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Sept. 1, 2018