Bummer! You have been redirected as the page you requested could not be found.

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

Need help with Math operators.

Hello, The question was "Create a variable named "maxWidth" and assign the largest value of variables a, b, and c to it using the Math.max method."

      var diameter = 5.75,
      circumference = Math.PI*diameter,
      chance = Math.round(Math.random()*20),
      maxWidth = Math.max(a,b,c),
      a = 17,
      b = 42,
      c = 1337,
      ageIfILiveToYear2100 = (new Date(2100, 0, 1)

As you can see I have it has var maxWidth = Math.max(a,b,c),

What did I do wrong?

Remove the left parenthesis on the last line before "new"

Why do you have the code with the diameter, circumference, change, and ageIfILiveToYear2100? That's from a different example. You don't need that in your case. All you need is

a = 17
b = 42
c = 1337
maxWidth = Math.max(a,b,c)

You need to assign values to a, b, and c before you can determine the maximum. Hence why the maxWidth line needs to be after the assignment to a, b, and c. You should also remove the commas from the end of your lines. You can end a line with a semicolon, but a comma is incorrect.

3 Answers

ahh I see, you must have the declarations first then the variable. Makes sense. Thank you!

var maxWidth = Math.max(c);

thanks Carlos,u code helped me in the challenge

That is not the problem here is the full bottom code, I just didn't copy it all and pasted it in.

ageIfILiveToYear2100 = (new Date(2100, 0, 1) - new Date(1995, 5, 16, 7, 20)) / (1000 * 60 * 60 * 24 * 365.242);

Here is the code I need help with, and want to know what I did wrong.

var maxWidth = Math.max(a, b, c);

Thanks!