|
@@ -0,0 +1,70 @@
|
|
|
+// a
|
|
|
+function a() {
|
|
|
+ alert('Привет');
|
|
|
+}
|
|
|
+a()
|
|
|
+
|
|
|
+// cube
|
|
|
+function cube() {
|
|
|
+ console.log(prompt('number') ** 3);
|
|
|
+}
|
|
|
+cube()
|
|
|
+
|
|
|
+// avg2
|
|
|
+function avg2(a, b) {
|
|
|
+ console.log((a + b) / 2);
|
|
|
+}
|
|
|
+avg2(5, 10)
|
|
|
+avg2(1, 2)
|
|
|
+
|
|
|
+// sum3
|
|
|
+function sum3(a, b, c) {
|
|
|
+ a = a || 0;
|
|
|
+ b = b || 0;
|
|
|
+ c = c || 0;
|
|
|
+ return a + b + c;
|
|
|
+}
|
|
|
+console.log(sum3(1, 2, 3))
|
|
|
+console.log(sum3(5, 10, 100500))
|
|
|
+console.log(sum3(5, 10))
|
|
|
+
|
|
|
+// intRandom
|
|
|
+function intRandom(min, max) {
|
|
|
+ min = min || 0;
|
|
|
+ max = max || 0;
|
|
|
+ let result = Math.random() * (max - min) + min;
|
|
|
+ return Math.round(result)
|
|
|
+}
|
|
|
+console.log(intRandom(2, 15))
|
|
|
+console.log(intRandom(-1, -1))
|
|
|
+console.log(intRandom(0, 1))
|
|
|
+console.log(intRandom(10))
|
|
|
+
|
|
|
+// greetAll
|
|
|
+function greetAll(...arguments) {
|
|
|
+ for (let arg of arguments) {
|
|
|
+ alert(`Hello ${arg}!`)
|
|
|
+ }
|
|
|
+}
|
|
|
+greetAll("Superman")
|
|
|
+greetAll("Superman", "SpiderMan")
|
|
|
+greetAll("Superman", "SpiderMan", "Captain Obvious")
|
|
|
+
|
|
|
+
|
|
|
+// sum
|
|
|
+function sum(...arguments) {
|
|
|
+ let result = 0
|
|
|
+ for (let arg of arguments) {
|
|
|
+ result += arg
|
|
|
+
|
|
|
+ }
|
|
|
+ console.log(result)
|
|
|
+}
|
|
|
+sum(1)
|
|
|
+sum(2)
|
|
|
+sum(10, 20, 40, 100)
|
|
|
+
|
|
|
+// Union
|
|
|
+
|
|
|
+
|
|
|
+
|