Last active
February 5, 2021 11:26
-
-
Save anandaanv/e42627488c8c5e2620b7cd43cfd909a2 to your computer and use it in GitHub Desktop.
whats my level?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whatsMyLevel(scale) { | |
let map = new Map(); | |
map.set('beginner', '0-20'); | |
map.set('familier', '21-50'); | |
map.set('expert', '51-90'); | |
map.set('guru', '91-99'); | |
let level = "god"; | |
map.forEach( (value, key, map) => { | |
let range = value.split("-"); | |
if(scale >= parseInt(range[0], 10) && scale <= parseInt(range[1], 10)) { | |
level = key; | |
} | |
}); | |
return 'You are ' + level; | |
} | |
// 1. Code RUN automatically: type your name | |
console.log(whatsMyLevel(10)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment