
italiandadx2
1,922 PointsProblem with the value parameter
Wouldn't the value past into the function be the same for each rgb number...? Meaning when you call the function and pass it a value of say 10... wouldn't the color returned be rgb(10, 10, 10)...? I guess you still get a random color for each circle but each color would have the same value for for r, g and b... rgb(10, 10, 10), rgb(127, 127, 127), etc...
1 Answer

Peter Vann
Treehouse Moderator 31,374 PointsHi!
If you pay close attention to the video right around 5:00, you will notice that the value is actually the randomValue function being passed in.
The give-away being this line of code:
const color = `rgb( ${value()}, ${value()}, ${value()} )`;
Which tells you that value() has to be an executable function (randomValue, specifically, which will randomly generate a fresh, distinct number each time it is called - in this case, three times right in a row).
Does that make sense?
I hope that helps.
Stay safe and happy coding!
italiandadx2
1,922 Pointsitaliandadx2
1,922 PointsThank you! Took me a minute to get what you were saying... I didn't realize that when you pass a function as an argument that the function would be called independently each time it's referenced... Thank you again!!!