This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"version":1,"resource":"file:///Users/paulfitzgerald/Desktop/app-eng/code/data/ui/src/swift/MatchesPage.tsx","entries":[{"id":"aBx8.tsx","timestamp":1657879035527},{"id":"te8x.tsx","timestamp":1657879052777}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flatten = (arr) => arr.reduce(function (flat, toFlatten) { | |
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten); | |
}, []); | |
const multiDimensionalArray = [[1,2,[3]],4]; | |
const flattenedArray = flatten(multiDimensionalArray); | |
it('flattens an array of arbitrarily nested arrays of integers into a flat array of integers', () => { | |
assert.equal(flatten([[1,2,[3]],4]), [1, 2, 3, 4]) | |
}) |