Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Create a variable named "chance" and assign a random number between 0 and 20 to it using the Math.random() method.

Create a variable named "chance" and assign a random number between 0 and 20 to it using the Math.random() method.

I have entered the following but it returning the error: "Oops! It looks like Task 1 is no longer passing."

    var diameter = 5.75,
          a = 17,
          b = 42,
          c = 1337,
          ageIfILiveToYear2100 = (new Date(2100, 0, 1) - new Date(1995, 5, 16, 7, 20)) / (1000 * 60 * 60 * 24 * 365.242);
      var circumference = diameter * Math.PI;
      var chance = Math.random()*20)+1);
    ```

6 Answers

You have some unneeded parentheses in your last statement.

var chance = Math.random()*20+1;

beauty, thanks Eirik.

Why doesn't it accept the code, var chance = Math.random(20);

Works fine in the console.

I used

var chance = Math.random()*20;

That seemed to work for me too, anything else was messing up problem #1.

var chance = Math.random()*20+1; I could not understand where the + 1 come from?

I agree with Elijah. Shouldn't it be var chance = Math.random() * 20 ; ?

this answer worked for me var chance = Math.random() * 20 ; thank you

You add the +1, because it would never go to 20, since it starts at 0.