The div() method of p5.NumberDict in p5.js divides the value at the given key with the given value and stores the updated result 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.
div( Key, Amount )
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 divided.
- Amount: This denotes the number to divide the value by,
The example below illustrates the div() method in p5.js:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/