Here is my code:
  let datasets = data.map(
    item => ({
      "label": item.name,
      "data": item.prices.map(nested => ({
        if( /* Last row */ ){
          "x": new Date(nested.updatedAt),
          "y": Number(nested.price)
        } else {
          "x": new Date(nested.createdAt),
          "y": Number(nested.price)
        }
      }))
    })
  );
I cannot seem to add an if statement at all to data mapping, above is a sample of what I am aiming to achieve. I tried to do a console.log for a test, it doesn't seem to allow code inside of the data map. Although I found this stackoverflow doing something similar. Any advice?
 
     
     
    