Back-End Technologies Basics - септември 2024 - JS Basics - Exercises

Здравейте, имам проблем с Judge относно няколко задачи, според Visual Studio Code работи, според Judge - не. Ето задачите и кода ми:

01. Ages

function printType (age){

    if(age >= 0 && age <= 2){
        console.log('baby')
    } else if (age >= 3 && age <= 13){
        console.log('child')
    } else if (age >= 14 && age <= 19){
        console.log('teenager')
    } else if (age >= 20 && age <= 65){
        console.log('adult')
    } else if (age >= 66){
        console.log('elder')
    } else
    console.log('out of bounds')  
}

 

04. Print And Sum

function printAndSum (startNumber, endNumber){

    let textForPrint = '';
    let sumNumbers = 0;

    for(let number = startNumber; number <= endNumber; number++){
        textForPrint += number + ' ';
        sumNumbers += number;
    }
    console.log(textForPrint);
    console.log('Sum: ' + sumNumbers);
}

07. Reversed Chars

 

function reverseChar (fistString, secondString, thirdString){
    const string = thirdString + ' ' + secondString + ' ' + fistString;
    console.log(string);
 }

 

11. Cooking by Numbers

 

function cookNumber (number, firstOp, SecOp, thirdOp, forthOp, fiftOp){
number = executeOperation(number, firstOp);
console.log(number);
number = executeOperation(number, SecOp);
console.log(number);
number = executeOperation(number, thirdOp);
console.log(number);
number = executeOperation(number, forthOp);
console.log(number);
number = executeOperation(number, fiftOp);
console.log(number);

}
function executeOperation (number, operation){
    switch(operation){
        case 'chop':
            number /= 2;
            break;
        case 'dice':
            number = Math.sqrt(number);
            break;
        case 'spice':
            number += 1;
            break;
        case 'bake':
            number *= 3;
            break;
        case 'fillet':
            number = number - 0.2 * number;
            break;
    }
    return number;
}

 

Линк към задачите в Judge: https://judge.softuni.org/Contests/Compete/Index/4628#0

Няма да получа точки за домашното пък са решени indecision