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.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter6: Using Arrays
Section: Chapter Questions
Problem 5E
icon
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"];

  1. Using a loop, iterate through this array and write each element of the array people on the web document.
  2. Write the command to remove "Greg" from the array.
  3. Write the command to remove "James" from the array.
  4. Write the command to add "Matt" to the front of the array.
  5. Write the command to add your name to the end of the array.
  6. Write the command to make a copy of the array using slice. The copy should NOT include "Mary" or "Matt".
  7. Write the command that gives the indexOf where "Mary" is located.
  8. Write the command that gives the indexOf where "Foo" is located (this should return -1 as “Foo” not exist).
  9. 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"].
  10. Create a new variable called withBob and set it equal to the people array concatenated with the string of "Bob".
  11. Display the elements in both ascendant and descendant orders.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
JQuery and Javascript
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning