var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
var myArray = [["John", 23], ["cat", 2]];
// Only change code below this line.
its just showing this
myArray should only contain
[["John", 23]] .
You should use
removedFromMyArray should only contain
["cat", 2] .
It would be a lot easier to help if you provided a link to the challenge.
pop() returns the removed item, so you gotta hand it over to where it should be stored, not exactly but in language somewhat like this:
the_removed_portion EQUALS the full array.pop()
Your solution works in terms of values, but it is actually a bit cheating. What if your array has an unknown number of entries and you want to remove the last item? Then myArray wouldn’t work.
pop() function in javscript removes last element in array
i know and im doing it but it keeps showing that i am the wrong coding
let removedFromArray = myArray.pop();
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (
</>) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.