A Pen by Michael Russell on CodePen.
Last active
April 19, 2016 22:36
-
-
Save subhaze/ff54ca5c9a05671c542be8d2684b1fed to your computer and use it in GitHub Desktop.
concatAll [Array#reduce]
This file contains hidden or 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
<pre style="padding: 20px"><code class="hljs js"> | |
function concatAll(list){ | |
return list.reduce((acc, curr) => | |
acc.concat(curr) | |
, []); | |
} | |
console.log(concatAll([[1,2,3], [4,5,6]])); | |
// [1, 2, 3, 4, 5, 6] | |
</code></pre> |
This file contains hidden or 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
function concatAll(list){ | |
return list.reduce((acc, curr) => | |
acc.concat(curr) | |
, []); | |
} | |
console.log(concatAll([[1,2,3], [4,5,6]])); | |
hljs.initHighlightingOnLoad() |
This file contains hidden or 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
function concatAll(list){ | |
return list.reduce(function(acc, curr){ | |
return acc.concat(curr); | |
}, []); | |
} | |
// console.log(concatAll([[1,2,3], [4,5,6]])); |
This file contains hidden or 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 src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script> |
This file contains hidden or 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
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/tomorrow-night-eighties.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment