+ 5
Defining the flip variable outside the function will make it as you want.
JavaScript Code :
var flips = 0;
function flipCoin(){
// Array for the outcomes possible
var choice = ["Heads", "Tails"];
// Generates random choice of heads or tails
var result = choice[Math.floor(Math.random() * choice.length)];
document.getElementById("result").innerHTML ="Result: " + result;
flips = flips + 1;
// Logs the result of the role
console.log("Flip " + flips + " Result: " + result);
}



