Created
May 18, 2013 11:03
-
-
Save nmoliveira/5604064 to your computer and use it in GitHub Desktop.
function that duplicates an array
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
// function that duplicates an array | |
function duplicateArray(arr) { | |
// create clone of original array using slice | |
var cloneArr = arr.slice(); | |
// concat original array and clone array in one new array (the objective!!) | |
var dupArr = arr.concat(cloneArr); | |
//return the new array | |
return dupArr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment