'Js .map giving unexpected results
this is my code for map and this is giving unexpected results:
console.log('results', results);
let newResults = [...results];
newResults = results.map((el) => {
console.log('el.props.i', el.props.i);
let newEl = {
price: el.props.i?.p.price,
time: el.props.i?.routes[0].time,
};
console.log('newEl', newEl);
return newEl;
});
u can check the logs here
output:
newResults [
{
"price": "159.88",
"time": "26h 00m"
},
{
"price": "159.88",
"time": "26h 00m"
},
{
"price": "159.88",
"time": "16h 00m"
}
]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
