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 trialMarla Morris
1,448 PointsThe MASH answer does not show when I hit "submit" in the browser. Instead the page reloads. How did I break the code?
I only made basic changes as directed by the video instruction for the MASH Javascript course.
```changes to the text of the answer in the html doc, e.g.: <p>You live in the kingdom of <span id="location"></span> inside a <span id="home"></span> with a <span id="pet"></span> and you have the power to <span id="profession"></span>. </div>
I also changed the javascript MASH array of choices, e.g: function mash_choice() { // New function called mash_choice that doesn't take any parameters // Since MASH is a special case, give it its own list var mash = ['icecastle', 'treehouse', 'burrow', 'cozycottage']; // The array of choices to pick from var randomNum = random_number(4); // Use the above function to get a number between 0 and 4 return mash[randomNum]; // Return the list item the random number function just picked and exit the function
The only other change I made was answers_object, per video instruction, to javascript:
function handle_submission(evt) { evt.preventDefault(); // Stop the form from reloading the page evt.stopPropagation(); // Stop the form from reloading the page
// Build up our answers object
var answers_object = {
'mash': mash_choice(),
'profession': get_answer('profession'),
'pet': get_answer('pet'),
'location': get_answer('location')
}
// Fill in the answers
fill_in_answers(answers_object);
var answer_div = document.querySelector('#answers');
answer_div.classList.add('show');
}
Thanks!