Created
November 9, 2018 03:03
-
-
Save AminBusiness/b47b0ed896fdb40830752b9fe3ede5fc to your computer and use it in GitHub Desktop.
// source https://jsbin.com/gavovuh
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
<script id="jsbin-javascript"> | |
//Challenge 9 Flatten array | |
//Take an array of arrays and flatten to a single array | |
function flattenArray(arrays) | |
{ | |
return arrays.reduce(function(a,b) | |
{ | |
return a.concat(b); | |
}) | |
} | |
const output = flattenArray([[1,2], [3,4], [5,6], [7]]); | |
console.log(output); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//Challenge 9 Flatten array | |
//Take an array of arrays and flatten to a single array | |
function flattenArray(arrays) | |
{ | |
return arrays.reduce(function(a,b) | |
{ | |
return a.concat(b); | |
}) | |
} | |
const output = flattenArray([[1,2], [3,4], [5,6], [7]]); | |
console.log(output);</script> |
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
//Challenge 9 Flatten array | |
//Take an array of arrays and flatten to a single array | |
function flattenArray(arrays) | |
{ | |
return arrays.reduce(function(a,b) | |
{ | |
return a.concat(b); | |
}) | |
} | |
const output = flattenArray([[1,2], [3,4], [5,6], [7]]); | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment