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 "\n", "\t" and "

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 29SA
icon
Related questions
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 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 "\n", "\t" and "

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,