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

Cannot read property, 'username' of undefined

I'm trying to create a program where a user will enter their usename and password and and an object will be instantiated with those two values. That part works fine. Once he hits submit he is taken to another page where he can click two buttons. One that shows his username and one that shows his password. When I click the buttons I get "dom_events.js:40 Uncaught TypeError: Cannot read property 'username' of undefined"

Could someone please take a look at my code and tell me where i went wrong? I appreciate the help

https://w.trhou.se/v8o1t1aeh6

1 Answer

You are selecting the button instead of the form. your event listener should listen for for form submission

I tried that and it still returns undefined.