Im a beginning in JavaScript, practicing/improving my JavaScript skill by doing simple projects I found online.
This is basically a text location game with four buttons. North, South, East, and West. Im trying to add 5 points each time the player goes to a new location once.
How can I make it so, it doesn't add points once a button has been clicked?
<script type="text/javascript">
var score = 0;
function north(){
var message = 'You are now in the kitchen';
alert(message);
document.getElementById("score").innerHTML = score + 5;
}
function west(){
var message='You are now the bathroom';
alert(message);
document.getElementById("score").innerHTML = score + 10;
}
function east(){
var message='You are now your bedroom ';
alert(message);
}
function south(){
var message='You are now in the living room';
alert(message);
}
if(document.getElementById('north').clicked == true)
{
document.getElementById('score') = score + 5;
}
else if(document.getElementById('west').clicked == true){
document.getElementById('score') = score + 5;
}
</script>
</head>
<body>
<div id='wrap' />
<header>
<h1> Exploring New Apartment </h1>
</header>
<section>
<article id='textarea'>
<textarea cols='30' rows='5' placeholder='You are currently the living room'></textarea>
<br />
<strong> Score: </strong> <p id='score' style="display:inline">0</p>
</article>
<article>
<div>
<input type='button' value="north" onclick='north()' id='north'/>
<br />
<input type='button' value='west' onclick='west()' />
<input type="button" value='east' onclick='east()'/>
<br />
<input type='button' value='south' onclick='south()'/>
</article>
</section>
<footer>
<p> <a href="mailto:tenkdarko@gmail.com"> Contact Us Via Email </a>
</footer>
</div>
</body>
</html>