|
@@ -0,0 +1,149 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <script>
|
|
|
+
|
|
|
+ //a
|
|
|
+ function a(text) {
|
|
|
+ alert(text)
|
|
|
+ }
|
|
|
+ a("Привет!")
|
|
|
+
|
|
|
+ //cube
|
|
|
+ function cube(a) {
|
|
|
+ return Math.pow(a, 3)
|
|
|
+ }
|
|
|
+ let result = cube(3);
|
|
|
+ alert(result);
|
|
|
+
|
|
|
+ //avg2
|
|
|
+ function avg2(a, b) {
|
|
|
+ return (a + b) / 2
|
|
|
+ }
|
|
|
+ avg2(3, 3);
|
|
|
+
|
|
|
+ //sum3
|
|
|
+ function sum3(a = 0, b = 0, c = 0) {
|
|
|
+ console.log(arguments)
|
|
|
+ return a + b + c;
|
|
|
+ }
|
|
|
+ sum3(3, 2, 1);
|
|
|
+
|
|
|
+ //intRandom
|
|
|
+ function intRandom(min = 0, max = 0) {
|
|
|
+ return Math.round(Math.random() * (max - min) + min);
|
|
|
+ }
|
|
|
+ intRandom(10)
|
|
|
+
|
|
|
+ //greetAll
|
|
|
+ function greetAll() {
|
|
|
+ var result = " "
|
|
|
+ for (var i = 0; i < arguments.length; i++) {
|
|
|
+ result += " " + arguments[i] + ",";
|
|
|
+ }
|
|
|
+ alert("Hello" + result);
|
|
|
+ }
|
|
|
+ greetAll("Superman", "SpiderMan", "Captain Obvious",)
|
|
|
+
|
|
|
+ //sum
|
|
|
+ function sum() {
|
|
|
+ var result = 0;
|
|
|
+ for (var i = 0; i < arguments.length; i++) {
|
|
|
+ result += arguments[i];
|
|
|
+ }
|
|
|
+ alert(result)
|
|
|
+ }
|
|
|
+ sum(1, 2, 3, 4, 5);
|
|
|
+
|
|
|
+ //Union
|
|
|
+
|
|
|
+ function aSample() {
|
|
|
+ return a("Привет!")
|
|
|
+ }
|
|
|
+ function cubeSample() {
|
|
|
+ return cube(3)
|
|
|
+ }
|
|
|
+ function avg2Sample() {
|
|
|
+ return avg2(3, 3)
|
|
|
+ }
|
|
|
+ function sum3Sample() {
|
|
|
+ return sum3(3, 2, 1)
|
|
|
+ }
|
|
|
+ function intRandomSample() {
|
|
|
+ return intRandom(4, 10)
|
|
|
+ }
|
|
|
+ function greetAllSample() {
|
|
|
+ return greetAll("Pingvini", "Ennoti", "Banana",)
|
|
|
+ }
|
|
|
+ function sumSample() {
|
|
|
+ return sum(1, 2, 3, 4, 5, 600)
|
|
|
+ }
|
|
|
+
|
|
|
+ var 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;
|
|
|
+ default: alert("Что-то не то")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var arr = {
|
|
|
+ a: aSample(),
|
|
|
+ cube: cubeSample(),
|
|
|
+ avg2: avg2Sample(),
|
|
|
+ sum3: sum3Sample(),
|
|
|
+ intRandom: intRandomSample(),
|
|
|
+ greetAll: greetAllSample(),
|
|
|
+ sum: sumSample(),
|
|
|
+ }
|
|
|
+ console.log(arr[prompt("Введите название задания")]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|