convertFrom
On this page
convertFrom()
This function is used to calculate XP from a level, or vise versa.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | number | ✅ | The value to convert. | |
| type | “level” or “xp” | ❌ | level |
Type to convert from. |
Return value
Section titled “Return value”Throws
Section titled “Throws”XpFatal- If the value is not a number, or type is invalid.
Example
Section titled “Example”const {convertFrom} = require('simply-xp');
const value = 10;const type = "level";
const result = convertFrom(value, type)console.log(result) // Returns Result