Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript not running and just printing out entire code on a blank webpage
    primarykey
    data
    text
    <p>Oddly enough i cant see any syntax errors. i am new too javascript but by no means incapable. But whenever i run my code any browser i use just prints out my entire code on a blank webpage without executing any of it. ive never had this problem before. as the codes not being executed i cant use any of the browsers debugging tools. </p> <p>its not like i haven't started the code properly the usual old</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; </code></pre> <p>followed by my code and then closing the tags</p> <p>whats odd is even the above code is being printed on the webpage so its not being recognised as javascript from the very beggining</p> <p>Has anyone had this problem before? am i missing something</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; var die1; // the 3 dice var die2; var die3; var username; // users name var bet = 0; // variable for the amount the user bets var input; // used to check the bet is a number var credits = 100; // users overall credits and starting amount var round = 0; // game rounds , will have a maximum of 10 rounds username = window.prompt("Welcome to Triple Roll! Please enter your name"); // prompts the user to enter their name gamestart; // calls the first function to start the game! var rolldice = function() // puts all 3 dice rolls into a function to be easily called. { die1 = Math.round(Math.random()*6); // random number generators for the 3 dice die2 = Math.round(Math.random()*6); // dieX is an integer (round number) in the range of 1 to 6 die3 = Math.round(Math.random()*6); } var gamestart = function() // Using this function the game can be reset to starting values, The user is also asked if they would like to hear the rules { bet = 0; credits = 100; round = 0; if (window.prompt("Hello" + username ", Do you wish to go over the the instructions? Y/N ")) = "Yes" || "yes" || "y" || "Y" // if the user says yes then show rules , else run the game { confirm(" This game has 10 rounds, at the beginning of the game you will start with 100 credits to bet with. For each round of the game you will bet on the outcome of 3 dice rolls each with numbers 1 through 6. continue?"); confirm(" For each round you may bet between 1 and 100 credits regardless of how many credits you actually have, though be warned if you lose and end up with 0 credits then its game over."); confirm(" The value of all 3 dice will determine whether or not you win or lose credits, but don't worry , you will be able to see how many credits you have at any time"); confirm(" If the 3 die all show a 1 , then you will win 50 times your bet plus the original stake back, If the 3 die all show the same value other than 1 then you win 30 times your bet plus your original stake back"); confirm("If 2 die show the same value, then you win 8 times your bet plus your original bet. If you don't meet any of the requirements but the values of die add up to 15 or more, then you win 2 times your bet plus the original stake."); confirm("If one of the die is a 6 or all 3 of the die are odd numbers, then you get your bet back and may try again. In all other situations you lose your bet"); } else { game; // call the game function } } var game = function() { input = window.prompt("Round" + round ". You have" + credits "credits. Please enter a bet between 0-100"); // shows the user what round it is, how many credits they have and asks them to make a bet bet = parseInt(input); // checks the input is a number if (bet != 0-100); // if the bet isn't between 0-100 { game; // restart the function } else // else { rolldice; // call the roll dice function } confirm(" The Die rolls are" + die1 + die2 + die3); // let user know what the dice values are winoutcomes; // call the function that checks to see if the user has won </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload