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 7633199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:49:01+00:00 2026-05-31T06:49:01+00:00

I am writing some JavaScript code for my webapp. I need to make a

  • 0

I am writing some JavaScript code for my webapp. I need to make a variable that has an attribute linked to it. ie: Dice1.PowerUp

So when I code I can roll a dice that is different when the powerup linked to it is at 0, 1 or 2. Do I have to code 2 different variable and set them at the same time or can I just code a linked variable that will work like an attribute to sort it.

While waiting for an answer I am coding it with 2 variables that will be set at the same time.

Code:

var consDie = new Array(3); 
//Implanté les élément de constance des dés. 
for (var i = 0; i <= 2; i++){ 
    consDie[i] = 12 - (i * 2); 
    console.log("D" + consDie[i]); 
    //Ça marché... holy macaroony! 
} 
var consNDice = 6; //Constante pour le nombre de dés 
var consAlign = {
    UnAl : consDie[2], 
    Bal : consDie[1], 
    Phys : consDie[0], 
    Ment : consDie[0]
}; 
//declaration of an object that contain the kind of dice that is rolled by powerup
  • 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-05-31T06:49:02+00:00Added an answer on May 31, 2026 at 6:49 am

    you can create a class for the dice:

    function Dice (power_up) {
        this.power_up = power_up;
    
        this.rollDice = function() {
            return Math.floor(Math.random()*6) * power_up;
        };
    }
    

    so you can create a dice object with a power up associated, and then use the rollDice function to get the value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some Javascript code that generates an XML document in the client (via
I am writing some tests for Javascript code and I need to dump some
I'm writing some MVC JavaScript code using Prototype. The problem is that when I
I need to make some UI part in javascript for android application for that
I am writing some JavaScript code that uses a string rendered with PHP. How
I'm thinking about writing some code in JavaScript which I can use in my
I am writing a javascript code to restrict the keys that can be entered
I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed
I'm writing some Javascript code and I'm trying to change the current page as
I'm writing a web page in ASP.NET. I have some JavaScript code, and I

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.