Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
Futbal
BaseConverter
Jason's Code Challenge
random3
Yes
Javascript Basics
Alternating Sign Fibonacci
H
merge json array objects based on ID
Triangle