Basic JavaScript - Manipulate Arrays With pop Method

Tell us what’s happening:
Describe your issue in detail here.
when i run the the following code, it brings out an incomplete message in the output box.
const myArray =[[“john”,23] , [cat, 2]];
removeFromMyArray = myArray.pop();
console.log(myArray);
console.log(removeFromMyArray)
Your code so far

// Setup
const myArray = [["John", 23], ["cat", 2]];

// Only change code below this line

const removeFromMyArray = myArray.pop();

console.log(myArray);
console.log(removeFromMyArray);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Manipulate Arrays With pop Method

Link to the challenge:

You have to create const removedFromMyArray you have created removeFromMyArray minor mistake in typing

To display code in your post, put three back tics ` before and after the code block. If you cant find a back tic on your keyboard use ALT+096 to display one.

in the code you have provided:

1) const myArray =[[“john”,23] , [cat, 2]];
2) removeFromMyArray = myArray.pop();
3) console.log(myArray);
4) console.log(removeFromMyArray)

line 1)
not sure what your using around “jonh”. I replaced it with single quotes 'jonh'
add quotes around 'cat'
line 2) removeFromMyArray was not defigned. I added let

once I made these changes, I was able to see the console logs being output

const myArray =[['john',23] , ['cat', 2]];
let removeFromMyArray = myArray.pop();

const myArray = [[“John”, 23],[“cat”, 2]];
removeFromMyArray = myArray.pop();

Its difficult to know if your code is being altered by the browser.
Use three back tics before and after a code block to show your code.

removeFromMyArray still needs a keyword

In second line of your code you have create it const (variable), and change your const to removedFromMyArray
just change it to const removedFromMyArray

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.