Arrays Section 8 or 9 Part q


#1

I’m stuck on the first part of part 8. It says to go below the two arrays (Condiments and Utensils) and use .push() to add your favorite condiments to the array and then console log it out. I have the following:

let condiments = ['Ketchup', 'Mustard', 'Soy Sauce', 'Sriracha'];

const utensils = ['Fork', 'Knife', 'Chopsticks', 'Spork'];

condiments.push('BBQ Sauce','Aioli');
console.log(condiments);

Which produces the desired result but I keep getting an X telling me I’ve done something wrong. Maybe just a 2nd pair of eyes would help.


#2

A link to the exercise will be helpful for us to be able to test your code.


#3

https://www.codecademy.com/courses/learn-javascript-arrays/lessons/arrays/exercises/let-const-arrays


#4

Below the two existing arrays, add your favorite condiment to the condiments array using .push().

Not the plural. The SCT may be expecting only one condiment.

Try,

condiments.push('BBQ Sauce');

#5

Oh uh. That makes sense but what a silly thing to get hung up on.


#6

That did it. Thank you.


#7

It’s unfortunate, but that is what happens when we teach what to think rather than how to think. Your code is fine (correct syntax) but the SCT is limited. We don’t have a lot of wiggle room when it comes to liberties or incorrect interpretation of the instructions. A minor wrinkle in the big picture.


#8

And true to code the idiosyncrasies of a code can drive the coder crazy
trying to figure out what they are doing wrong :slight_smile:


#9

Here is what I do in Chrome:

  • open a lesson
  • open a new tab
  • navigate new tab to about:blank
  • Ctrl + Shift + j to open JS console
  • copy function from lesson to command line in console
  • enter

Bottom line, keep a sandbox open to test lesson code in the real world. The console lets us see the errors and exceptions, as well as expected output when no errors.

Once we pass a lesson we can still use that environment as a sandbox to test other ideas. Note the outputs to see if they meet expectations.


#10

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