1. Company JS Advanced 50/100
Здравейте ако някой може li да каже защо дава 50/100??
Условие:
1.Company
class Company {
// TODO: implement this class...
}
Your Task
Write a Company Class, Which Supports the Described Functionality Below.
Functionality
Constructor()
Should have these 1 property:
- departments - empty array
AddEmployee({username}, {Salary}, {Position}, {Department})
This function should add a new employee to the department with the given name.
- If one of the passed parameters is empty string (""), undefined or null, this function should throw an error with the following message:
"Invalid input!"
- If salary is less than 0, this function should throw an error with the following message:
" Invalid input!"
- If the new employee is hired successfully, you should add him into the departments array and return the following message:
- New employee is hired. Name: {name}. Position: {position}"
bestDepartment()
This function should print the department with the highest average salary and its employees sorted by their salary by descending and by name in the following format:
"Best department is: {best department's name}
Average salary: {best department's average salary}
{employee1} {salary} {position}
{employee2} {salary} {position}
{employee3} {salary} {position}
. . ."
Submission
Submit only your Company class.
Examples
This is an example how the code is intended to be used:
Sample code usage |
let c = new Company(); c.addEmployee("Stanimir", 2000, "engineer", "Construction"); c.addEmployee("Pesho", 1500, "electrical engineer", "Construction"); c.addEmployee("Slavi", 500, "dyer", "Construction"); c.addEmployee("Stan", 2000, "architect", "Construction"); c.addEmployee("Stanimir", 1200, "digital marketing manager", "Marketing"); c.addEmployee("Pesho", 1000, "graphical designer", "Marketing"); c.addEmployee("Gosho", 1350, "HR", "Human resources"); console.log(c.bestDepartment()); |
Corresponding output |
Best Department is: Construction Average salary: 1500.00 Stan 2000 architect Stanimir 2000 engineer Pesho 1500 electrical engineer Slavi 500 dyer |
решение: https://pastebin.com/MPr8LdNN
Да благодаря ти това беше + това че на salary иска да е <= за да даде 100/100.
Здравейте, някой би ли ми помогнал и да ми каже защо ми гърми един тест. Тествах го с различни резултати и изглежда работи нормално.
https://pastebin.com/cWY4QT0B