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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started