For each of the exercises below, assume you are starting with the following people array. and use javascript var people = ["Greg", "Mary", "Devon", "James"]; Using a loop, iterate through this array and write each element of the array people on the web document. Write the command to remove "Greg" from the array. Write the command to remove "James" from the array. Write the command to add "Matt" to the front of the array. Write the command to add your name to the end of the array. Write the command to make a copy of the array using slice. The copy should NOT include "Mary" or "Matt". Write the command that gives the indexOf where "Mary" is located. Write the command that gives the indexOf where "Foo" is located (this should return -1 as “Foo” not exist). Redefine the people variable with the value you started with. Using the splice command, remove "Devon" from the array and add "Elizabeth" and "Artie". Your array should look like this when you are done ["Greg", "Mary", "Elizabeth", "Artie", "James"]. Create a new variable called withBob and set it equal to the people array concatenated with the string of "Bob". Display the elements in both ascendant and descendant orders.
For each of the exercises below, assume you are starting with the following people array. and use javascript var people = ["Greg", "Mary", "Devon", "James"]; Using a loop, iterate through this array and write each element of the array people on the web document. Write the command to remove "Greg" from the array. Write the command to remove "James" from the array. Write the command to add "Matt" to the front of the array. Write the command to add your name to the end of the array. Write the command to make a copy of the array using slice. The copy should NOT include "Mary" or "Matt". Write the command that gives the indexOf where "Mary" is located. Write the command that gives the indexOf where "Foo" is located (this should return -1 as “Foo” not exist). Redefine the people variable with the value you started with. Using the splice command, remove "Devon" from the array and add "Elizabeth" and "Artie". Your array should look like this when you are done ["Greg", "Mary", "Elizabeth", "Artie", "James"]. Create a new variable called withBob and set it equal to the people array concatenated with the string of "Bob". Display the elements in both ascendant and descendant orders.
Chapter6: Using Arrays
Section: Chapter Questions
Problem 5E
Related questions
Question
For each of the exercises below, assume you are starting with the following people array. and use javascript
var people = ["Greg", "Mary", "Devon", "James"];
- Using a loop, iterate through this array and write each element of the array people on the web document.
- Write the command to remove "Greg" from the array.
- Write the command to remove "James" from the array.
- Write the command to add "Matt" to the front of the array.
- Write the command to add your name to the end of the array.
- Write the command to make a copy of the array using slice. The copy should NOT include "Mary" or "Matt".
- Write the command that gives the indexOf where "Mary" is located.
- Write the command that gives the indexOf where "Foo" is located (this should return -1 as “Foo” not exist).
- Redefine the people variable with the value you started with. Using the splice command, remove "Devon" from the array and add "Elizabeth" and "Artie". Your array should look like this when you are done ["Greg", "Mary", "Elizabeth", "Artie", "James"].
- Create a new variable called withBob and set it equal to the people array concatenated with the string of "Bob".
- Display the elements in both ascendant and descendant orders.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
Knowledge Booster
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.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning