Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                <!--
Name:		Mukhammadkhon Tadjiev...
Date:		January 30, 2020
Purpose:	Lab 3 Maybe -
-->
<!DOCTYPE html>
<html>    

<head>
    <title>Lab 2</title>
    <h1>Slot Machine</h1>
</head>

<body>
    <!-- We create few divs in order to dispaly messages through DOM Document object model and for that we use document.getElementById 
      n select the ID we mentioned in DIv of HTML n then through .innerHTML we display that output message on the browser. So DOM manipulation is pretty useful-->
    <div id="display_1">


    </div>

    <br>


    <script>
        // Constant Variables
        const MAX = 4; // The MAX number that will be generated
        const MIN = 1; // The MIN number that will be generated
        const WINRATE = 3; // The amount the winnings are multiplied by

        // TODO: 3. Create Variables
        var cashOnHand = 1000;
        var numberOfRoundsPlayed = 0;
        var numberOfWins = 0;
        var numberOfLosses = 0;

        var playAgain = true;
        var number1 = 0;
        var number2 = 0;
        var number3 = 0;

        //var askAgain = true;

        // TODO: 4. Create Loop 
        for (var i = 0; i <= cashOnHand; i++) {

            var bet = parseInt(prompt("Place your Bet! \n Cash on Hand: $1000"));

            if (bet < 0 || bet > cashOnHand) {

                bet = 0;
                alert("Wrong bet of $  " + bet + " Try again");

            } else {
                cashOnHand = cashOnHand - bet;
                numberOfRoundsPlayed++;
            }

            number1 = Math.floor(Math.random() * (MAX - MIN + 1)) + MIN;
            number2 = Math.floor(Math.random() * (MAX - MIN + 1)) + MIN;
            number3 = Math.floor(Math.random() * (MAX - MIN + 1)) + MIN;


            if (number1 === number2 && number1 === number3) {
                alert("Round " + numberOfRoundsPlayed + ": " + number1 + " | " + number2 + " | " + " | " +
                    number3 + " \n " + "You won $30!");
                numberOfWins++;
                cashOnHand = bet * WINRATE;
            } else {
                (number1 !== number2 && number1 !== number3);
                numberOfLosses++;
                alert("Round " + numberOfRoundsPlayed + ": " + number1 + " | " + number2 + " | " + " | " +
                    number3 + " \n " + "Better Luck Next Time!");
            }





            window.confirm("Play Again ?" + "\n" + "OK == YES" + "\n" + "CANCEL == NO");
            /*if (confirm == true) {
                askAgain = true;
            } else {
                askAgain = false;
            }
            */


            var outputMessage = "Number of Rounds played : " + numberOfRoundsPlayed + '<br>' + "Number of Wins : " +
                numberOfWins + '<br>' + "Number of Losses : " + numberOfLosses + '<br>' + "Remaining Cash on Hand : " +
                cashOnHand;
            document.getElementById("display_1").innerHTML = outputMessage;




























        }




        // TODO: 5. Output
        console.log(bet);
    </script>
</body>

</html>
              
            
!
999px

Console