Took 4 minutes 9 seconds to implement JavaScript merge() function for same length arrays. Here is the code snippet.Function:
arr1 = ['bla', 'bla', 'bla'];
arr2 = ['ha', 'ha', 'ha'];
function merge(arr1, arr2) {
for (var i = 0; i < arr2.length; i++) {
arr1.push(arr2[i]);
}
}
merge(arr1, arr2);
document.write(arr1)
bla,bla,bla,ha,ha,ha
No comments:
Post a Comment