Saturday, August 21, 2021

Using Functions in Javascript Basic guideline

Function in Javascript : In Simple term Function is piece of code which can be used over and over again.Its little bit like variable but its whole chunk of code.Function can hold any number of complete lines of code.

// Simple console log function..

function logger() {
console.log(`Hey I am a Simple Function`);
}
// Calling Function to Print in Console
logger();

Function with Argument -

// Function with argument in Javascript..

function fruitProcessor(apples, oranges) {
console.log(apples, oranges);
const fruitMix = `Juice of ${apples} apples and ${oranges} oranges`;
return fruitMix;
}

const fruitJuice = fruitProcessor(1, 5);
console.log(fruitJuice);
//OR

console.log(fruitProcessor(2, 7));

0 comments

Post a Comment