function a(){ alert("Привет!"); } a() // function cube(){ console.log(prompt(`число`)**3); } cube(); // function avg2 (a, b){ console.log((a + b) / 2); } avg2(1,2); avg2(10,5); // function sum3 (a, b, c){ a = a || 0; b = b || 0; c = c || 0; return(a + b + c); } sum3(1,2,3); sum3(5,10,100500); sum3(5,10); // function intRandom (a, b){ a = a || 0; b = b || 0; let number = (Math.random() * (b - a) + a); return Math.round(number); } console.log(intRandom(2, 15)) console.log(intRandom(-1, -1)) console.log(intRandom(0, 1)) console.log(intRandom(10)) // function greetAll() { for(let i of arguments) { alert(`Hello ${i}`) } } greetAll("Superman") greetAll("Superman", "SpiderMan") greetAll("Superman", "SpiderMan", "Captain Obvious") // function sum (){ let resulta = 0; for(let i of arguments){ resulta += i; } console.log(resulta); } sum(1) sum(2) sum(10, 20, 40, 100) // function aSample(){ a("Привет!") // вызывает alert("Привет!") } function cubeSample(){ cube(5) // => 125 } let sample = prompt("Введите название задания") switch (sample.toLowerCase()){ case "a": a() break case "cube": cube() break case "avg2": avg2() break case "sum3": sum3() break case "intRandom": intRandom() break case "greetAll": greetAll() break case "sum": sum() break } // let sampl = { a: a(), cube: cube(), avg2: avg2(), sum3: sum3(), intRandom: intRandom(), greetAll: greetAll(), sum: sum() } let sampl1 = prompt("Введите название функции") alert(sampl1[`${sampl}`])