Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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