Skip to content

DoCurious API Reference / types / calculateXpProgress

Function: calculateXpProgress()

calculateXpProgress(xp): object

Defined in: types/gamification.types.ts:435

Calculates the percentage progress within the current level and XP remaining to the next level.

Parameters

xp

number

The user's total cumulative XP

Returns

object

progress (0-100 percentage) and toNext (XP remaining; 0 at max level)

progress

progress: number

toNext

toNext: number

Example

ts
const { progress, toNext } = calculateXpProgress(500)
// progress: 30 (30% through Level 3: Explorer)
// toNext: 350 (need 350 more XP for Level 4)

DoCurious Platform Documentation