Skip to content

Instantly share code, notes, and snippets.

@nmoliveira
Created May 18, 2013 11:03
Show Gist options
  • Save nmoliveira/5604064 to your computer and use it in GitHub Desktop.
Save nmoliveira/5604064 to your computer and use it in GitHub Desktop.
function that duplicates an array
// 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