Classes

NumberDict

Methods

inner add(Key, Number)

Add the given number to the value currently stored at the given key. The sum then replaces the value previously stored in the Dictionary.
Parameters:
Name Type Description
Key Number for the value you wish to add to
Number Number to add to the value
Example
function setup() {
  let myDictionary = createNumberDict(2, 5);
  myDictionary.add(2, 2);
  print(myDictionary.get(2)); // logs 7 to console.
}

inner div(Key, Amount)

Divide the given number with the value currently stored at the given key. The quotient then replaces the value previously stored in the Dictionary.
Parameters:
Name Type Description
Key Number for value you wish to divide
Amount Number to divide the value by
Example
function setup() {
  let myDictionary = createNumberDict(2, 8);
  myDictionary.div(2, 2);
  print(myDictionary.get(2)); // logs 4 to console.
}

inner maxKey() → {Number}

Return the highest key currently used in the Dictionary.
Returns:
Number
Example
function setup() {
  let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });
  let highestKey = myDictionary.maxKey(); // value is 4
  print(highestKey);
}

inner maxValue() → {Number}

Return the highest number currently stored in the Dictionary.
Returns:
Number
Example
function setup() {
  let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });
  let highestValue = myDictionary.maxValue(); // value is 3
  print(highestValue);
}

inner minKey() → {Number}

Return the lowest key currently used in the Dictionary.
Returns:
Number
Example
function setup() {
  let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });
  let lowestKey = myDictionary.minKey(); // value is 1.2
  print(lowestKey);
}

inner minValue() → {Number}

Return the lowest number currently stored in the Dictionary.
Returns:
Number
Example
function setup() {
  let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });
  let lowestValue = myDictionary.minValue(); // value is -10
  print(lowestValue);
}

inner mult(Key, Amount)

Multiply the given number with the value currently stored at the given key. The product then replaces the value previously stored in the Dictionary.
Parameters:
Name Type Description
Key Number for value you wish to multiply
Amount Number to multiply the value by
Example
function setup() {
  let myDictionary = createNumberDict(2, 4);
  myDictionary.mult(2, 2);
  print(myDictionary.get(2)); // logs 8 to console.
}

inner sub(Key, Number)

Subtract the given number from the value currently stored at the given key. The difference then replaces the value previously stored in the Dictionary.
Parameters:
Name Type Description
Key Number for the value you wish to subtract from
Number Number to subtract from the value
Example
function setup() {
  let myDictionary = createNumberDict(2, 5);
  myDictionary.sub(2, 2);
  print(myDictionary.get(2)); // logs 3 to console.
}