Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function salaryAttention(input) {
- let index = 0;
- let openedTabs = input[index];
- index++;
- let currentSalary = input[index];
- index++;
- for (let i = 0; i < openedTabs; i++){
- let tabName = input[index];
- index++;
- switch (tabName) {
- case "Facebook": currentSalary -= 150; break;
- case "Instagram": currentSalary -= 100; break;
- case "Reddit": currentSalary -= 50; break;
- }
- if (currentSalary <= 0) {
- console.log("You have lost your salary.");
- break;
- }
- }
- if (currentSalary > 0) {
- console.log(currentSalary);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment