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 JavaScript Loops Working with 'for' Loops The Refactor Challenge – Duplicate Code

Jessaly Sinchico
Jessaly Sinchico
1,485 Points

I checked my work, but I'm still not able to see the random colors. I see the numbers but the color is the problem.

let html = '';

const randomValue = () => Math.floor(Math.random() * 256);

function randomRGB(value) {

const color = rgb( ${value()}, ${value()}; ${value()} );

return color;

}

for ( let i = 1; i <= 10; i++ ) {

html += <div style="background-color: ${randomRGB(randomValue)}">${i}</div>;

}

document.querySelector('main').innerHTML = html;

2 Answers

Try changing const color = rgb( ${value()}, ${value()}; ${value()} ); to const color = rgb( ${value()}, ${value()}, ${value()} ); with a , to separate the second and third values instead of ;

Jessaly Sinchico
Jessaly Sinchico
1,485 Points

Thank you so much! I was able to fix the error and it worked!