Code is behaving. I’m just not understanding. How exactly does .slice work? (In very simple terms, please, I am so very new to this)
This exercise asked for “You’re in a hurry so you decide to ask a friend to help you with your grocery shopping. You want him to pick up the bananas, coffee beans, and brown rice.
Use .slice() to provide him with a list of these three things.
Log this part of the list to the console. Unlike the two previous checkpoints, you should do both of these steps in one line.”
My questions are
- why are there only two numbers (1, 4) in the .slice line when I’m supposed to be making a list of three things?
- The instructions ask for both steps in one line, but then it has console.log(groceryList); under it again. Is that just to print the whole list again?
This is the code it gave me when I gave up, so this is what the lesson is asking for.
let groceryList = [‘orange juice’, ‘bananas’, ‘coffee beans’, ‘brown rice’, ‘pasta’, ‘coconut oil’, ‘plantains’];