I'm attempting to reuse the code from here Edit a variable within an array to create something simmilar but less complex.
I made the 'working' function:
var WorkT = function(gain,loss,message) {
coins += this.gain;
coins -= this.loss;
this.message = message;
}
workT1 = new WorkT(30,0,'<span class="red">+ 30 Gold Coins');
workT2 = new WorkT(15,0,'<span class="red">+ 15 Gold Coins');
workT3 = new WorkT(80,0,'<span class="red">+ 80 Gold Coins');
workT4 = new WorkT(1,0,'<span class="red">+ 1 Gold Coin');
WorkTs = [workT1,workT2,workT3,workT4];
And I'm trying to call it later on in my code with this:
$('#output').html(WorkTs[Math.floor(Math.random() * 4)].WorkT());
But, when I click the button, nothing changes. Can anyone tell me why?
WorkTvariable.