Salary For-Loop - Exercise 66/100 в Judge Javascript
Моля за помощ.Дава ми 66/100 , а нямам идея къде греша.
function salary(input) {
let openTabs = Number(input[0]);
let moneySalary = Number(input[1]);
for (let i = 2; i <= openTabs; i++) {
let tabs = input[i];
if (tabs === 'Facebook') {
moneySalary -= 150;
} else if (tabs === 'Instagram') {
moneySalary -= 100;
} else if (tabs === 'Reddit') {
moneySalary -= 50;
} else {
moneySalary -= 0;
}
if (moneySalary <= 0) {
break;
}
}
if (moneySalary <= 0) {
console.log('You have lost your salary.');
} else {
console.log(`${moneySalary}`);
}
}