So the idea is to make the perfectcookie.png change to brokencookie.png when the user gets to a 150 "cookies", when the cookiecount gets to 150. I'm new to javascript so there may be multiple mistakes.
var cookiecount = 0;
function add() {
cookiecount += value;
document.getElementById('text').innerHTML = cookiecount;
}
document.title = cookiecount + " Cookies"
function upgrade() {
if (cookiecount >= 50) {
value += 1;
cookiecount -= 50;
}
else {
alert("Not enough cookies!");
}
}
function victory () {
if (cookiecount >= 150) {
document.getElementById(cookie).innerHTML = "brokencookie.png";
}
}
<center>
<a href="#" onclick=add() onclick=victory()><img src="perfectcookie.png" id="cookie"></a>
<br><br>
<p class="maintext">You Got:</p>
<span id="text" style="font-family: Elephant, serif; padding: 0px;"></span>
<br><br>
<div class="upgrade">
<a href="#" onclick=upgrade()><img src="pointer.png" height="100px" padding="50S"></a>
</div>
</center>