Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Functions
var maxHealth = 100 var currentHealth = 50; //var healAmount = 10; function heal(healAmount = 10) { var newHealth = currentHealth + healAmount; currentHealth += healAmount; currenHealth newHealth > 100 ? maxHealth : newHealth; return (currenHealth / maxHealth) * 100; } var result = heal(); // currentHealth - 60 heal(50); // currentHealth = 110 but maxHealth = 100, therefore currentHealth = 100
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
новинка
BaseConverter
Too much Recursion
rstring
Returns an approximation of Pi.
100034322376708
Fixed
2k Dreamin
BF.JS
BinaryGap, javascript - Find longest sequence of zeros in binary representation of an integer.
Please log in to post a comment.