[Java Script]
Please help to achieve the result that the question requires below. (My current code is as attached.)
I would like to know how I could tell "If the randomly generated number does not exist in the array, add the number."
Q: The CA SuperLotto Plus lottery game consists of a draw of 6
numbers total.
The first 5 numbers are selected randomly from the same set of
numbers
between 1 and 47. This means that you cannot have repeating numbers
in this
set of 5.
The Mega number is a single number drawn randomly from the
number set
between 1 and 27. This number set is NOT related in any way to the
first set.
![function draw() { var array1 = []; var i = 0; var x1 = 0; while(i <= 5) { var x1 = Math.floor(Math.random() * 47) + 1; if x1](http://img.homeworklib.com/questions/0b0116d0-c948-11eb-a787-031049f89e4a.png?x-oss-process=image/resize,w_560)
Here I am providing the funciton draw():
Code:
<script>
function draw()
{
var array1 = [];
var i=0;
var x1=0,glag =0;
while(i<5)
{
flag=0;
var x1=Math.floor(Math.random()*47)+1;
for(var k=0;k<i;k++)
if (array1[k]==x1)
flag=1; //settting flag=1 when x1 already present in
array1
if(flag==0) //if still flag==0 (means x1 not in array1)
{
array1[i]=x1; //then we are inserting the x1 into
array1.
i++;
}
}
document.write("Printing the numbers in the
array:<br>");
for(var j=0;j<i;j++)
{
document.write(array1[j]+"<br>");
}
var x2=Math.floor(Math.random()*27)+1;
document.write("\nMeganumber:",x2);
}
draw();
</script>
Screenshot:
![<script> function draw() { var array1 = []; var i=0; var x1=0,glag =0; while(i<5) flag=0; var x1=Math.floor(Math.random()*47)](http://img.homeworklib.com/questions/0b9f8860-c948-11eb-8845-1f58a09d695d.png?x-oss-process=image/resize,w_560)
Output:

Hoping that the above answer will help you...Thank you...
[Java Script] Please help to achieve the result that the question requires below. (My current code...
This question relates to JavaScript. Could you please show me how to get my code below working. Please keep it simple. The code has a green square image. When it is clicked the function generates a random number from 1-3. If the number generated is '1' then the green square is replaced by a picture of a tree. Please keep it as simple as possible because I am new to coding. Thanks. <html> <head> <title></title> <script>...
NEED HELP with HTML with Javascript embedding
for form validation project below. I have my code
below but I'm stuck with validation. If anyone can fix it, I'd
really appreciate.
******************************************************************************
CODE:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project
Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Nice</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<script>
var textFromTextArea;
function getWords(){
var text =...
I have the code buts its not working as this below instruction can anyone help Use the requirements from the pizza part of Assignment 6 and do the following using CSS and an internal style sheet: 1. Your Javascript function should be in an external file (don’t forget to move it up to studentweb too) 2. Put a red border of 300px in width around the form 3. There should be three Div sections: header, main_body, and footer. 4. Center the name of your...
Java Project Name: IC19_WinningTheLottery n this assignment, we're going to attempt to win the lottery! (**If you do actually win the lottery, please be sure to give back to your alma mater, Orange Coast College. We will be happy to put your name on the building!**) Ok, time to get real. The Fantasy 5 (TM) lottery is a game in which 5 numbers from 1 to 36 are randomly drawn by the State of California. If you correctly guess all...
This is an assignment for my algorithm class which I have written the code partially and only need to complete it by adding a time function that calculates the average running time. We could use any programming language we want so I am using C++. I am including the instruction and my partial code below. Thank you! Implement linearSearch(a,key) and binarySearch( a,key)functions. Part A.In this part we will calculate theaverage-case running time of each function.1.Request the user to enter a...
please help with all of these questions, thanks.
Suppose that diseased trees are distributed randomly and uniformly throughout a large forest with an average of λ per acre. Let X denote the number of diseased trees in a randomly chosen one-acre plot with range, 0, 1,2,...^ (a) What distribution can we use to model X? Write down its probability mass function (p.m.f (b) Suppose that we observe the number of diseased trees on n randomly chosen one-acre parcels, Xi, X2,...
JAVA TIC TAC TOE - please help me correct my code Write a program that will allow two players to play a game of TIC TAC TOE. When the program starts, it will display a tic tac toe board as below | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 The program will assign X to Player 1, and O to Player The program will ask Player 1, to...
Hallo! I have a problem in my code, I need help please in java code. My task is : Write a program that can read a text from a file and do frequency analysis on the letters that occur . To store information (frequency) you must use an array. Tip! The place where you collect the frequency of eg the letter A is the equivalent of the ASCII code of "A" ie 65. The array should be 127 elements. For...
please
Question 1 Convert the constraints into linear equations by using slack variables. Maximize z = 2X1 +8X2 Subject to:X1 + 6x2 s 15 2x1 + 9x2 s 25 X120,X220 X1 + 6x2 +51 s 15 2X1 + 9x2525 25 x1 +6X2+S1 = 15 2X1 +9x2 +52 = 25 O X1 +6X2 + 512 15 2X1 + 9x2 +522 25 X1 +6x2 = S1 +15 2x1 + 9x2 = S2 + 25 Question 2 Introduce slack variables as necessary and...
[JS] [HTML] wanting to add this logic to existing code(see below) of a blackjack game, where it will show the Suit emblem instead of spelled out suit name. example: display 7 ♣ instead of 7 clubs. //this is the logic, main obj is to display suits emblems to existing code if (card.Suit == 'Hearts') icon='♥'; else if (card.Suit == 'Spades') icon = '♠'; else if (card.Suit == 'Diamonds') icon = '♦'; else icon = '♣'; //existing code blackjack.js //variables for...