Call by Value vs Return By Value in JavaScript

Free Web development courses with real-time projects Start Now!!

Program 1

/* 
   fucntion
     defination of function

     calling of function
*/
        
// function dataflair()  //defination  
// {
//     console.log("This is user define function")
// }


// dataflair()   //calling
// console.log("welcome in my program")
// dataflair()  //calling


//Developer
function factorial(n)  // parameter
{
               let f=1
                while(n!=0)
                {
                    f=f*n
                    n--
                }
              return f   // return by value  
}
"use strict"
const ps=require("prompt-sync")
const prompt=ps({sigint:true})
let n=prompt("Enter a number")

let m=factorial(n)

console.log("Factorial is " + m)
if(m%2==0)
  console.log("No is even")
else
console.log("No is even")

//  palindrom
//  reverse
// sqaure

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *