Skip to content

Instantly share code, notes, and snippets.

@anandaanv
Last active February 5, 2021 11:26
Show Gist options
  • Save anandaanv/e42627488c8c5e2620b7cd43cfd909a2 to your computer and use it in GitHub Desktop.
Save anandaanv/e42627488c8c5e2620b7cd43cfd909a2 to your computer and use it in GitHub Desktop.
whats my level?
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