Write Concise Object Literal Declarations Using Simple Fields- extra Information is needed

Write Concise Object Literal Declarations Using Simple Fields- extra Information is needed
0
#1

How can I log the object’s props’ values?

Your code so far


const createPerson = (name, age, gender) => ({
  name, age, gender

});
console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper object

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-simple-fields

0 Likes

#2

What do you mean “pros’ values”? For the challenge, what you have should complete it.

1 Like

#3

Pros’ means properties
I meant how to get the values (name , age and gender);
the challenge is already done

0 Likes

#4

You already are, the FCC console is turning the object into a string (so you get [Object object], which is what it is). If you open the browser console it will allow you to drill into it. If you want it to print the literal representation of the object in the FCC console, you can use JSON.stringify, like console.log(JSON.stringify(createPerson........

1 Like

#5

Thanks for reply but I want print out each value of the properties just like in object we do x.name or x[‘name’] etc.
With JSON.stringify(....) we can get all the properties and values together.

createPerson.name ....
``` doesn't work here
regards
0 Likes

#6

console.table(createPerson......)? (that’ll work great in the browser console but not the FCC one). As I say, you’re already logging the whole object, it’s accessible in the actual browser console, just not the FCC one

createPerson.name doesn’t work because createPerson is a function. const result = crearePerson(..... then result.name works, because result is the value createPerson evaluates to

1 Like

#7

Got it thank you so much dear DanCouper
best wishes

1 Like

#8

The answer I wanted to get is “const y = x('hrr',40, 'male') console.log(y.name)// hrr

0 Likes