12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //a
- function a(hi){
- alert(hi)
- }
- a("Привет!") // вызывает alert("Привет!")
- //cube
- function greet(step){
- var stepin = step**3
- console.log(stepin)
- }
- greet(prompt("введите число для возвидения в третью степень", "число"))
- //avg2
- function average (a,b){
- let avg2 = (a+b)/2
- console.log(avg2)
- }
- average(1,2)
- average(5,10)
- //sum3
- function sumTree (a=0,b=0,c=0){
- let sum3 = a+b+c
- console.log(sum3)
- }
- sumTree(1,2,3)
- sumTree(5,10,100500)
- sumTree(5,10)
- //greetAll
- function userName(a, b, c) {
- arguments[0]=prompt("What u name","Superman");
- alert(`Hellow ${arguments[0]} `);
- arguments[1]=prompt("What u surName","SpiderMan");
- alert(`Hellow ${arguments[0]}, ${arguments[1]}`);
- arguments[2]=prompt("What u fatherName","Captain Obvious");
- alert(`Hellow ${arguments[0]}, ${arguments[1]}, ${arguments[2]}`);
- };
- userName();
- //sum
- function sum() {
- var fullSum = 0;
- for (var i = 0; i < arguments.length; i++) {
- fullSum += arguments[i];
- }
- console.log(fullSum)
- return fullSum;
- }
- sum(1)
- sum(2)
- sum(10,20,40,100)
- //union
- var unionCheck = prompt("Введите название задания")
- switch (unionCheck.toLowerCase()){
- case "a": a()
- break
- case "cube": greet()
- break
- case "avg2": average()
- break
- case "sum3": sumTree()
- break
- case "greetAll": userName()
- break
- case "sum": sum()
- break
- }
|