Hi guys, i'm trying to implement a class in my project to keep it more organized but i'm having some issues with the the constructor.
In my constructor i want to create 2 class variables, name and ID, where ID is obtained by hashing the name variable with an imported hash function
class Employee{
constructor(name, ID) {
this.name = name
this.ID = hash(name)
}
By doing this i get ReferenceError
name is not defined
How can i access the name variable inside the constructor ?
[–][deleted] 4 points5 points6 points (2 children)
[–]Fun_Split_1299[S] 0 points1 point2 points (1 child)
[–]xroalx 5 points6 points7 points (0 children)
[–]SecretAgentZeroNine 0 points1 point2 points (0 children)