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