//a function a(msg) { alert(msg) } //cube function cube(number) { let cube = number * number * number; return cube; } //avg2 function avg2(a, b) { let avg2 = (a + b) / 2; return avg2; } //sum3 function sum3(a = 0, b = 0, c = 0) { let sum = a + b + c; return sum; } //intRandom function intRandom(a = 0, b = 0) { return Math.round(Math.random() * (b - a)) + a; } //greetAll function greetAll() { for (let i in arguments) { alert(arguments[i]) } } //sum function sum() { let sum = 0; for (let i of arguments) { sum += i; } return sum; } //Union function aSample() { a("Привет!") // вызывает alert("Привет!") } function cubeSample() { cube(5) // => 125 } function avg2Sample() { avg2(10, 5) // возвращает 7.5 } function sum3Sample() { sum3(5, 10, 100500) // => 100515 } function intRandomSample() { intRandom(2, 15) // возвращает целое случайное число от 2 до 15 (включительно) } function greetAllSample() { greetAll("Superman", "SpiderMan", "Captain Obvious") // выводит alert "Hello Superman, SpiderMan, Captain Obvious" } function sumSample() { sum(10, 20, 40, 100) // => 170 } let sample = prompt("Введите название задания"); switch (sample.toLowerCase()) { case "a": aSample(); break; case "cube": cubeSample(); break; case "avg2": avg2Sample(); break; case "sum3": sum3Sample(); break; case "intRandom": intRandomSample(); break; case "greetAll": greetAllSample(); break; case "sum": sumSample(); break; } //Union declarative let hometask = { a: () => a("Привет!"), cube: () => cube(5), avg2: () => avg2(10, 5), sum3: () => sum3(5, 10, 100500), intRandom: () => intRandom(2, 15), greetAll: () => greetAll("Superman", "SpiderMan", "Captain Obvious"), sum: () => sum(10, 20, 40, 100) }