Pure function
The return value of the pure functions solely depends on its arguments Hence, if you call the pure functions with the same set of arguments, you will always get the same return values. They do not modify the arguments which are passed to them
function square(x){
return x*x
}
Impure function
The return value of the impure functions does not solely depend on its arguments Hence, if you call the impure functions with the same set of arguments, you might get the different return values For example, Math.random(), Date.now(). They may modify the arguments which are passed to them
function getRandom(number)
{
a = Math.random()
if(a > 10){
return a
}
else{
return 10
}
}