|
@@ -0,0 +1,96 @@
|
|
|
+function aSample() {
|
|
|
+ alert('Привет')
|
|
|
+}
|
|
|
+a();
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// cube //
|
|
|
+
|
|
|
+function cubeSample(a) {
|
|
|
+ return Math.pow(a, 3);
|
|
|
+}
|
|
|
+cube(3)
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// avg2 //
|
|
|
+
|
|
|
+function avg2Sample(a,b) {
|
|
|
+ return (a + b) / 2
|
|
|
+}
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// sum3 //
|
|
|
+
|
|
|
+function sum3Sample(a,b,c) {
|
|
|
+ return (a + b + c)
|
|
|
+}
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// intRandom //
|
|
|
+
|
|
|
+function intRandomSample(min,max) {
|
|
|
+ return Math.round(Math.random() * (max - min) + min)
|
|
|
+}
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// greetAll //
|
|
|
+
|
|
|
+function greetAllSample() {
|
|
|
+ for (let i = 0; i < arguments.length; i++)
|
|
|
+ alert('Hello ' + arguments[i])
|
|
|
+}
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// sum //
|
|
|
+
|
|
|
+function sumSample() {
|
|
|
+ let result = 0;
|
|
|
+
|
|
|
+ for (let i = 0; i < arguments.length; i++) {
|
|
|
+ result += arguments[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ return alert(result);
|
|
|
+ }
|
|
|
+
|
|
|
+//=======================================================================================//
|
|
|
+
|
|
|
+// Union //
|
|
|
+
|
|
|
+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 tasks = {
|
|
|
+ a: aSample(),
|
|
|
+ cube: cubeSample(),
|
|
|
+ avg2: avg2Sample(),
|
|
|
+ sum3: sum3Sample(),
|
|
|
+ intRandom: intRandomSample(),
|
|
|
+ greetAll: greetAllSample(),
|
|
|
+ sum: sumSample(),
|
|
|
+}
|