Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Javascript Basics
const maxHealth = 100; var currentHealth = 50; var numberLives = 5; currentHealth = maxHealth; var characterName = "Wishmaster"; var currentLevel = 1; //var isGameOver = false; //print(isGameOver); // const (value that can't be changed, let (scope base), var //if (true) { //var isGameOver = false; //var and const can be access inside and outside of code blocks //let isGameOver = false; //} let message = "Hi, my name is " + characterName; //"Hi, my name is ${characterName}"; <-- Interpolation let length = characterName.length; let upperName = characterName.toUpperCase(); let lowerName = characterName.toLowerCase(); let wish = characterName.slice(0,4); let level = "Hello, your current on level " + currentLevel; print(message) print(wish) print(level) var inventory =["shirt", "axe", "bread", "shield"]; let shirt = inventory[0]; inventory[2] = "chicken"; inventory.length; // 4 items in array inventory[0].length; // 5 characters in shirt inventory.push("water"); // adds water on end of array inventory.pop(); // remove last item var levels = [ [1.1, 1.2, 1.3], // row 1 [2.1, 2.2, 2.3, 2.4], // row2 [3.1, 3.2, 3.3], // row3 [4.1, 4.2], // row4 ]; var firstWorld = levels[0]; // 1.1, 1.2, 1.3 var firstLevel = levels[0][1]; // level 1.2 // firstLevel [0][1] = 1.4 levels [1].pop(); levels [3].push(4.3);
run
|
edit
|
history
|
help
0
Alternating Sign Fibonacci
CWG - pages
Objects
black peepz ping pong
Variables
JS exam part 2 - Circumference
rstring
Strange Attractors
Merge Two Arrays
Triangle