I am using this code as a part of a game I'm making. But for the purposes of finding out what was causing this bug I took the section of code into a new html document. I am trying to use this code:
<html>
<script type="text/javascript">
Difficulty = Normal
function ChangeGameMode()
{
alert (Difficulty + ' game started ');
}
</script>
<button type="button" class="StartButton" onclick="ChangeGameMode()">Start</button>
</html>
When I click the button, I don't get an alert. Nothing happens.
But if I don't use the Difficulty variable in the alert - ie:
alert ('Normal' + ' game started ');
Then when I use that for the alert instead, it does work. I am at conplete loss as to what is causing this and I have been pulling my hair out because of it. Any help would be appreciated.
Normalvariable? Did you want a string?