Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active March 9, 2022 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/c43fc3c0a086c583583fc7605241c45a to your computer and use it in GitHub Desktop.
Save McLarenCollege/c43fc3c0a086c583583fc7605241c45a to your computer and use it in GitHub Desktop.
serializeNestedArray

Given a nested array, write a function to serialize the array i.e return a one-dimensional array containing all the elements. NOTE: Dont use the .push method.

CODE TEMPLATE


function serialize(arr){
// write your code here
}
let arr = [[true,'true',false],[2],[2,3,4],[],[1]];
console.log(serialize(arr));//[true,'true',false,2,2,3,4,1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment