Hello, any idea to print this object

Hello, any idea to print this object:

let car = {
“01”: {
“id”: “01”,
“nombre”: “Camaras de seguridad epcom”,
“cantidad”: 1,
“precio”: 250
},
“02”: {
“id”: “02”,
“nombre”: “Camaras de seguridad cyber power”,
“cantidad”: 1,
“precio”: 250
}
}.

When I try to print car with map I get the message:

Uncaught (in promise) Error: TypeError: car.map is not a function.

Thank you

yes, you are trying to use MAP that its for arrays
so wrap the items in square brackets [ … ] not curly braces{ … }

Array.prototype.map() - JavaScript | MDN (mozilla.org)

let car = [
“01”: {
“id”: “01”,
“nombre”: “Camaras de seguridad epcom”,
“cantidad”: 1,
“precio”: 250
},
“02”: {
“id”: “02”,
“nombre”: “Camaras de seguridad cyber power”,
“cantidad”: 1,
“precio”: 250
}
].
1 Like
let car = {
  '01' : {
    id: '01',
    nombre: 'Camaras de seguridad epcom',
    cantidad: 1,
    precio: 250
  },
  '02' : {
    id: '02',
    nombre: 'Camaras de seguridad cyber',
    cantidad: 1,
    precio: 250
  }
};
Object.values(car).forEach(i => console.log(i));
{ id: '01', nombre: 'Camaras de seguridad epcom', cantidad: 1, precio: 250 }
{ id: '02', nombre: 'Camaras de seguridad cyber', cantidad: 1, precio: 250 }
1 Like