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 trialTimothy Harrington
10,770 PointsChanging the argument to a function??? Please help..
Hi guys and gals, need your help to teach me why Guil did this:
Why does Guil use () when passing the argument in const color? Shouldn't it just be passed ${value} ?
let html = '';
const main = document.querySelector('main');
const randomValue = () => Math.floor(Math.random() * 256);
function randomRGB(value) {
const color = `rgb( ${value()}, ${value()}, ${value()} )`;
return color;
}
for (let i = 0; i <= 10; i++) {
html += `<div style="background-color: ${randomRGB(randomValue)}">${i}</div>`;
}
main.innerHTML = html;
doesn't it mean that he's making the argument turn into a function? I'm confused.
thank you!