I'm trying to create an array of objects for an assignment in Javascript, but the following doesn't seem to work
var employee = {
employeeId: "",
hoursWorked: 0,
overtimeWorked: 0,
wage: 15
};
var employees = [];
var p = 0;
var i = 0;
while(p != -1){
p = prompt("please enter employee id#")
employees[i] = new employee();
employees[i].employeeId = p;
i++
}
I've gone through and comment debugged my code and the problem seems to be
employees[i] = new employee();
Whether or not I do this outside the loop, or with any element in the array, I don't seem to be able to instantiate any elements of the array as the employee object.
new: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…