I get the following error when I run the code below:
Customer is not a constructor cust1 = new Customer();
<html>
<head><title>Object object</title>
<script type="text/javascript">
var Customer = {
name : undefined,
gender : undefined,
photo : undefined,
occupation : undefined,
setName : function(name) {
this.name = name;
},
setGender : function(gender) {
this.gender = gender;
},
setPhoto : function(photo) {
this.photo = photo;
},
setOccupation : function(occupation) {
this.occupation = occupation;
},
getName : function() {
return this.name;
},
getGender : function() {
return this.gender;
},
getPhoto : function() {
return this.photo;
},
getOccupation : function() {
return this.occupation;
},
showCustomer : function() {
var table = "<table border='1'><th>Customers</th>";
table += "<tr><td>Name : </td><td> " + this.getName() + "</td></tr>";
table += "<tr><td>Gender : </td><td> " + this.getGender() + "</td></tr>";
table += "<tr><td>Photo : </td><td> " + this.getPhoto() + "</td></tr>";
table += "<tr><td>Occupation : </td><td> " + this.getOccupation() + "</td></tr>";
table += "</table>";
document.write(table);
}}
</script>
</head>
<body bgColor="#EOFFFF">
<script type="text/javascript">
cust1 = new Customer();
cust1.setName(prompt("Please enter the name here",""));
cust1.setGender(prompt("Please enter the gender here",""));
cust1.setPhoto(prompt("Please enter the photo here",""));
cust1.setOccupation(prompt("Please enter the occupation here",""));
cust1.showCustomer();
</script>
</body>
</html>
Can someone please advise what I am doing wrong?
thanks
you need to use it as is
like Customer.setName();