JavaScript Treehouse Club - MASH MASH - JavaScript Stuff You Can Change

Marla Morris
Marla Morris
1,448 Points

The 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!