12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- function a (text="called function alert") {
- alert(text);
- }
- /* a("hello"); */
- /* function cube (number) {
- return number **3;
- }
- a(cube(3)); */
- /* function avg(a,b){
- return ((a+b)/2);
- }
- a(avg(1,2));
- a(avg(10,5)); */
- /* function sum3 (a=0,b=0,c=0) {
- return a+b+c;
- }
- a(sum3(1,2,3));
- a(sum3(5,10,100500));
- a(sum3(10,5)); */
- /* function intRandom (min,max=0) {
- if(max == 0 ){
- return Math.floor(Math.random()* (min-max+1))+max;
- }
- return Math.floor(Math.random()* (max-min+1))+min;
- }
- a(intRandom(100)); */
- /* function greetAll(...names) {
- let greetArr = [];
- for(let i = 0 ; i< arguments.length; i++){
- greetArr.push(names[i]);
- }
- alert(greetArr);
- }
- greetAll("SPYDIK","KYRKA","VETAL"); */
- function sum(...numarr){
- /* let result=0;
- for(let i =0; i<arguments.length;i++){
- debugger;
- result=result+arguments[i];
- }
- alert(result); */
- let arrforsum = [];
- for(let i = 0; i<arguments.length; i++){
- arrforsum.push(numarr[i]);
- }
- let sum = 0 ;
- for(let i =0; i<arrforsum.length;i++){
- sum=sum+arrforsum[i];
- }
- alert(sum);
- /* return alert(numarr.reduce((a,b) => a+b)); */
- }
- sum(...[10,2,20]);
|