///Закомментила рабочие функции, которые потом переобразовала для свича и обьекта. Свич тоже закомментила, чтобы не мешал работать 
///с обьектом


function a(something) {
    return alert(something)
}
function cube(number) {
    number = Math.pow(number, 3)
    return alert(number)
}
function avg2(a, b) {
    var medium = (a + b) / 2 
    return alert(medium)
 }
function sum3(a, b, c=0) {
    debugger
    var sum = a + b + c
    return alert(sum)
}
function intRandom (a, b=0) {
    var yourNumber = b + (Math.round(Math.random() * (a - b)))
    return alert(yourNumber)
}
// function greetAll(){
//     var str = ""
//     for (let key of arguments) {
//         str += `, ${key}`
//     }
//     return alert ("Hello" + str)
// }
function greetAllEdit(){
    var promptValue = true
    argumentsArr = []
    while(!!promptValue == true){
        promptValue = prompt("Who are you?")
        argumentsArr.push(promptValue)
    }
    argumentsArr.pop()
    greetAll(argumentsArr)

}
function greetAll(arguments){
    var str = ""
    for (let key of arguments) {
        str += `, ${key}`
    }
    return alert ("Hello" + str)
}
// function sum() {
//     var count = 0
//     for (let key of arguments) {
//         count += key
//     }
//     return alert(count)
// }
function sumEdit() {
    var promptValue = true
    argumentsArr = []
    while(!!promptValue == true){
        promptValue= +prompt("Write a number")
        argumentsArr.push(promptValue)
    }
    argumentsArr.pop()
    sum(argumentsArr)
}
function sum(arguments) {
    var count = 0
    for (let key of arguments) {
        count += +key
    }
    return alert(count)
}
// let exersice = prompt("Chose exersice: \n a - 1 \n cube - 2 \n avg2 - 3 \n sum3- 4 \n intRandom - 5\n greetAll - 6 \n sum- 7")
// switch (exersice){
//     case "1": a(prompt("Write something")); break; 
//     case "2": cube(+prompt("Your number is...")); break;
//     case "3": avg2(+prompt("First number"), +prompt("Second number")); break;
//     case "4": sum3(+prompt("Your first number"), +prompt("Your second number"), +prompt("Your third number(if you need it)")); break;
//     case "5": intRandom(+prompt("Max"), +prompt("Min")); break;
//     case "6": greetAllEdit();  break;///отредактировала эту ф-цию, чтобы можно было много параметров делать промтом.
//     case "7": sumEdit(); break;///аналогично
//     default: alert("Error. Try again") 
// }

let exersixeObj = {
    "1": function () {
        var something = prompt("Write something")
        return alert(something)
    },
    "2": function () {
        var number = +prompt("Your number is...")
        number = Math.pow(number, 3)
        return alert(number)
    },
    "3": function () {
        let a = +prompt("First number"); let b = +prompt("Second number")
        var medium = (a + b) / 2 
        return alert(medium)
     },
    "4": function (c=0) {
        a = +prompt("Your first number"); b = +prompt("Your second number"); c = +prompt("Your third number(if you need it)")
        c = c ? c: 0
        var sum = a + b + c
        return alert(sum)
    },
    "5": function  (a, b=0) {
        a = +prompt("Max"); b = +prompt("Min")
        b = b ? b: 0;
        var yourNumber = b + (Math.round(Math.random() * (a - b)))
        return alert(yourNumber)
    },
    "6": function (){
        var promptValue = true
        argumentsArr = []
        while(!!promptValue == true){
            promptValue = prompt("Who are you?")
            argumentsArr.push(promptValue)
        }
        argumentsArr.pop()
        this["8"](argumentsArr)
    
    },
    "8":function (arguments){
        var str = ""
        for (let key of arguments) {
            str += `, ${key}`
        }
        return alert ("Hello" + str)
    },
    "7": function () {
        var promptValue = true
        argumentsArr = []
        while(!!promptValue == true){
            promptValue= +prompt("Write a number")
            argumentsArr.push(promptValue)
        }
        argumentsArr.pop()
        this["9"](argumentsArr)
    },
    "9": function (arguments) {
        var count = 0
        for (let key of arguments) {
            count += +key
        }
        return alert(count)
    }
}
let checking = prompt("Chose exersice: \n a - 1 \n cube - 2 \n avg2 - 3 \n sum3- 4 \n intRandom - 5\n greetAll - 6 \n sum- 7")
exersixeObj[checking]()