ProdanTenev

Salary

Mar 1st, 2022
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.66 KB | None | 0 0
  1. function salaryAttention(input) {
  2.     let index = 0;
  3.     let openedTabs = input[index];
  4.     index++;
  5.     let currentSalary = input[index];
  6.     index++;
  7.    
  8.     for (let i = 0; i < openedTabs; i++){
  9.         let tabName = input[index];
  10.         index++;
  11.         switch (tabName) {
  12.             case "Facebook": currentSalary -= 150; break;
  13.             case "Instagram": currentSalary -= 100; break;
  14.             case "Reddit": currentSalary -= 50; break;
  15.         }
  16.         if (currentSalary <= 0) {
  17.             console.log("You have lost your salary.");
  18.             break;
  19.         }
  20.     }
  21.     if (currentSalary > 0) {
  22.         console.log(currentSalary);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment