|
@@ -1,54 +1,129 @@
|
|
|
// ЗАДАНИЕ 2 - a
|
|
|
-// function a(){
|
|
|
-// alert("Привет!");
|
|
|
+// function a(hello){
|
|
|
+// alert(hello);
|
|
|
// }
|
|
|
// a("Привет!");
|
|
|
|
|
|
// ЗАДАНИЕ 3 - cube
|
|
|
// function cube(){
|
|
|
-// number = prompt('Введите число, которую хотите возвести в куб');
|
|
|
-// numberInCube = number * number * number;
|
|
|
-// alert(numberInCube);
|
|
|
+// alert(prompt('Введите число, которую хотите возвести в куб') ** 3);
|
|
|
// }
|
|
|
// cube();
|
|
|
|
|
|
|
|
|
// ЗАДАНИЕ 4 - avg2
|
|
|
-// function avg2(){
|
|
|
-// middleForTwoNumber1 = (1 + 2) / 2;
|
|
|
-// middleForTwoNumber2 = (10 + 5) / 2;
|
|
|
-// alert(middleForTwoNumber1);
|
|
|
-// alert(middleForTwoNumber2);
|
|
|
+// function avg2(a, b){
|
|
|
+// alert((a + b) / 2);
|
|
|
// }
|
|
|
-// avg2();
|
|
|
+// avg2(1, 2);
|
|
|
+// avg2(10, 5);
|
|
|
|
|
|
|
|
|
// ЗАДАНИЕ 5 - sum3
|
|
|
-// var a = 5;
|
|
|
-// var b = 10;
|
|
|
-// function sum3(){
|
|
|
-// sum3Number1 = 1 + 2 + 3;
|
|
|
-// sum3Number2 = a + b + 100500;
|
|
|
-// sum3Number3 = a + b;
|
|
|
-// alert(sum3Number1);
|
|
|
-// alert(sum3Number2);
|
|
|
-// alert(sum3Number3);
|
|
|
+// function sum3(a, b, c=0){
|
|
|
+// alert(a + b + c);
|
|
|
// }
|
|
|
-// sum3();
|
|
|
-
|
|
|
+// sum3(1, 2, 3);
|
|
|
+// sum3(5, 10, 100500);
|
|
|
+// sum3(5, 10);
|
|
|
|
|
|
// ЗАДАНИЕ 6 - intRandom
|
|
|
-// function intRandom(){
|
|
|
-// intRandomNumber1 = Math.floor(Math.random() * (15 - 2)) + 2;
|
|
|
-// intRandomNumber2 = Math.floor(Math.random() * (-1 - (-1))) + (-1);
|
|
|
-// intRandomNumber3 = Math.floor(Math.random() * (1 - 0)) + 0;
|
|
|
-// intRandomNumber4 = Math.floor(Math.random() * (10 - 0)) + 0;
|
|
|
-// alert(intRandomNumber1);
|
|
|
-// alert(intRandomNumber2);
|
|
|
-// alert(intRandomNumber3);
|
|
|
-// alert(intRandomNumber4);
|
|
|
+// function intRandom(a, b=0){
|
|
|
+// alert(Math.floor(Math.random() * (b - a)) + a);
|
|
|
// }
|
|
|
-// intRandom();
|
|
|
+// intRandom(2, 15);
|
|
|
+// intRandom(-1, -1);
|
|
|
+// intRandom(0, 1);
|
|
|
+// intRandom(10);
|
|
|
|
|
|
|
|
|
// ЗАДАНИЕ 7 - greetAll
|
|
|
+// function greetAll(name1, name2, name3){
|
|
|
+// alert('Hello' + ' ' + name1 + ' ' + name2 + ' ' + name3);
|
|
|
+// }
|
|
|
+// greetAll("Superman");
|
|
|
+// greetAll("Superman", "SpiderMan");
|
|
|
+// greetAll("Superman", "SpiderMan", "Captain Obvious");
|
|
|
+
|
|
|
+
|
|
|
+// ЗАДАНИЕ 8 - sum
|
|
|
+// function sum(a, b=0, c=0, d=0){
|
|
|
+// alert(a + b + c + d);
|
|
|
+// }
|
|
|
+// sum(1);
|
|
|
+// sum(2);
|
|
|
+// sum(10, 20, 40, 100);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// ЗАДАНИЕ 8 - Union
|
|
|
+// function a(hello){
|
|
|
+// switch (a){
|
|
|
+// case a: alert(hello);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// a("Привет!");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// function cube(){
|
|
|
+// switch(cube){
|
|
|
+// case cube: alert(prompt('Введите число, которую хотите возвести в куб') ** 3);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// cube();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// function avg2(a, b){
|
|
|
+// switch(avg2){
|
|
|
+// case avg2: alert((a + b) / 2);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// avg2(1, 2);
|
|
|
+// avg2(10, 5);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// function sum3(a, b, c=0){
|
|
|
+// switch (sum3){
|
|
|
+// case sum3: alert(a + b + c);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// sum3(1, 2, 3);
|
|
|
+// sum3(5, 10, 100500);
|
|
|
+// sum3(5, 10);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// function intRandom(a, b=0){
|
|
|
+// switch (intRandom){
|
|
|
+// case intRandom: alert(Math.floor(Math.random() * (b - a)) + a);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// intRandom(2, 15);
|
|
|
+// intRandom(-1, -1);
|
|
|
+// intRandom(0, 1);
|
|
|
+// intRandom(10);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// function greetAll(name1, name2, name3){
|
|
|
+// switch (greetAll){
|
|
|
+// case greetAll: alert('Hello' + ' ' + name1 + ' ' + name2 + ' ' + name3);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// greetAll("Superman");
|
|
|
+// greetAll("Superman", "SpiderMan");
|
|
|
+// greetAll("Superman", "SpiderMan", "Captain Obvious");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// function sum(a, b=0, c=0, d=0){
|
|
|
+// switch (sum){
|
|
|
+// case sum: alert(a + b + c + d);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// sum(1);
|
|
|
+// sum(2);
|
|
|
+// sum(10, 20, 40, 100);
|