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