Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Javascript Basics If statements
var maxHealth = 100 var currentHealth = 50; var healAmount = 10; function heal() { var newHealth = currentHealth + healAmount; currentHealth += healAmount; currentHealth = newHealth > 100 ? maxHealth : newHealth; return (currentHealth / maxHealth) * 100; } var result = heal(); // currentHealth - 60 heal(50); // currentHealth = 110 but maxHealth = 100, therefore currentHealth = 100 var keyPressed ="l"; var xPos = 0; let endPos = 5; //if (keyPressed == "r" && xPos < endPos) { xPos +=1;} <-- If statement when both need to be true if (keyPressed == "r") { xPos += 1; } else if (keyPressed == "l") { xPos -= 1; } else { xPos =0; } print(result);
run
|
edit
|
history
|
help
0
Precio Helado
Copy of "Javascript is Weird"
Time it has been since Tuesday, January 1st, 2019
говнокод
single_digit
🦆 you JS
Objects
ROSHAMBO BITCHES!
Fixed
not worked!!