This file contains hidden or 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 calculateSomeFormula(param1, param2) { | |
if (param1) { | |
if (!isNaN(param1)) { | |
if (param2) { | |
if (!isNaN(param2)) { | |
return (param1 * 2) * (param2 * 3); | |
} else { | |
throw new Error('Param2 is not a number'); | |
} | |
} else { |
This file contains hidden or 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 calculateSomeFormula(param1, param2) { | |
if (!param1) { | |
throw new Error('Param1 is not defined'); | |
} | |
if (isNaN(param1)) { | |
throw new Error('Param1 is not a number'); | |
} | |
if (!param2) { |
This file contains hidden or 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 calculateSomeFormula(param1, param2) { | |
validateParams(param1, param2); | |
return (param1 * 2) * (param2 * 3); | |
} | |
// although return value is not used in our example but this method can also return value which can be used by the caller | |
function validateParams(param1, param2) { | |
if (!param1) { |
OlderNewer