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 trialDavid Mendiola
Full Stack JavaScript Techdegree Student 16,579 PointsIs this a passable solution?
var numCircles = 10;
function buildRGB(){
return Math.floor(Math.random() * 256);
}
function getRGB() {
return "rgb(" + buildRGB() + "," + buildRGB() + "," + buildRGB() + ");";
}
for (var x = 0; x < numCircles; x++){
var html = "<div style='background-color:" + getRGB() + "'></div>";
document.write(html);
}
Would this be a viable solution?
Alice Tribuleva
3,247 Pointsha, that's awesome!
2 Answers
Alexander Davison
65,469 PointsDid you try it? Did it return the same output as Dave's did?
If the output is the same as Dave's output, you should be good to go :)
Good luck! ~alex
Anas AlHariri
8,776 PointsI think that he may be using an external code editor, and he could have a problem with the styling sheet. He shouldn't get the expected result unless he has the same styling effect of the project.
Good Luck
Alexander Davison
65,469 PointsI meant by the same functionality. :)
~alex
Alice Tribuleva
3,247 PointsMine was very close, but I got a chance to make a few improvements. Thank you, David!
var html = '';
function tom() {
return Math.floor(Math.random() * 256 );
// var mot = Math.floor(Math.random() * 256 );
// return mot;
}
function getColor() {
return `rgb( ${tom()}, ${tom()}, ${tom()})`;
}
for (var i = 0; i < 3; i++ ) {
html += `<div style="background-color: ${ getColor() } "></div>`;
}
document.write(html);
David Bath
25,940 PointsDavid Bath
25,940 PointsI don't see why not! Looks good!