Trying to get an 'if' condition to work within a data_generator element of an Apexchart card

I am using this code in my card configuration:

data_generator: |
      let data = [];
        if (entity.attributes.raw_tomorrow === "-") {
          entity.attributes.forecast.map((hour, index) => {
          data.push([new Date(hour["hour"]).getTime(), entity.attributes.forecast[index]["price"]]);        
        });
        } else {
            entity.attributes.raw_tomorrow.map((hour, index) => {
            data.push([new Date(hour["hour"]).getTime(), entity.attributes.raw_tomorrow[index]["price"]]);
        });
        }
      return data;

When the condition is not met, data is shown in accordance with the ‘else’ part.

When the condition is met, nothing is shown.

If I make a card without the condition, data is shown:

data_generator: |
      let data = [];
          {
            entity.attributes.forecast.map((hour, index) => {
            data.push([new Date(hour["hour"]).getTime(), entity.attributes.forecast[index]["price"]]);        
        });
        }
      return data;

Now, why does half the condition work and the other half not?

Hope someone can point me to a fix here
Thanks

Got it working. This is a working code:

type: custom:apexcharts-card
experimental:
  color_threshold: true
graph_span: 1d
hours_12: false
yaxis:
  - min: 0
header:
  title: Energy price tomorrow (dkk/kWh)
  show: true
span:
  start: day
  offset: +1d
series:
  - entity: sensor.energi_data_service
    color_threshold:
      - value: 0.5
        color: blue
      - value: 1.5
        color: cyan
      - value: 2.5
        color: orange
      - value: 3.5
        color: red
    type: column
    float_precision: 2
    data_generator: |
      let data = [];
        if (entity.attributes.tomorrow_valid === false) {
          entity.attributes.forecast.map((hour, index) => {
          data.push([new Date(hour["hour"]).getTime(), entity.attributes.forecast[index]["price"]]);        
        });
        } 
        else {
          entity.attributes.raw_tomorrow.map((hour, index) => {
          data.push([new Date(hour["hour"]).getTime(), entity.attributes.raw_tomorrow[index]["price"]]);
        });
        }
      return data;