I am in college right now and I am learning Javascript. I have a lab that requires I display three coloured buttons on the screen that are completely random in order. Now when these buttons are all green, all red, or all blue, you get a bonus to how many points you get. The code below is what I have so far, but right now I want to explain my thinking process and maybe get some help from you guys to help me better my thinking process.
So basically below I start with 3 button variables. These turn out to be completely useless for me I found out. I thought I could do more complicated if statements with them, but couldn't quite figure it out. So I make a function called randomButton. Then I use a variable called randomNumberOne and set it equal to the Math.ceil and make it so the numbers go from 1 -3. Then I write an if statement saying if the number in that variable gets set as 1, display the red button, if 2 green, if 3 blue. Then I call the function 3 times because I want it to be displayed 3 times. Now what I want to do is make it so if there are 3 blues, reds, or greens in a row it will display something like "You get x10 points" or something like that. I just do not know how to go about doing that. Sorry if what I am typing doesn't make sense, I am still learning and I am eager to learn. Thanks for your time.
<!doctype html>
<html>
<head>
<script>
var button1 = "<img src=red.jpg>"
var button2 = "<img src=green.jpg>"
var button3 = "<img src=blue.jpg>"
function randomButton() {
var randomNumberOne = Math.ceil(Math.random() * 3);
if (randomNumberOne === 1) {
document.write("<img src= red.jpg>");
} else if (randomNumberOne === 2) {
document.write("<img src= green.jpg>");
} else if (randomNumberOne === 3) {
document.write("<img src= blue.jpg>");
}
}
</script>
</head>
<body>
</body>
<script>
randomButton()
randomButton()
randomButton()
</script>
</html>