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 trialKristine Johnson
5,232 PointsThis is my solution:
let html = '';
const randomValue = () => Math.floor(Math.random() * 256);
const randomRGB = () => `rgb( ${randomValue()}, ${randomValue()}, ${randomValue()}`;
for ( let i = 1; i <= 10; i++){
html += `<div style="background-color: ${randomRGB()}">${i}</div>`;
}
1 Answer
Steven Parker
231,269 PointsYou forgot to indicate what course and lesson you are referring to. But this seems like mostly functional code () only missing something to put the html on the page (such as a document.write
call), and you might have a bit of CSS to go with it — if it is intended to display something other than stripes.
You might want to take a look at this video about Posting a Question, which will cover how to link a question to a lesson video. And for when your question refers to something you are doing in a workspace, you may also want to view this one about sharing a snapshot of your workspace to allow folks to replicate your entire environment (including HTML and CSS with the JavaScript).