179k views
2 votes
HELP PLZ 50 POINTS

What code would add a new array item named "home" to the array below?

var titles = ["score", "points"];

titles.put("home");
titles.push("home");
titles.set("home");
array.push("home");

1 Answer

2 votes

Answer:

titles.push("home");

Step-by-step explanation:

It depends on if you want to change the original array or not, but since you are just adding on I think this is the correct option.

"... 5 ways to add an item to the end of an array. Push, splice, and length will mutate the original array. Whereas concat and spread will not and will instead return a new array. Which is the best depends on your use case" (www.samanthaming.com)

[] Attached is from the same source

-> I think this is correct

Have a nice day!

I hope this is what you are looking for, but if not - comment! I will edit and update my answer accordingly. (ノ^∇^)

- Heather

User Jmatthias
by
3.4k points