Edabit Experience Points

Published by Deep Xavier in

As you complete challenges on Edabit, you gain experience points depending on the level of difficulty of the challenge. The points for each level of difficulty are as follows:

DifficultyExperience Points
Very Easy5XP
Easy10XP
Medium20XP
Hard40XP
Very Hard80XP

Given an array of how many challenges a person has completed per level of difficulty, return how many experience points they'll have.

Examples

getXP([89, 77, 30, 4, 1]) ➞ "2055XP"
// Very Easy: 89 * 5 = 445
// Easy: 77 * 10 = 770
// Medium: 30 * 20 = 600
// Hard: 4 * 40 = 160
// Very Hard: 1 * 80 = 80
// 445 + 770 + 600 + 160 + 80 = 2055

getXP([254, 32, 65, 51, 34]) ➞ "7650XP"

getXP([11, 0, 2, 0, 27]) ➞ "2255XP"

Notes

Return the values as a string and make sure to add "XP" at the end.

Watch a quick demo on how Edabit works.