Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Javascript Basics
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
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 var secondWorld [1].pop; var fourthWorld [3].push 4.3;
[
+
]
Show input
Absolute running time: 0.71 sec, cpu time: 0.72 sec, memory peak: 40 Mb, absolute service time: 0,87 sec
edit mode
|
history
|
discussion
Hi, my name is Wishmaster Wish Hello, your current on level 1