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

2 Likes

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

1 Like

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.

11 Likes

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

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!

26 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 : )

4 Likes

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

For the comic strip to appear, just do:
comicStrip = [ ‘Codey sees the trail’, ‘Codey starts the hike’, ‘Codey is halfway’, ‘Codey reaches the finish’ ]

Don’t include my list. It will only show up blank.

I spent 10 minutes not being able to figure out why it was just staying blank. Only to realize that I forget to capitalize all the C’s in Codeys name. Im sure I was not the only one and maybe this can help someone who sees this in the future.

2 Likes

the same happened to me I forgot to capitalize s in comicStrip

1 Like

remove mylist = [3] from your code as it does nothing for the code. It should just say selection = myList[3] after you’ve built your list.

same here sir/ma, but it was after i figured it out then rechecking people’s comment to see if i can find something new, behold i saw this, lol… thanks

I check all helpful topics here but still don’t work. until I check this word “comicStrip” …big Strip

first of all you need to select the item from the list and then only you can save it to the variable selection
//////forexample
// 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
comicStrip[3]

// and save it to the variable selection
selection = comicStrip[3]

Hope this will help
Happy coding : )

This Is very helpful! Thank you