til2to / porfolio_projects

0 stars 0 forks source link

Fixing Bug #18

Open Baayeh opened 1 year ago

Baayeh commented 1 year ago

Bug: TypeError

Cannot read properties of undefined (reading 'toLowerCase')

The bug is consoled on line 152 in the index.js file. Created a breakpoint on line 151 to get the value of the email field on form submission. The value returned is undefined. Since the value is undefined, the next line will break because you cannot do a comparison with an undefined value.

Baayeh commented 1 year ago

Possible Solution

On line 151, the form selector to get the value of the email field is missing the value of the name attribute associated with the field. Replace const email = contactForm.elements.value; with const email = contactForm.elements.email.value; to be able to grab the value of the email field and assign it to the email variable. The value grabbed can now be used in the if statement on the next line and the form can be submitted with the correct feedback.