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 Treehouse Club - MASH MASH - JavaScript Changing Stuff in JavaScript

Zane Mattingly
Zane Mattingly
8,428 Points

"Ultra MASH", a reworked OO version of the Treehouse Club - MASH code

Put together a re-worked version of Joy Kesten's (@joykesten2) MASH code using the concepts presented in the previous JavaScript courses I've taken.

The code has been reorganized into functions/attributes of a 'game' object that switches "views" between the form and the answer box.

After the user has submitted the form, the submit button becomes a reset button which they can use to reset and repopulate the form.

The form is pre-filled with randomized answers from an object passed into the game constructor. Each category within the object can be arbitrarily long, as long as there are enough to fill the corresponding text inputs.

Each text input includes a 'clear' button is presented in the input area if a value is present. If the user removes the value from the text input, the clear button is hidden but reappears if text is added.

There's some very basic error handling if the user clears all of the inputs for a category. Rather than presenting 'undefined' in the answers box, instead an error message is presented.

Not perfect by a long shot, but it was a fun exercise and I learned quite a bit about eventHandlers. Thought I'd throw it up for comments or questions.

It's available at https://github.com/zmattingly/UltraMASH if you'd like to check it out.

Thanks. :)

1 Answer

Joy Kesten
STAFF
Joy Kesten
Treehouse Guest Teacher

Zane Mattingly Nice work!! I downloaded the zip file and checked it out. I like that you can deselect things. Very funny inputs too : )

Really nice additions, keep up the good work!

Also, tag me next time so it doesn't take me so long to check out your work!