Format example scripts better.

This commit is contained in:
Stephen Chung
2022-01-20 12:06:36 +08:00
parent 6b06019265
commit b63b4cb3af
22 changed files with 72 additions and 30 deletions

View File

@@ -1,14 +1,14 @@
// This script defines a function with two parameters
// This script defines a function with two parameters and local variables.
let a = 3;
fn addme(a, b) {
fn add(a, b) {
a = 42; // notice that 'a' is passed by value
a + b; // notice that the last value is returned even if terminated by a semicolon
}
let result = addme(a, 4);
let result = add(a, 4);
print(`addme(a, 4) should be 46: ${result}`);
print(`add(a, 4) should be 46: ${result}`);
print(`a should still be 3: ${a}`); // should print 3 - 'a' is never changed
print(`a should still be 3: ${a}`); // prints 3: 'a' is never changed