Entering calculated data into a database field

Hi. I’m trying to have a database field value be the result of an if/else statement, based on the outcome of a sports game. So the result field will read either “home” or “away” based on whether the home team score >= away team score.
I’m thinking that I need to have a function between the submit button line and the let toInsert line, but nothing works.
Here’s my code so far. If anyone could guide me in the right direction I’d really appreciate it.

import wixData from ‘wix-data’; //the insert function requires you to do this

export function button1_click() { //on clicking the submit button
//Add your code for this event here:

function game1_result() { //function to find the field value of game1_result

var game1_h = $w(“#input11”).value; //declaing the 2 variables
var game1_a = $w(“#input12”).value;

if (game1_h >= game1_a) {
$w(‘#Week1_Predictions2’).setFieldValue(‘game1_result’, “home”);
}
else {
$w(‘#Week1_Predictions2’).setFieldValue(‘game1_result’, “away”);
}
return game1_result;
}

let toInsert = { // defining the columns
‘player_name’: $w(“#input9”).value, //player’s name
‘game1_h’: $w(“#input11”).value, //home team
‘game1_a’: $w(“#input12”).value, //away team
‘game1_result’: game1_result //the value of this field will be the result of the if statement
};

wixData.insert(“Week1_Predictions2”, toInsert)

.then( (results) => { 

let item = results;
})
}

console.log(‘results’);