Created
July 28, 2014 20:52
-
-
Save pedromcunha/e773e63b205f0edf567d to your computer and use it in GitHub Desktop.
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 changePowerTotal(currentPower, GenID, GenStat, GenPower) { | |
if(GenStat == 'on') { | |
currentPower += GenPower; | |
return alert("Generator #"+GenID+" is now on adding "+GenPower+" MW, for a total of "+currentPower+" MW!"); | |
} | |
else if(GenStat == 'off') { | |
if (currentPower <= 0) { | |
currentPower = 0; | |
} | |
else { | |
currentPower -= GenPower; | |
} | |
return alert("Generator #"+GenID+" is now off, removing "+GenPower+" MW, for a total of "+currentPower+" MW!"); | |
} | |
return currentPower; | |
} | |
changePowerTotal(0, 2, "off", 62); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code Academy Power Generator problem.