DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on • Edited on

1

Functions in JavaScript | JavaScript #9

// Function in JavaScript
// A JavaScript function is a block of code designed to perform a particular tast

function onePlusAvg(x,y){
console.log("Done")
return 1 + (x+y)/2
}

// function onePlusAvg(x,y){
// console.log("Done")
// return Math.round(1 + (x+y)/2)
// }

let a = 1;
let b = 2;
let c = 3;

// console.log("Average of a and b is ", (a + b)/2)
// console.log("Average of b and c is ", (a + b)/2)
// console.log("Average of a and c is ", (a + b)/2)

// console.log("One plus Average of a and b is ", onePlusAvg(a,b))
// console.log("One plus Average of a and b is ", onePlusAvg(b,c))
// console.log("One plus Average of a and b is ", onePlusAvg(a,c))

console.log("One plus Average of a and b is ", onePlusAvg(a,b))
console.log("One plus Average of a and b is ", onePlusAvg(b,c))
console.log("One plus Average of a and b is ", onePlusAvg(a,c))

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (1)

Collapse
 
goku_91 profile image
Si

very Nice

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay