Created
May 17, 2017 19:00
-
-
Save ParthBarot-BoTreeConsulting/04f4813c70245c3ed03558026eae4a08 to your computer and use it in GitHub Desktop.
JS refactoring - Fist version
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
var MyApp = {}; | |
MyApp.Base = { | |
getFixedVal: function(){ | |
//Javascript code before refactoring | |
var myDataVal = someCalculationHere(); | |
var amount = someInputFieldValue; | |
var fixedVal = 0; | |
if(myDataVal > 12){ | |
if(0 < amount && amount <= 12000){ | |
if(calculatedVal <= 95){ | |
fixedVal = 0.8; | |
}else{ | |
fixedVal = 0.7; | |
} | |
}else{ | |
if(calculatedVal <= 95){ | |
fixedVal = 1.0; | |
}else{ | |
fixedVal = 1.1; | |
} | |
} | |
} else if(0 < myDataVal && myDataVal < 12) { | |
if(0 < amount && amount <= 12000){ | |
if(calculatedVal <= 90){ | |
fixedVal = 0.4; | |
}else{ | |
fixedVal = 0.7; | |
} | |
}else{ | |
if(calculatedVal <= 78){ | |
fixedVal = 0.4; | |
}else if(calculatedVal >= 78.01 && calculatedVal <= 90){ | |
fixedVal = 0.7; | |
}else if(calculatedVal > 90){ | |
fixedVal = 0.9; | |
} | |
} | |
} | |
return fixedVal; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment