123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- // a
- function a() {
- alert('Привет');
- }
- // cube
- function cube(number) {
- number = number ** 3;
- return number;
- }
- // avg2
- function avg2(a = 0, b = 0) {
- let avg = (a + b) / 2;
- return avg;
- };
- // sum3
- function sum3(a = 0, b = 0, c = 0) {
- let sum = (a + b + c);
- return sum;
- }
- // intRandom
- function intRandom(a = 0, b = 0) {
- let randomNumber = Math.random() * (b - a) + a;
- return Math.round(randomNumber);
- };
- // greetAll
- function greetAll() {
- for (let i = 0; i < arguments.length; i++) {
- alert("Hello, " + arguments[i]);
- };
- };
- // sum
- function sum() {
- let result = 0;
- for (let i = 0; i < arguments.length; i++) {
- result += arguments[i];
- }
- return result;
- }
- // Union
- function aSample() {
- return a("Привет!");
- }
- function cubeSample() {
- return cube(5);
- }
- function avg2Sample() {
- return avg2(10, 5);
- }
- function sum3Sample() {
- return sum3(2, 4, 6);
- }
- function intRandomSample() {
- return intRandom(0, 1);
- }
- function greetAllSample() {
- return greetAll("Superman", "SpiderMan", "Captain Obvious");
- }
- function sumSample() {
- return sum(10, 20, 40, 100);
- }
- var taskName = prompt("Введите название задания");
- switch (taskName.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 unionDeclarative = {
- a: aSample(),
- cube: cubeSample(),
- avg2: avg2Sample(),
- sum3: sum3Sample(),
- intRandom: intRandomSample(),
- greetAll: greetAllSample(),
- sum: sumSample()
- }
|