Browse Source

'.gitignore

vladislavaSim 1 year ago
parent
commit
afdfcce3b7
3 changed files with 82 additions and 0 deletions
  1. 9 0
      .gitignore
  2. 10 0
      HW6/index.html
  3. 63 0
      HW6/main.js

+ 9 - 0
.gitignore

@@ -0,0 +1,9 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+.idea/

+ 10 - 0
HW6/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>HW 6</title>
+</head>
+<body>
+<script src="main.js"></script>
+</body>
+</html>

+ 63 - 0
HW6/main.js

@@ -0,0 +1,63 @@
+function a(text) {
+    alert(text)
+}
+
+function cube(n) {
+    return Math.pow(n, 3)
+}
+
+function avg2(a, b) {
+    return (a + b) / 2
+}
+
+function sum3(a, b, ...c) {
+    return a + b + +c
+}
+function intRandom(min = 0, max = 10) {
+    return Math.round(Math.random() * (max - min - 1) + min)
+}
+
+function greetAll(...arguments) {
+    for(let arg of arguments) {
+        alert(`Hello, ${arg}!`)
+    }
+}
+function sum(...arguments) {
+    let result = 0
+    for(let num of arguments) {
+        result += num
+    }
+    return result
+}
+
+var sample = prompt("Введите название задания")
+switch (sample.toLowerCase()){
+    case "a": a('Test prompt')
+        break
+    case "cube": cube(5)
+        break
+    case 'avg2': avg2(55, 17)
+        break
+    case 'sum3': sum3(5, 82, 47)
+        break
+    case 'intRandom': intRandom(1, 105)
+        break
+    case 'greetAll': greetAll('Sonya', 'Kerry', 'Eve')
+        break
+    case 'sum': sum(45, 741, 32, 14)
+        break
+    default:
+        a()
+}
+
+let sampleObj = {
+        a: a(),
+        cube: cube(),
+        avg2: avg2(),
+        sum3: sum3(),
+        intRandom: intRandom(),
+        greetAll: greetAll(),
+        sum: sum(),
+    };
+
+console.log(sampleObj[prompt("Введите название задания")]);