SHARE
TWEET

Salary

a guest Feb 17th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function demo(input) {
  2.     let openTabs = input.shift()
  3.     let salary = input.shift();
  4.  
  5.  
  6.     for (let i = 0; i < openTabs; i++) {
  7.         let site = input[i];
  8.         switch (site) {
  9.             case 'Facebook':
  10.                 salary -= 150;
  11.                 break;
  12.             case 'Instagram':
  13.                 salary -= 100;
  14.                 break;
  15.             case 'Reddit':
  16.                 salary -= 50;
  17.                 break;
  18.  
  19.         }
  20.       if (salary <= 0) {
  21.         console.log('You have lost your salary.');
  22.         break;
  23.         }
  24.  
  25.     }
  26.    
  27.  
  28.     if (salary > 0) {
  29.         console.log(salary);
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top