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 trialja5on
10,338 Pointshow to call a parameter / or get a result from it?
I know the code isn't working, stuck on how to return a value from parameters.
2 Answers
beverlygrant
Full Stack JavaScript Techdegree Student 5,674 PointsYou are using
console.log(lower);
Here lower is a variable of function getMyRand. Which is limiting its scope and you can't directly use that value from outside the function.
An Example of Function which Arguments and Parameter.
function iAmAfunction(parameter){
return parameter * parameter; //returning a value
}
let squareofNum = iAmAfunction(5); //5 is an argument
console.log(squareofNum);
I would highly recommend you to start the function lectures again to understand the basic terminology.
Kylie Soderblom
3,890 PointsMath.floor(Math.random() * (max - min) ) + min; Start with this. (max = upper, min = lower).
ja5on
10,338 Pointsja5on
10,338 PointsYes i will do (i have some holes in my knowledge) thanks for your response
Diego Alvarez
6,680 PointsDiego Alvarez
6,680 PointsBut that doesn't answer his question, because he's trying to log to the console the value of the parameters, dynamically.
For example:
document.querySelector('main').innerHTML = `The random number between ${lower} and ${upper} is ${randomNumber(1,100)}`;
I'm trying to figure it out as well, but I believe it's possible only with callbacks, or I'm too asleep at the moment haha.
This is what I'm trying according to your answer.
Obviously it throws an error, which says > Uncaught RangeError: Maximum call stack size exceeded