DEV Community

TimothyAgevi
TimothyAgevi

Posted on

Javascript Functions

important terms

1.function-Subprogram called to perform a particular task.
2.Variable- identifier used to represent a single data item.
3.Parameter-Variable used to store values ,within a function.
4.Arguments-Actual values stored within a function.

3 Ways of Declaring Function

a)1.traditional way

function calAge(cyear,yob){
return cyear-yob;
}
console.log(calAge(2021,2000))

b)embedding it in a variable

const age=function calAge(cyear,yob){
return cyear-yob;
}
console.log(age(2021,2000)

c)Using Arrow

const age = (cyear, yob) => {
return cyear - yob;
}
console.log(age(2021,2000)

note

for all the above the output is 21,

parameters are those inside the function parenthesis while auguments are the 2021,2000 values within the console.log().

try it yourself,happy coding Nerds

Top comments (0)