Lack of understanding

Tell us what’s happening:
Nothings happening so far. But I want to ask why should I go through all this when I can just delete the data I don’t want and instead add new data?
Plz explain.
Thank You.

Your code so far

// Setup
var myArray = [["John", 23], ["dog", 3]];

// Only change code below this line
myArray.unshift(["Paul" ,35])


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Manipulate Arrays With unshift()

Link to the challenge:

1 Like

Hello @ameenarab5! You can always test your code by putting any data you like, but to pass the test, you need to have the code freeCodeCamp provides. If you want to play with your code, edit it and put in the data you want and then before clicking “Run Tests”, reset the code and do what’s said in the challenge, and then submit it.

Hope this answers your question.

Thank You
But that’s not what I mean’t . I mean’t in real world .
Why do I have to use .pop() , .shift() , .unshift() when I can simply edit the data?

1 Like

The use cases of those functions are mostly for automated tasks. For example, you may want to have the data inside the array to be an user input. So, you would create a function so that when the user fills in the data and then hits the submit button, change or update the data of the array. So, I think those functions are used for those use cases. Maybe there’s more.

Hope this is the answer.

1 Like

Thank You for sharing knowledge. :slight_smile:

1 Like

You are always welcome