I\'ve been trying to do javascript for sometime now, but i want it to be \"object-orientated\" so I\'m trying to create different javascript classes in different files and try t
I see three issues with the code.
The page does not import the proper external Javascript files
javascript test
Male needs to be a String literal
When the interpreter encounters male
within the Person
constructor it looks for a variable, which it cannot find.
function main()
{
var employee = new Person("Richard", 23, "male");
document.getElementById("mainBody").innerHTML = employee.getName();
}
The code should call the main function.
Without a call to the main function the code is never kicked off.
function main()
{
var employee = new Person("Richard", 23, "male");
document.getElementById("mainBody").innerHTML = employee.getName();
}
main();
Working Example: http://jsfiddle.net/R7Ybn/