function a(text) {
    alert(text)
}

function cube(n) {
    return Math.pow(n, 3)
}

function avg2(a, b) {
    return (a + b) / 2
}

function sum3(a, b, ...c) {
    return a + b + +c
}
function intRandom(min = 0, max = 10) {
    return Math.round(Math.random() * (max - min - 1) + min)
}

// function greetAll(...arguments) {
//     for(let arg of arguments) {
//         alert(`Hello, ${arg}!`)
//     }
// }

function greetAll(...arguments) {
    arguments = arguments.map(item => ' ' + item)
    alert(`Hello, ${arguments}!`)

}
function sum(...arguments) {
    let result = 0
    for(let num of arguments) {
        result += num
    }
    return result
}

var sample = prompt("Введите название задания")

switch (sample.toLowerCase()){
    case "a": a('Test prompt')
        break
    case "cube": cube(5)
        break
    case 'avg2': avg2(55, 17)
        break
    case 'sum3': sum3(5, 82, 47)
        break
    case 'intRandom': intRandom(1, 105)
        break
    case 'greetAll': greetAll('Sonya', 'Kerry', 'Eve')
        break
    case 'sum': sum(45, 741, 32, 14)
        break
    default:
        a()
}

let sampleObj = {
        a() {
            a('Test prompt')
        },
        cube() {
            cube(50)
        },
        avg2() {
            avg2(55, 17)
        },
        sum3() {
            sum3(5, 82, 47)
        },
        intRandom() {
            intRandom(1, 50)
        },
        greetAll() {
            greetAll('Sonya', 'Kerry', 'Eve')
        },
        sum() {
            sum(45, 741, 32, 14)
        },
    };

console.log(sampleObj[prompt("Введите название задания")]());
