|
@@ -56,7 +56,6 @@ function sum(...arguments) {
|
|
let result = 0
|
|
let result = 0
|
|
for (let arg of arguments) {
|
|
for (let arg of arguments) {
|
|
result += arg
|
|
result += arg
|
|
-
|
|
|
|
}
|
|
}
|
|
console.log(result)
|
|
console.log(result)
|
|
}
|
|
}
|
|
@@ -65,6 +64,35 @@ sum(2)
|
|
sum(10, 20, 40, 100)
|
|
sum(10, 20, 40, 100)
|
|
|
|
|
|
// Union
|
|
// Union
|
|
|
|
+var 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;
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+// Union declarative
|
|
|
|
+var sample = prompt("Введите название задания").toLowerCase()
|
|
|
|
+var sample2;
|
|
|
|
+var sample1 = {
|
|
|
|
+ a: a(),
|
|
|
|
+ cube: cube(),
|
|
|
|
+ avg2: avg2(),
|
|
|
|
+ sum3: sum3(),
|
|
|
|
+ intRandom: intRandom(),
|
|
|
|
+ greetAll: greetAll(),
|
|
|
|
+ sum: sum(),
|
|
|
|
+}
|
|
|
|
+sample2 = sample[`${sample}`]
|