Question: Javascript Write the function popAndShift(). The function has to first print the the contents of the arrays array1 and array2. After this, the elements of

Javascript

Write the function popAndShift(). The function has to first print the the contents of the arrays array1 and array2. After this, the elements of array2 will be deleted, alternating between the .pop() and .shift() methods (starting with .pop()), while adding the removed values to the end of array1. Finally, the contents of array1 will be printed.

Note! The automatic test takes care of assigning values to the arrays.

Example output:

First array: first,second

Second array: third,fourth

Resulting array: first,second,fourth,third

The verification of program output does not account for whitespace characters like " ", "\t" and " "

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!