Simplifying if else

@yisrael-wix there are around 3000 lines of code on this one, probably too much, but in short I have a dataset with various items created by a user, they contain a numerical value in each item, I am querying the records by month, and adding them up, these results I want to display on a graph starting with the month 11 months ago, up to the current month, i.e., covering 12 months.

Here’s some of the relevant stuff, maybe you could help me sort this out:

export function monthValue9(
    owner
) {
    var date = new Date(); // full date today
    var start = new Date(date.getFullYear(), date.getMonth() - 9, 1);
    var end = new Date(date.getFullYear(), date.getMonth() - 8, 0);
    var x = new Date();
    x.setDate(1);
    x.setMonth(x.getMonth() - 9);

    let month_number_minus9 = (x.getMonth()); // current month in a number 0 - 11

    specificationValue(owner, start, end).then(result => {
            let month_minus_9 = result;
            month_minus_10(
                owner,
                month_minus_9,
                month_number_minus9
                
                // done for every month from current to 11 months ago... when complete, populateChart() with all datasets passed to it
            );
        })
        .catch(error => {
            console.log(error);
        });
}



export async function populateChart(
    owner,
    month_current,
    month_minus_1,
    month_minus_2,
    month_minus_3,
    month_minus_4,
    month_minus_5,
    month_minus_6,
    month_minus_7,
    month_minus_8,
    month_minus_9,
    month_minus_10,
    month_minus_11,
) {

   

    let months = [
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
    ];

    let currentMonth = new Date().getMonth();
    let monthsB = months.splice((currentMonth + 1) % 12).reverse();
    months = months.reverse();
    months.push(monthsB);
    months = months.flat();

    let label = [
        months[0],
        months[1],
        months[2],
        months[3],
        months[4],
        months[5],
        months[6],
        months[7],
        months[8],
        months[9],
        months[10],
        months[11]
    ];

    let data = [
        month_current,
        month_minus_1,
        month_minus_2,
        month_minus_3,
        month_minus_4,
        month_minus_5,
        month_minus_6,
        month_minus_7,
        month_minus_8,
        month_minus_9,
        month_minus_10,
        month_minus_11
    ];

    let background_colour = [
        "rgba(54, 162, 235, 0.2)",
        "rgba(255, 206, 86, 0.2)",
        "rgba(75, 192, 192, 0.2)",
        "rgba(153, 102, 255, 0.2)",
        "rgba(255, 159, 64, 0.2)",
        "rgba(255, 99, 132, 0.2)",
        "rgba(85, 162, 235, 0.2)",
        "rgba(33, 206, 86, 0.2)",
        "rgba(180, 192, 192, 0.2)",
        "rgba(153, 102, 255, 0.2)",
        "rgba(200, 159, 64, 0.2)",
        "rgba(100, 99, 132, 0.2)"
    ];

    let border_colour = [
        "rgba(54, 162, 235, 1)",
        "rgba(255, 206, 86, 1)",
        "rgba(75, 192, 192, 1)",
        "rgba(153, 102, 255, 1)",
        "rgba(255, 159, 64, 1)",
        "rgba(255, 99, 132, 1)",
        "rgba(85, 162, 235, 1)",
        "rgba(33, 206, 86, 1)",
        "rgba(180, 192, 192, 1)",
        "rgba(200, 102, 255, 1)",
        "rgba(255, 159, 64, 1)",
        "rgba(100, 99, 132, 1)"
    ];

    let items = {
        label: label,
        data: data,
        background_colour: background_colour,
        border_colour: border_colour
    };

    console.log(items);
    let chart = new ChartJSAPI($w('#specificationTimeline'));
    chart.customization = chartCustomization;

    console.log(label);
    console.log("data");
    console.log(data);
    console.log(background_colour);
    console.log(border_colour);

    chart.data = {
        label,
        datasets: [{ data }] //, background_colour, border_colour
    }

    $w('#specificationTimeline').show();
    $w('#specificationTimeline').expand();
}

I am creating arrays with the data I am passing in to the function, then attempting to display them on the chart. When I created an object (items) and I couldn’t map the results to the chart, so this seems to be a bit of experimenting