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 Object-Oriented JavaScript (2015) Practice Project User Interface Code

Assigning a value to guess.

I saw this question come up within a different question. Since this was a followup there, I am making it it's own question.

I am just trying to see if I understand how a value is assigned to the guess variable, which is passed to the guessHandler. So I think this is how it is explained. Please correct me if this is not correct:

When the choice "George Washington" is what is displayed in #choice0, it is actually populated with the value "George Washington", since that is the innerHTML? So this becomes the value of the guess that is passed into the guessHandler? Please clarify if that is what is happening.

Thank you so much!

Charles Wanjohi
Charles Wanjohi
9,235 Points

Yeah you are right ....and since its a text, it would be preferable to use textContent for innerHTML i.e.

let myAnswer =document.getElementById('choice0').textContent;
guessHandler(answer);

hope this answers your question

1 Answer

Thanks so much!