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

General Discussion

I added a new section to MASH

Joy Kesten

you asked us to share if we added anything to the MASH course, and I added a new field successfully. It took a few goes, but I added a new field to fit how I played MASH as a kid. Not entirely sure how to share it so here it goes: http://port-80-cdhz9vacfx.treehouse-app.com/

With added code in the index:

<div id="answers" class="hide">
      <p>Your home is in <span id="location"></span> married to <span id="spouse"></span> with a <span id="pet"></span> as you are a <span id="profession"></span> who owns a <span id="home"></span>.
  </div>

and below that:

<div class="choice-bucket">
        <h4 class="highlight">Who will you be married to?</h4>
          <input name="spouse[]" type="text">
          <input name="spouse[]" type="text">
          <input name="spouse[]" type="text">
          <input name="spouse[]" type="text">
      </div>
  </div>

For the script.js modifiers I simply added the extra field to each category:

function fill_in_answers(answers) {
    // Find the spans that need filled
    var home = document.querySelector('#home');  // This says make a new variable and find the HTML tag that has the ID of "home" 
    var profession = document.querySelector('#profession');
    var pet = document.querySelector('#pet');
    var location = document.querySelector('#location');
    var spouse = document.querySelector('#spouse');

 home.innerText = answers['mash']; {
    profession.innerText = answers['profession'];
    pet.innerText = answers['pet'];
    location.innerText = answers['location'];
    spouse.innerText = answers['spouse'];
    home.innerHTML = answers.mash;  // Change the content of the element in the HTML doc with the id "home" to the "mash" value in answers 
    profession.innerHTML = answers.profession;  // Change the content of the element in the HTML doc with the id "career" to the "career" value in answers 
    pet.innerHTML = answers.pet;
    location.innerHTML = answers.location;
    spouse.innerHTML = answers.spouse;
}

var answers = {
        'mash': mash_choice(),
        'profession': get_answer('profession'),
        'pet': get_answer('pet'),
        'location': get_answer('location'),
        'spouse': get_answer('spouse')
    }

And I think that's it.

The class was fun and easy. I took a "winter break" for two weeks and it was a nice way to get back into things. So...no questions here, just a fun way to add to MASH.

1 Answer

Joy Kesten
STAFF
Joy Kesten
Treehouse Guest Teacher

Heather Mathewson this is great! That was the way I played as a kid too :) I'm so glad you enjoyed the course and took it to the next level.

I can see you're cranking away on front end languages, best of luck!

ps. I hope you don't mind but I edited your post so the code would show up in blocks by using the back tick three times at the beginning and end of the code. At the beginning you can also put the language you're writing to make sure it shows up correctly.