|
@@ -34,16 +34,12 @@
|
|
|
//Task intRandom
|
|
|
// function intRandom (a, b) {
|
|
|
// let c = b - a;
|
|
|
-// b ? b = a : a = 0;
|
|
|
-
|
|
|
+
|
|
|
// if (a === b) {
|
|
|
// return a;
|
|
|
// }
|
|
|
-
|
|
|
-// (b - a) ? c : c = a ;
|
|
|
-
|
|
|
-// return(Math.round( Math.random() * c ));
|
|
|
-// }
|
|
|
+// return (c) ? (Math.round( Math.random() * c + a)): (Math.round( Math.random() * a ));
|
|
|
+// };
|
|
|
// intRandom(2,15) // возвращает целое случайное число от 2 до 15 (включительно)
|
|
|
// intRandom(-1,-1) // вернет -1
|
|
|
// intRandom(0,1) // вернет 0 или 1
|
|
@@ -112,17 +108,14 @@
|
|
|
// break;
|
|
|
|
|
|
// case "intrandom": function intRandom (a, b) {
|
|
|
-// let c = b - a;
|
|
|
-// b ? b = a : a = 0;
|
|
|
-
|
|
|
-// if (a === b) {
|
|
|
-// return a;
|
|
|
-// }
|
|
|
-
|
|
|
-// (b - a) ? c : c = a ;
|
|
|
-
|
|
|
-// return(Math.round( Math.random() * c ));
|
|
|
-// }
|
|
|
+// let c = b - a;
|
|
|
+
|
|
|
+// if (a === b) {
|
|
|
+// return a;
|
|
|
+// }
|
|
|
+// return (c) ? (Math.round( Math.random() * c + a)): (Math.round( Math.random() * a ));
|
|
|
+
|
|
|
+// };
|
|
|
// intRandom(2,15);
|
|
|
// intRandom(0,1);
|
|
|
// intRandom(10);
|
|
@@ -154,47 +147,43 @@
|
|
|
// break;
|
|
|
// };
|
|
|
|
|
|
-let setFunction ={
|
|
|
- "a": function (b){
|
|
|
- alert(b);
|
|
|
- },
|
|
|
- "cube": function cube(a) {
|
|
|
- return (a*a*a);
|
|
|
- },
|
|
|
- "avg2": function avg2 (a, b) {
|
|
|
- return ((a + b) / 2);
|
|
|
- },
|
|
|
- "sum3": function sum3 (a, b, c = 0) {
|
|
|
- return (a + b + c) ;
|
|
|
- },
|
|
|
- "intrandom": function intRandom (a, b) {
|
|
|
- let c = b - a;
|
|
|
- b ? b = a : a = 0;
|
|
|
-
|
|
|
- if (a === b) {
|
|
|
- return a;
|
|
|
- }
|
|
|
-
|
|
|
- (b - a) ? c : c = a ;
|
|
|
+// let setFunction ={
|
|
|
+// "a": function (b){
|
|
|
+// alert(b);
|
|
|
+// },
|
|
|
+// "cube": function cube(a) {
|
|
|
+// return (a*a*a);
|
|
|
+// },
|
|
|
+// "avg2": function avg2 (a, b) {
|
|
|
+// return ((a + b) / 2);
|
|
|
+// },
|
|
|
+// "sum3": function sum3 (a, b, c = 0) {
|
|
|
+// return (a + b + c) ;
|
|
|
+// },
|
|
|
+// "intrandom": function intRandom (a, b) {
|
|
|
+// let c = b - a;
|
|
|
|
|
|
- return(Math.round( Math.random() * c ));
|
|
|
- },
|
|
|
- "greetall": function greetAll (arg) {
|
|
|
- let str = `Hello`;
|
|
|
- for (let i of arguments) {
|
|
|
- str += ' ' + i + ',';
|
|
|
- }
|
|
|
- str = str.slice(0, -1);
|
|
|
- alert(str);
|
|
|
- },
|
|
|
- "sum": function sum (...arg) {
|
|
|
- let acum = 0;
|
|
|
- for (let value of arg) {
|
|
|
- acum += value;
|
|
|
- }
|
|
|
- return acum;
|
|
|
- }
|
|
|
-};
|
|
|
+// if (a === b) {
|
|
|
+// return a;
|
|
|
+// }
|
|
|
+// return (c) ? (Math.round( Math.random() * c + a)): (Math.round( Math.random() * a ));
|
|
|
+// },
|
|
|
+// "greetall": function greetAll (arg) {
|
|
|
+// let str = `Hello`;
|
|
|
+// for (let i of arguments) {
|
|
|
+// str += ' ' + i + ',';
|
|
|
+// }
|
|
|
+// str = str.slice(0, -1);
|
|
|
+// alert(str);
|
|
|
+// },
|
|
|
+// "sum": function sum (...arg) {
|
|
|
+// let acum = 0;
|
|
|
+// for (let value of arg) {
|
|
|
+// acum += value;
|
|
|
+// }
|
|
|
+// return acum;
|
|
|
+// }
|
|
|
+// };
|
|
|
|
|
|
//setFunction.greetall("Вася, Петя")
|
|
|
|