Browse Source

Homework.5

Marko 1 year ago
parent
commit
82c06e6356
1 changed files with 34 additions and 4 deletions
  1. 34 4
      file.js

+ 34 - 4
file.js

@@ -11,7 +11,7 @@ function cube(x){
     return x**3;
     }
     
-    let result = cube();
+cube();
 
 // avg2
 
@@ -19,12 +19,42 @@ function avg2(a,b){
     return (a + b)/2
 }
 
-let result1 = avg2();
+avg2();
 
 // sum3
 
 function sum3(a,b,c){
-    return (a + b + c) || (a + b) || (b + c) || (a + c)
+    return (a + b + c) || (a + b) 
 }
-let result2 = sum3()
+sum3();
+
+// intRandom
+
+function intRandom(a,b) {
+    if(b === undefined){
+     c = (Math.round(Math.random() *a))
+    }else 
+    c = (Math.round(Math.random() * (b - a) + a));
+ return c
+    }
+intRandom()
+
+// greetAll ?
+
+function greetAll(){
+    for(i = 0;i<arguments.length;i++){
+        alert(`Hi, ${arguments[i]}`)};
+
+}
+greetAll()
+
+// sum
+
+function sum(){
+    let result = 0;
+       for(i = 0;i<arguments.length;i++){
+     result += arguments[i]};
+   return result
+   }
+   sum()