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 Treehouse Club - MASH MASH - JavaScript Stuff You Can Change

Carlo Sabogal
Carlo Sabogal
7,468 Points

Changing js futuristic mash

Hi, I am playing with the js file, and I would like to know why if I change the num variable and random number function like this I don't get the same results, but undefined answers.

function random_number(num) {
    var num = 4 ;
    return Math.floor(Math.random() * num)+1; 
}

I am assigning the number 4 (removed "or" statement) and added +1 at the end of the function so it is always between 1 and 4 instead of 1 and 3. Why was the "or" statement necessary and why the change on the math random function is not giving the same results?

thanks

Carlo