I have a JSON object that I want to iterate through.
"phone": {
"Samsung": {
"type": "S7"
},
"iPhone": {
"type": "6S"
},
"Google": {
"type": "Pixel"
}
}
I'm using Object.key
to map through each of these values, which I THINK is the correct way to work with objects:
render() {
//this.props.phone contains the objects "Samsung", "iPhone", and "Google"
return (
Object.keys(this.props.phones).map((type) => {
console.log(type)
return (
<p>Type of phone: {type}</p>
)
})
)
}
However, the console.log
above returns this when I was expecting an object to return:
Why is it returning a value, and not an object?