The add() method of p5.NumberDict in p5.js adds the given value to the value at the given key and stores the updated value at the same key. A key-value pair is a set of two values that are mapped to each other. These values can be accessed by querying this dictionary using the key portion of the pair. A number dictionary can store multiple key-value pairs that can be accessed using the methods of the dictionary.
add( Key, Number )
Parameters: This function has two parameters as shown above and discussed below:
- Key: This is a number that denotes the key from where the value would be added.
- Number: This is a number that denotes the value that is to be added.
The example below illustrates the add() method in p5.js:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/