Day 5 — Back to Hott Lotto

I worked on creating the piece of JavaScript code for my Hott Lotto game. Look below:

1st step: I need to create a mechanism for giving each person a randomized number.

Math.floor((Math.random())

However, I want an actual number to show up. If I keep it like this no number will show.

2nd Step: I want to give each person an actual random number but provide a range.

Math.floor((Math.random() * 1000) + 1)

Each person will receive a random number between 1–1000.

3rd Step: How do I incorporate telling them what prize they won?

I came up with this:

`var n = Math.floor((Math.random() * 1000) + 1);    if (n) {      var output = "";      if (n % 3 == 0)        output += "Rock";      if (n % 5 == 0)        output += "star";      console.log(output || n);    }`

When I ran the code in my Chrome Browser, it just returned “Rockstar,” meaning the number was divisible by both 3 and 5. However, I want to show people their actual number to provide some kind of transparency. Well, I’ll work on that part tomorrow. I’m too tired.

Also, click the ❤ below to help me inspire more people in break into tech.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.