/* function add(a, b = 1) { return a+b; } console.log(add(4)) function add( n1,n2) { var sum = n1 + n2 console.log("The sum of the values entered "+sum) } add(12,13) function retStr() { return "hello world!!!" } var val = retStr() console.log(val) function addTwoNumbers(first ,second = 10){ console.log('first parameter is :',first) console.log('second parameter is :',second) return first+second; } console.log("case 1 sum:",addTwoNumbers(20)) // no value console.log("case 2 sum:",addTwoNumbers(2,3)) console.log("case 3 sum:",addTwoNumbers()) console.log("case 4 sum",addTwoNumbers(1,null))//null passed console.log("case 5 sum",addTwoNumbers(3,undefined)) */ // ANONYM FUNCTION var func = function(x,y){ return x*y }; function product() { var result; result = func(10,20); console.log("The product : "+result) } product() // Function var func = new Function("x", "y", "return x*y;"); function product() { var result; result = func(10,20); console.log("The product : "+result) } product() var func = new Function("x", "y", "return x*y;"); function product() { var result; result = func(10,20); console.log("The product : "+result) } product() function factorial(num) { if(num <= 0) { return 1; } else { return (num * factorial(num-1) ) } } console.log(factorial(6))