Basic JavaScript - Manipulate Arrays With unshift()

Tell us what’s happening:
Describe your issue in detail here.
Can somebody please explain why i cant figure this 1 out ,

Your code so far

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


// Only change code below this line
 
myArray.shift();  [ [ 'dog', 3 ] ]; my vscode :  [ [ 'dog', 3 ] ]
myArray.unshift(["Paul",  35]);   my vscode : [[ 'Paul', 35 ], [ 'dog', 3 ]]


// i also tried    myArray.unshift([35]);
                                 myArray.unshift(["Paul"]);

I Am really lost over here with this one ,  or is this a system error ? 


Your browser information:

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

Challenge: Basic JavaScript - Manipulate Arrays With unshift()

Link to the challenge:

myArray.shift();
myArray.unshift([“Paul”, 35]);

// this was the code i tried , the picture is a bit weird , but can anybody please explain what is going wrong with me not being able to change the

const myArray = [[“John”, 23], [“dog”, 3]];

// to [[ “Paul”, 35], [ ‘dog’, 3]];

is it maybe due to the missing double quotes ? really weird why my double quote input changes to single quote output

The default code for this is:

// Setup
const myArray = [["John", 23], ["dog", 3]];
myArray.shift(); //<--- already set up for you

// Only change code below this line
// your code should go here <----

but in “Your code so far” you have code that looks like its explaining what is going on, but also some extra random code that makes it a little hard to tell where you might have gone wrong. You should only need one unshift, nothing more. Single and double quotes work the same and should not matter here.

ok but do yo maybe know the solution to this ? my only solution would be myArray.unshift([“Paul”, 35]); but when i try this it wont pass

If you can post your full code, because that should work.

// Setup
const myArray = [[“John”, 23], [“dog”, 3]];

// Only change code below this line

so the above had to be changed to be added to the begin with .unshift([“Paul”, 35]);

first you had to use , myArray.unshift(); // so the ["John ", 23] would dissappear.

and than use myArray.unshift(); ?

The default code had a shift in it. If you reset the code it should add it back, then just put your unshift under the commented code.

you mean this : ?
myArray.shift();
myArray.unshift([“Paul”, 35]);

Something like that yes.

llmao , i forgot that the .shift(); was already added :zipper_mouth_face: sorry , tnx

If you reset the code and only added that unshift and didnt mess with anything else then maybe. If this is basically what you have then it might be a minor issue with your browser, the test works for me. You can restart your browser, clear the cache or try it in private mode and see if it works.

// Setup
const myArray = [["John", 23], ["dog", 3]];
myArray.shift();

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

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