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

Updated Random Quote Machine

Hi,

I just finished updating my old Random Quote Machine and thinking if there is something that should be changed or if it's all good?

I'm aware that some of the quotes > 140 characters which is what I'm trying to fix at the moment.

http://codepen.io/regnis/full/dpyvXB/

1 Answer

Steven Parker
Steven Parker
243,644 Points

:point_right: You can make the code a bit more compact if you want.

You could replace the entire long switch statement in randomColorThemes with this single line:

    changeColorTheme(colorThemes[randomColor - 1]);

And you could simplify it a bit further by removing the "+ 1" from the computation of randomColor, and then remove the "- 1" from this line.

I had no idea I could do it like that but it's working perfect, thank you very much Steven Parker :-D