Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let specialized = ['Programming', 'Hardware maintenance', 'Cooking', 'Translating', 'Designing'];
- let average = ['Driving', 'Managing', 'Fishing', 'Gardening'];
- let clumsy = ['Singing', 'Accounting', 'Teaching', 'Exam-Making', 'Acting', 'Writing', 'Lecturing', 'Modeling', 'Nursing'];
- let specializedCounter = 1;
- let clumsyCounter = 1;
- let sum = 0;
- for (const line of input) {
- let [proffesion, gold] = line.split(' : ').filter(t => t !== '');
- proffesion = proffesion.trim();
- if(specialized.includes(proffesion) && gold < 200){
- continue;
- }
- if (specialized.includes(proffesion)) {
- sum += +gold * 0.8;
- if (specializedCounter % 2 === 0) {
- sum += 200;
- }
- specializedCounter++;
- }
- if(average.includes(proffesion)) {
- sum += +gold;
- }
- if(clumsy.includes(proffesion)) {
- if(clumsyCounter % 2 === 0){
- gold = +gold * 0.95;
- } else if (clumsyCounter % 3 === 0) {
- gold = +gold * 0.9;
- }
- sum += +gold;
- clumsyCounter++;
- }
- }
- let result = [];
- result.push(`Final sum: ${sum.toFixed(2)}`);
- if(sum < 1000) {
- result.push(`Mariyka need to earn ${(1000 - sum).toFixed(2)} gold more to continue in the next task.`)
- } else {
- result.push(`Mariyka earned ${(sum - 1000).toFixed(2)} gold more.`)
- }
- return result.join('\n');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement