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 trialAdam Hirschovits
4,983 PointsThe var mashes - why are they pre-selected?
Hi all
Apologies if this is a stupid question (I am a 33 year old learning all this from scratch so way behind the curve) but in the var mash in the function "mash_choice", why have there been entered four types of properties? What is the aim of it in the code, given that people can type in whatever they want?
Best Adam
1 Answer
Adam Hirschovits
4,983 PointsJack AM - thank you very much indeed! As it happens, the game wasn't working at all for me. However, on going through the code, I noticed that somehow (very confident this was my c*ck-up!) the html didn't link to the JavaScript, so when I added in the link, and played the game, your answer made perfect sense - so very much appreciated for getting back to me on this one!
Best Adam
jack AM
2,618 PointsYep that'll do it haha. Glad it worked out, happy coding!
jack AM
2,618 Pointsjack AM
2,618 PointsHey Adam,
No worries, hope we can figure this out... So if you notice the very last word, as it tells your fortune, uses those strings in the variable mash. It randomly selects one of either, 'shack', 'mansion', 'house', or 'apartment', and displays it as the last word, no matter what input the user types in. For instance, if you were to run the app and without typing anything in, keep hitting the "Tell my fortune" button, you'll see the very last word in the fortune being told is changing, leaving "undefined" in place where the user's input WOULD be.