Question: The JavaScript code segment below calls a function magicArray that has two array parameters ( arr1 and arr2 ). The function is intended to createand
The JavaScript code segment below calls a functionmagicArraythat has two array parameters (arr1 and arr2). The function is intended to createand return an array arr3 that will contain all of the elements of arr1 followed by all of the elements of arr2.
Two Examples:
arr1 | arr2 | arr3 (this array is returned) |
1, 2, 3, 4 | 9, 8, 7, 6, 5 | 1, 2, 3, 4, 9, 8, 7, 6, 5 |
11, 21, 34, 46 | 98, 72 | 11, 21, 34, 46, 98, 72 |
The code segment below also calls a functionprintArraywhich prints the elements of an array in a vertical format. Your code should work as intended for arrays of any size.

function magicArray(arrl, arr2) { var arr3 = //create the new array here // Missing Code return arr3; } function printArray(arr) { } //Missing Code var a = new Array(1, 11, 8, 4); var b = new Array(9, 17, 6, 8, 13); var c= magicArray(a,b); //call to your function that returns the newly created array document.write("Array a: "); printArray(a); document.write("Array b: "); printArray(b); document.write("Array c: "); printArray(c); Array a: 1 11 8 4 Array b: 9 17 6 8 13 Array c: 1 11 8 4 9 17 6 8 13
Step by Step Solution
There are 3 Steps involved in it
Heres the corrected JavaScript code with working magicArray and printArray functions JavaScript func... View full answer
Get step-by-step solutions from verified subject matter experts
