Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

JavaScript Create a function called playGame(). Create a function-scoped variable that gets a random number between (and including) 1 and 100. Make sure your result does not include 0 (zero). Create a...

1 answer below »

JavaScript

  • Create a function called playGame().
  • Create a function-scoped variable that gets a random number between (and including) 1 and 100. Make sure your result does not include 0 (zero).
  • Create a variable called min and set it to 50.
  • Create a variable called max and set it to 75.
  • Then write an if/else statement that follows the following logic:
    • If the random number is greater than the minimum variable and less than the maximum variable, then send a message to HTML that saysYour Number: #, You Won!(the # should be replaced with the randomly generated number. If it doesn't fall within those parameters, then the message in HTML should sayYour Number: #, Keep Trying!

Your final output should look like this...


Answered 1 days After Jun 30, 2021

Solution

Kshitij answered on Jul 02 2021
135 Votes
RandomWin/index.html


RANDOM NUMBER
RandomWin/script.js
var min = 50;
var max = 75;
function playGame() {
var val = Math.floor(Math.random() * 100) + 1;
var result = "";
if (val > 50 && val < 70) {
result = "Your number is " + val + " You won!!! ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here