diff --git a/app.js b/app.js index b80fae6..5eeb12e 100644 --- a/app.js +++ b/app.js @@ -1,50 +1,49 @@ -let Employee = [{ - employeeId: employeeId, - firstName: firstName, - lastName: lastName, - department: { - Administration: Administration, - Marketing: Marketing, - Development: Development, - Finance: Finance, - }, - - level: { - Junior: Junior, - MidSenior: MidSenior, - Senior: Senior - }, - - imageUrl: imageUrl -}] - -function Employee(employeeId, firstName, lastName, department, level, imageUrl) { - this.employeeId = employeeId; - this.firstName = firstName; - this.lastName = lastName; +function Employee(employeeID, fullName, department, level, imageURL) { + + this.employeeID = employeeID; + this.fullName = fullName; this.department = department; this.level = level; - this.imageUrl = imageUrl; - + this.imageURL = imageURL; + this.salary = function () { + let salaryRange; + switch (this.level) { + case 'Senior': + salaryRange = { min: 1500, max: 2000 }; + break; + case 'Mid-Senior': + salaryRange = { min: 1000, max: 1500 }; + break; + case 'Junior': + salaryRange = { min: 500, max: 1000 }; + break; + default: + + salaryRange = { min: 500, max: 500 }; + } + + + let randomSalary = Math.floor(Math.random() * (salaryRange.max - salaryRange.min + 1)) + salaryRange.min; + + let netSalary = randomSalary - (randomSalary * 0.075); + + return netSalary; } +console.log(this.fullName,this.salary()) +document.write(`${this.fullName} - the Salary : (${this.salary()}) ------------- `); -let e1 = new Employee(1000, Ghazi Samer, Administration, Senior) +}; -Employee.prototype.getFullName = function () { - return `${this.firstName} ${this.lastName}`; -}; +let employee1 = new Employee(1000, 'Ghazi Samer', 'Administration', 'Senior'); +let employee2 = new Employee(1001, 'Lana Ali', 'Finance', 'Senior'); +let employee3 = new Employee(1002, 'Tamara Ayoub', 'Marketing', 'Senior'); +let employee4 = new Employee(1003, 'Safi Walid', 'Administration', 'Mid-Senior'); +let employee5 = new Employee(1004, 'Omar Zaid', 'Development', 'Senior'); +let employee6 = new Employee(1005, 'Rana Saleh', 'Development', 'Junior'); +let employee7 = new Employee(1006, 'Hadi Ahmad', 'Finance', 'Mid-Senior'); -for (emp of Employee) { - let content = ` - $(em.employeeId) - - - - ` - document.getElementById("Employee").innerHTML += content -} \ No newline at end of file