Hi Everyone! First time post and enjoying javascript. However, I can't seem to figure out how to append to the array and for the if statement to check if the variable got pushed into the array.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
var chosen=[];
var feat=function(chosenfeat){
if (chosenfeat==="den"){
if (chosen.indexOf("den")){
document.getElementById('denid').checked=false;
alert("Are you sure you don't want a Den? They are free!");
chosen.splice(chosen.indexOf("den",1))}
else {
chosen.push=("den");
alert("Congradulations! You recieve a complimentary free den!");
console.log(chosen);}
}
}
</script>
</head>
<body>
<input type="checkbox" id="denid" onclick="feat('den');" />Den (NO CHARGE)<br />
</body>
</html>