Hii, style='...' is for writing the CSS code directly into the HTML element. For anything you need to be reusable, what you want is to define a class within the <style>...</style> block, eg:
.my_class {
color: #B8B8B8;
background-color: #303030;
border-color: #383838;
}
And then you can set an element to use it via class="my_class". You can have multiple classes on the same element if you separate the names with spaces (class="my_class another_class").
Hii, you could try with a coin flip:
Math.random()is uniformly distributed, so there's roughly a 50% chance that the result is above0.5, and thus a 50% chance that you get an accessory.For different odds, play around with adjusting the threshold (
0.5). Make it higher to make accessories less likely, decrease it to make it more likely.EDIT: Oh, right, I forgot -- you can also calculate the threshold based on how many accessories you have. It should go something like this:
If you have five elements in accessories,
1/5gives you0.2, so the odds would be about 80% of the time you'll get an accessory. So that's another thingy to play around with.EDIT2: Just correcting my own faulty math :D