Spin the Wheel Using Mathematical Formulas

Use mathematical formulas to spin the wheel at a random number of degrees and display the prize won by the user.


Now that we’ve added the event listener and created an animation using tweens to rotate the wheel object by an angle of 1800 degrees, let's create an object to store all the prize information, and write a logic to randomly generate the number of degrees the wheel object rotates.

Create an object to store the prize details

We'll create an object that will consist of the following information related to the prizes shown in the wheel image:

  • The total number of prizes.

  • The name of each prize stored in an array.

Now let's look at the code below:

Get hands-on with 1200+ tech skills courses.