console.log doesn’t run in a function that is assigned to a button with “onclick”

I have a $10 button <button onclick="$10Wager">$10</button> that the user clicks if he wants to wager $10 and $10 will be deducted from his chips

The code in js:

let player = {
    name: "Per",
    chips: 200
}

function $10Wager(){
    return player.chips -= 10
    console.log(player.chips)
}

Why doesn’t the final value of the player’s chips after deduction of the $10 wager (i.e. 190) display on the console? could u also explain the logic?

What code should I use to ensure that the $10 button is working?

Answer

Try this code
You use JS function but when you calling you function using onclick here you forget to use
fucntion brackets ()

    let player = {
        name: "Per",
        chips: 200
    }

  function $10Wager(){
    player.chips -= 10
    console.log(player.chips);
    return player.chips;
}
  <button onclick="$10Wager()">$10</button>