How is logging an array to console, the entire process, different than a string?

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

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

condiments.push('bbq','Secret Family Recipe');


Here is the exercise: Arrays

For some reason actually logging to console is not working with the same strategy as just using a string:

The below is an example of a string:

newYearsResolutions.push('eat good food', 'laugh!');


I think its because newYearsResolutions is undefined??? let newYears = [] ///// newYears.push();


I answered my own question:grin:


Two strings, actually. When pushed to the array they will be separate elements.

When we print an array, such as,


what gets printed is a string representation of the array and its structure…

[ 'Ketchup', 'Mustard', 'Soy Sauce', 'Sriracha' ]

We can also extract the elements in a single string…


Ketchup,Mustard,Soy Sauce,Sriracha

Ideally, logging an array is done by iterating over the elements and printing each one, in turn.

condiments.forEach(x => console.log(x))

Soy Sauce

Not sure if this addresses your question. Please elaborate further if not.


I was able to answer through trial and error but it looked like you use the same console.log process.


i was wrong lol newYears = [‘La’, ‘La’];



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