Skip to content
Advertisement

Question on how to work with class instances inside an array

So i am learning how to work with classes and class instances and have created a scenario where i have a class Employee that is extended by three other classes that represent employees from different departments. I already managed to create a function that allows me to create a new instance of any class and push it into an array containing all existing employees.

So now i am trying to play around and iterate over the array and create new functions that allow me to access a specific value of any instance.

for example the first one i am trying to do is a function that return true or false if an employee is working remotely:

JavaScript

I have no idea and couldn’t find any answers online on how to do it, hoping you could shed a light on me. Cheers

Advertisement

Answer

Without seeing your class code for the employee it should be something like this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement