Remove Duplicates from Pokemon Pokedex entries

This commit is contained in:
Dragon Fire
2020-03-08 11:16:26 -04:00
parent e0d131f394
commit 0f3eb4939e
3 changed files with 15 additions and 3 deletions
+10
View File
@@ -40,6 +40,16 @@ module.exports = class Util {
return arr;
}
static removeDuplicates(arr) {
if (arr.length === 0 || arr.length === 1) return arr;
const newArr = [];
for (let i = 0; i < arr.length; i++) {
if (newArr.includes(arr[i])) continue;
newArr.push(arr[i]);
}
return newArr;
}
static firstUpperCase(text, split = ' ') {
return text.split(split).map(word => `${word.charAt(0).toUpperCase()}${word.slice(1)}`).join(' ');
}