Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:15:35+00:00 2026-06-17T21:15:35+00:00

I am creating a basic modified Crapps game. I am using java script and

  • 0

I am creating a basic modified Crapps game. I am using java script and HTML. So It will not look great, but its purpose is to teach me Java Script.

I am still in the beginning stages and have hit a road block. What is supposed to happen is when I click a button this function happens. My function occurs yet it keep rolling 2 6’s and thus the dice show up as 6.

Everything works except that the 6 keeps reoccurring.

I went through code and could not find common mistakes- making sure the numbers it should generate is covered, that my bases are covered 6 numbers (1-5) all have a job, my names are correct, etc. I know my function is being called because the image of the dice shows up as 6 every time where I want it to go.

 function rolldice()
   {
     dice1=Math.floor(Math.random()*6+0);
        if(dice1=0)
            {
             document.getElementById("dice1").innerHTML="<img src='1.jpg' width='100' height='100' />";
            }
        if(dice1=1)
            {
              document.getElementById("dice1").innerHTML="<img src='2.jpg' width='100' height='100' />";

            }
        if(dice1=2)
            {
              document.getElementById("dice1").innerHTML="<img src='3.jpg' width='100' height='100' />";

            }
        if(dice1=3)
            {
              document.getElementById("dice1").innerHTML="<img src='4.jpg' width='100' height='100' />";

            }
        if(dice1=4)
            {
              document.getElementById("dice1").innerHTML="<img src='5.jpg' width='100' height='100' />";

            }
        if(dice1=5)
            {
             document.getElementById("dice1").innerHTML="<img src='6.jpg' width='100' height='100' />";

            }
dice2=Math.floor(Math.random()*6+0);
    if(dice2=0)
            {
             document.getElementById("dice2").innerHTML="<img src='1.jpg' width='100' height='100' />";
            }
        if(dice2=1)
            {
              document.getElementById("dice2").innerHTML="<img src='2.jpg' width='100' height='100' />";

            }
        if(dice2=2)
            {
              document.getElementById("dice2").innerHTML="<img src='3.jpg' width='100' height='100' />";

            }
        if(dice2=3)
            {
              document.getElementById("dice2").innerHTML="<img src='4.jpg' width='100' height='100' />";

            }
        if(dice2=4)
            {
              document.getElementById("dice2").innerHTML="<img src='5.jpg' width='100' height='100' />";

            }
        if(dice2=5)
            {
             document.getElementById("dice2").innerHTML="<img src='6.jpg' width='100' height='100' />";

            }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:15:36+00:00Added an answer on June 17, 2026 at 9:15 pm

    You are using = instead of ==. That means that it will run each of the statements from 1-5.

    if (dice1 = 5){
    

    is the same as

    dice1 = 5;
    if (dice1){
    

    Which will always be true.

    You should also have var before each of your variables when you are assigning the random value, FYI.

    I would consider shortening all of this code to something like this:

    function rolldice(){
      for (var i = 0; i < 2; i++){
        var roll = Math.floor(Math.random() * 6);
        document.getElementById('dice' + (i + 1)).innerHTML = 
          "<img src='" + (roll + 1) + ".jpg' width='100' height='100' />"
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery I'm creating a basic 'tooltip' animation so that the tooltip will appear
My current class is planning on creating a basic networked game, but we have
I'm working on creating a basic web based game using the HTML5 canvas and
I am using web.py and creating a basic webpage, I had a basic html
I'm creating some basic OO scripts using MySQLi and getting an Undefined Method error
I'm creating a basic form with ajax submit using jquery framework. This is my
I am using the Grails ajaxflow plugin for creating a basic wizard. One issue
I am creating a multiplayer chess game in Visual Basic.Net and I need to
I am creating a basic Php Ajax chat application. when i am using this
I'm creating a basic shopping cart script , located at php/cart.php, with a GET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.