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
Nathan Marshall
6,031 Pointsonclick function will not recognise my value?
Hi Guys, I am currently building an app which allows me to change a background color on click. I have made another function which creates a random color value for me each time. When I pass this through myFunction which gets activated onclick, nothing appears to happen. I have tried to pass my value through as a string and this still doesn't help.
Can someone please explain why this is?
Here is my codepen: https://codepen.io/Nathan-Callum-Marshall/pen/wXybZE?editors=1010
Thanks
Nathan
1 Answer
Steven Parker
243,656 PointsThe "randomColor()" function passes back the string directly, it does not have a "value" property.
Also, the color name string should not have a semicolon at the end.
Nathan Marshall
6,031 PointsNathan Marshall
6,031 PointsThank you, Steve. I had the .value on there to see if it made a difference at the time. Silly mistake by me. I should have known about the semicolon :D
Thanks once again