Advertisement
Guest User

Untitled

a guest
Jun 29th, 2019
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function salary(input) {
  2.  
  3.     let nOpenTabs = Number(input[0]) ;
  4.     let salary = Number(input[1]) ;
  5.  
  6.  
  7.  
  8.     for (let i = 2; i <= nOpenTabs; i++ ) {
  9.  
  10.        let tab = String(input[i]);
  11.  
  12.         if ( tab == `Facebook` ) {
  13.  
  14.             salary -= 150
  15.            
  16.  
  17.         }
  18.         if ( tab == `Instagram` ) {
  19.  
  20.             salary -= 100
  21.  
  22.         }
  23.         if ( tab == `Reddit` ) {
  24.  
  25.             salary -= 50
  26.  
  27.         }
  28.  
  29.         if ( salary <= 0 ) {
  30.  
  31.             console.log(`You have lost your salary.`)
  32.             break;
  33.    
  34.           }
  35.  
  36.        
  37.        } // end of for
  38.  
  39.       if (salary != 0 ) {
  40.         console.log(salary)
  41.       }
  42.  
  43.  
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement