A little memory

A static i32.

A static i32.

Goal

Log a stored units value.

@external("env", "log")
declare function log(n: i32): void;

@external("env", "logStr")
declare function logStr(s: string): void;

let stored: i32 = 12;
export function main(): void {
  log(stored);
  stored = 8;
  log(stored);
}
@external("env", "log")
declare function log(n: i32): void;

@external("env", "logStr")
declare function logStr(s: string): void;

const PRICE: i32 = 40;
export function main(): void {
  log(PRICE);
}
@external("env", "log")
declare function log(n: i32): void;

@external("env", "logStr")
declare function logStr(s: string): void;

let total: i32 = 0;
export function main(): void {
  total += 12;
  total += 8;
  log(total);
}
@external("env", "log")
declare function log(n: i32): void;

@external("env", "logStr")
declare function logStr(s: string): void;

let n: i32 = 3;
export function main(): void {
  n = n + 1;
  log(n);
}