AhmetUstun

06. Company

Jul 1st, 2021
495
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Company {
  2.  
  3.     constructor() {
  4.         this.departments = {};
  5.         this.aveSalaries = {};
  6.     }
  7.  
  8.     addEmployee(username, salary, position, department) {
  9.  
  10.         if ([...arguments].some(a => a === null || a === undefined || a === '') || salary < 0) {
  11.             throw new Error('Invalid input!');
  12.         }
  13.  
  14.         let user = {
  15.             username: username,
  16.             salary: salary,
  17.             position: position
  18.         };
  19.  
  20.         if (!this.departments.hasOwnProperty(department)) {
  21.  
  22.             this.departments[department] = [];
  23.  
  24.             this.aveSalaries[department] = {
  25.                 totalEmployees: 0,
  26.                 totalSalaries: 0,
  27.                 averageSalary: 0
  28.             };
  29.         }
  30.  
  31.         this.departments[department].push(user);
  32.         this.aveSalaries[department].totalEmployees += 1;
  33.         this.aveSalaries[department].totalSalaries += salary;
  34.        
  35.         this.aveSalaries[department].averageSalary =
  36.             this.aveSalaries[department].totalSalaries /
  37.             this.aveSalaries[department].totalEmployees;
  38.        
  39.         return `New employee is hired. Name: ${username}. Position: ${position}`;
  40.     }
  41.  
  42.     bestDepartment() {
  43.  
  44.         let bestDepartment = Object
  45.             .entries(this.aveSalaries)
  46.             .sort((a, b) => b[1].averageSalary - a[1].averageSalary)
  47.             .shift();
  48.  
  49.         console.log(`Best Department is: ${bestDepartment[0]}`);
  50.         console.log(`Average salary: ${bestDepartment[1].averageSalary.toFixed(2)}`);
  51.  
  52.         this.departments[bestDepartment[0]]
  53.             .sort((a, b) => b.salary - a.salary || a.username.localeCompare(b.username));
  54.  
  55.         this.departments[bestDepartment[0]].forEach(user => {
  56.             console.log(`${user.username} ${user.salary} ${user.position}`);
  57.         });
  58.     }
  59. }
Advertisement
Comments
  • User was banned
  • User was banned
  • Sinmaonoz
    72 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • User was banned
Add Comment
Please, Sign In to add comment