This code:
1 formResults = { ... };
2 console.log("first name: " + formResults.firstName);
3 console.log("last name: " + formResults.lastName);
4 console.log("email: " + formResults);
has the following output:
first name: John
last name: Doe
email: [object Object]
The last line of output is incorrect. It is caused by line 4, where we're trying to print the entire formResults
object, but we actually just want to print the email.
Line 4 was probably meant to be:
4 console.log("email: " + formResults.email);
But when we fix it, we still get the same output:
first name: John
last name: Doe
email: [object Object]
huh???
Turns out, someone is trolling by filling out the form with [object Object]
as their email address.
formResults = { firstName: "John", lastName: "Doe", email: "[object Object]" };
console.log("first name: " + formResults.firstName);
console.log("last name: " + formResults.lastName);
console.log("email: " + formResults.email);