Is it possible to condense this code? I have three functions, each assigned to an anchor tag which gets called onclick.

Is there a way to condense this code? It seems redundant to have three function calls which do the same thing except the value is different for each.

var winnings = 0;

function add20() {
    winnings += 20;
    document.getElementById("winnings").innerHTML = winnings;
}

function add40() {
    winnings += 40;
    document.getElementById("winnings").innerHTML = winnings;
}

function add60() {
    winnings += 60;
    document.getElementById("winnings").innerHTML = winnings;
}
You could just create one function, like this:

function add(x) { 
    winnings += x; 
    document.getElementById("winnings").innerHTML = winnings;
}


But if you need three different versions, you could always do this:

var winnings = 0;
function addX(x) { 
    return function() { 
        winnings += x; 
        document.getElementById("winnings").innerHTML = winnings;
    }
}

var add20 = addX(20);
var add40 = addX(40);
var add60 = addX(60);


Or even more simply:

function add(x) { 
    winnings += x; 
    document.getElementById("winnings").innerHTML = winnings;
}
function add20() { add(20); }
function add40() { add(40); }
function add60() { add(60); }