Last active
December 22, 2015 20:38
-
-
Save Sljubura/6527495 to your computer and use it in GitHub Desktop.
Jednostavan prikaz closure-a.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pdv(OPERACIJA) { | |
return function (broj) { | |
if ( OPERACIJA === '-' ) { | |
return broj - 20; | |
} else if( OPERACIJA === '+' ) { | |
return broj + 20; | |
} else { | |
throw 'Lose uneti parametri!'; | |
} | |
} | |
} | |
var oduzmi = pdv('-'); | |
var hiljadu = oduzmi(1000); | |
console.log(hiljadu); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment