// traditonal function 

function sum(a,b) {
    return a+b;
}




// arrow function

const sum1 = (a,b) => { return a+b}  // for logic code

//or

const sum2=(a,b) => a+b;  // for direct returning

console.log(sum1(2,3));
console.log(sum2(3,4))



//more 

let myFun = (msg) => { console.log("your msg : ",msg)  }

myFun("Hello Guys")


//////////////////////////////////////////////////PRACTICE QUES ///////////////////////////////////
//function that take srting and return number of vowels

function giveVowels(msg){
 numberOfVowels =0;

    for(i=0;i<msg.length;i++){
    
     char = msg.charAt(i);
        
        if(char=="a"||char=="e"||char=="i"||char=="o"||char=="u"){
            numberOfVowels++;
         
        }
    }
    return "Number of vowels : ",numberOfVowels;
}

console.log(giveVowels("Hii I am Vikas Nagar"))


// Same ques with arrow function
let giveVowels2 =(msg)=> { numberOfVowels =0;

    for(i=0;i<msg.length;i++){
    
     char = msg.charAt(i);
        
        if(char=="a"||char=="e"||char=="i"||char=="o"||char=="u"){
            numberOfVowels++;
         
        }
    }
    return "Number of vowels : ",numberOfVowels;
  }


console.log(giveVowels2("Hii I am Vikas Nagar"))

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: