Do I need to use mylist?

Help please! This is the code I put in and when I try to run it, all I see is a blank space. Also, the solution button does not pop up for me. I guess it’s cause I’m using a VERY old laptop. Anyways, here is the code I used.

// Build a list
myList = comicStrip

comicStrip = [‘Codey sees the trail’, ‘Codey starts the hike’, ‘Codey is halfway’, ‘Codey reaches the finish’]

myList[3]

comicStrip = myList[3]
// select the 4th item from the list
// and save it to the variable selection

Any help would be appreciated. Thank you

what language is this? the syntax looks very much like python, but // are not python comments.

The language is javascript. The // and instructions were already there before writing the code. Maybe I have to delete them before running the code? Not sure :confused:

myList and comicStrip are not separate arrays, but one and the same. myList is a reference only to comicStrip.

selection = comicStrip[3]

will be the same as,

selection = myList[3]

since they are both drawn from the same array.

3 Likes

mtf is right, i didn’t recognize the language as JS given no var, let or const are present

1 Like

I found the solution button so I got the answer. Thank you guys for the help!!

1 Like

For anyone else who is still struggling the answer is:

// Build a list
comicStrip = ['Codey sees the trail', 'Codey starts the hike', 'Codey is halfway', 'Codey reaches the finish']


// select the 4th item from the list
// and save it to the variable selection
selection = comicStrip[3]

Building off of mtfs answer, mylist and comicStrip are interchangable for this specific exercise (not sure if it needs to specifically defined in a real application). The selection statement is refering to your create “list” in my example above I defined it as comicStrip. Whatever number your define within [xx] selects the strings available in your “list”.

So for this problem a valid value would be 0-3, anything outside of these values would be an invalid selection.

Hopefully this helps!

3 Likes

OMG…thank you! :slight_smile:

That was extremely helpful.

I’ve gone through this exercise 5 times and I can’t find anything wrong with my code, but I’m not being allowed to pass.

Any help would be appreciated.

comicStrip = [‘Codey sees the trail’, ‘Codey starts the hike’, ‘Codey is halfway’, ‘Codey reaches the finish’]
selection = comicStrip[3]

I am having the same problem, this is the only thing the solution button brought me to. I have checked everything on here and have solved the problem, no next button. I have also just answered incorrectly a bunch on purpose for this fabled solution button have yet to see anything.

The correct code for anyone struggling is the following - it is the 1st line where i was going wrong but managed to work it out

// Build a list
myList = comicStrip = [‘Codey sees the trail’, ‘Codey starts the hike’, ‘Codey is halfway’, ‘Codey reaches the finish’]

// select the 4th item from the list
mylist = [3]
// and save it to the variable selection
selection = myList[3]

Hope this helps : )

1 Like

I think maybe it has something to do with your apostrophe. I copied your code and the color was all red so I thought it may have something to do with the format. I deleted the apostrophe before Codey sees the trail and typed back in an apostrophe and it worked.

1 Like