I’m having syntax troubles with the following code. I think the issue is that the second if clause is not properly embedded in the first if clause.
What’s happening is a link is clicked on to display either full time or part time employees. Fulltime or parttime is passed up as an argument of function displayEmployees.
The program runs a for loop through an array of employees. If the argument of the function is “part-time”, then the code says, if the array object’s status is part-time, select its details and return them in an alert message. If the argument of the function is “full-time”, then the code says, if the array object’s status is full-time, select its details and return them in a different alert message.
So the following code returns a syntax error indicating a problem with “else” clause. Any ideas why?
[code]
function displayEmployees(time) {
var messagefulltime = ”;
var messageparttime = ”;
[B]for [/B](var i = 0 ; i < eList.length ; i++) {
[B]if[/B] (time == ‘parttime’) {
[B]if [/B](eList[i].status = ‘Part-time’) {
messageparttime += eList[i].name;
messageparttime += ‘, salary: ‘ + eList[i].salary;
messageparttime += ‘, age: ‘ + eList[i].age;
messageparttime += ‘, status: ‘ + eList[i].status;
messageparttime += ‘. n’;
}
}
alert(messageparttime);
[B]else [/B]{
messagefulltime += eList[i].name;
messagefulltime += ‘, salary: ‘ + eList[i].salary;
messagefulltime += ‘, age: ‘ + eList[i].age;
messagefulltime += ‘, status: ‘ + eList[i].status;
messagefulltime += ‘. n’;
}
alert(messagefulltime);
}
}
Thanks,
Si