123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <!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>
|