I have the following code in a js file:
var english = {
firstname: 'Tony ',
lastname:'Smith',
address: {
street: "777 guid str",
city: "New York",
state: "NY"
}
};
var spanish = {
firstname: 'Roberto ',
lastname:'Tzuark',
address: {
street: "227 guid str",
city: "New York",
state: "NY"
}
};
function greet(person) {
console.log('hi ' + person.firstname + person.lastname);
}
and the following code in html:
<form id="myForm" method="get">
<button type="button" name="english" onClick="greet(english)">english</button>
<button type="button" name="spanish" onClick="greet(spanish)">spanish</button>
</form>
When the button is clicked I get an "undefined" error in the console. However, if I change the variable names 'english' and 'spanish' to ANYTHING else, it works fine. These are not listed in the javascript reserved words (http://www.w3schools.com/js/js_reserved.asp)
Why doesn't it work?