Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function salary(input) {
- let nOpenTabs = Number(input[0]) ;
- let salary = Number(input[1]) ;
- for (let i = 2; i <= nOpenTabs; i++ ) {
- let tab = String(input[i]);
- if ( tab == `Facebook` ) {
- salary -= 150
- }
- if ( tab == `Instagram` ) {
- salary -= 100
- }
- if ( tab == `Reddit` ) {
- salary -= 50
- }
- if ( salary <= 0 ) {
- console.log(`You have lost your salary.`)
- break;
- }
- } // end of for
- if (salary != 0 ) {
- console.log(salary)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement