IT3049C
IT3049C 3049C
HTML CODE: < html > < head > < title > IT3049CModule3 </ title > < link rel = 'stylesheet' href = 'style.
View the step-by-step solution to:

Question

HTML CODE:

<

style="color:rgb(86,156,214);">html>


<head>

  <title>IT3049C Module 3</title>

  <link rel="stylesheet" href="style.css">

</head>


<body>


<h1>Rock, Paper, Scissors</h1>


<div id="welcomeScreen">

  Welcome to our game... Rock, Paper, Scissors! Please press the start button to begin.

  <br/>

  <button id="startButton">Start</button>

</div>


<div id="gameScreen" class="hidden">


<h2>Please select your choice...</h2>

  <form id="gameForm">

    <select id="userChoice">

    <option value="rock">ROCK</option>

    <option value="paper">PAPER</option>

    <option value="scissors">SCISSORS</option>

  </select>

  <input type="submit" value="BOOM!">

</form>

</div>




  <script src="index.js"></script>

</body>


</html>


JAVASCRIPT CODE-

"use strict";

//Variables used...


const startButton = document.getElementById("startButton");


const welcomeScreen = document.getElementById("welcomeScreen");

const gameScreen = document.getElementById("gameScreen");


const gameForm = document.getElementById("gameForm");




startButton.addEventListener("click"function(startButtonClickEvent){

    startButtonClickEvent.preventDefault();


    console.log("User clicked the start button!!!");


    welcomeScreen.classList.add("hidden");

    gameScreen.classList.remove("hidden");

});



gameForm.addEventListener("submit" , function(gameFormSubmitEvent){

    const userChoice = document.getElementById("userChoice").value;

    console.log("User :" + userChoice);  

    gameFormSubmitEvent.preventDefault();

});



function user(){

    console.log("User: " + userChoice)


    var computerOpt = Math.random();

        if(computerOpt < 0.34)  {

            computerOpt = "rock";

        }else if(computerOpt <= 0.67)  {

            computerOpt = "paper"

        }else{

            computerOpt = "scissors";

        };

        console.log("Computer :" + computerOpt);

        console.log(compare(userChoicecomputerOpt));

        

        function compare(c1c2){

            if(c1 === c2){

                return "The result is a tie!";

            }

            if(c1 ==="rock"){

                if(c2 === "scissors"){

                    return "rock wins";

                }else{

                    return "paper wins";

                }

            }

            if(c1 === "paper"){

                if(c2 === "rock"){

                    return "paper wins";

                }else{

                    return "scissors wins";

                }

            }

            if(c1 === "scissors"){

                if(c2 === "rock"){

                    return "rock wins";

                }else{

                    return "scissors wins";

                }

            }

        }

}







Hi, im not getting any output after the user selection being displayed on the screen.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes