I can complete the javascript challenges on codewars but nothing like what others are doing. What am i doing wrong?
I've finished the foundations course on the odin project and i do struggle some but can and even have fun doing the challenges on codewars but i'm getting pretty down when looking at other peoples answers. My codes are 10 plus lines long and then I see people do the same thing in 1 line of code that i don't understand at all.
I'm guess i'm asking should i be happy where i'm at and how in the world do i learn that 1 line stuff that doesn't even look like javascript to me?
for example my isogram challenge:
function isIsogram(str){
string = str;
toArray = string.toUpperCase().split("")
for ( let i = 0;i < string.length -1; i ++) {
letter = toArray[0];toArray.shift();
if (toArray.indexOf(letter) > -1){
return false
}
}
return true
}
Theirs:
function isIsogram(str){
return !/(\w).*\1/i.test(str)
}
Posted Aug 15, 2023, 1:19 PM UTC