Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Closing.
'looks like you've solved it'
This comment is hidden because it contains spoiler information about the solution
Not an issue
You should
return
instead ofconsole.log
. Always assume you should return the answer because AFAIK, CodeWars doesn't read from console ever.You should always assume you should be returning the value because CodeWars doesn't read from the console ever, AFAIK.
Your value needs to be returned, not logged out. Though upon my review, I did not see that having to return the value was included in the description. So, +1 for adding that to the description.
Just note that with the answer by @the-code-less-traveled it matches both letters and numbers (not just letters as s/he specified on the last line).
This is mostly right but I would like to offer a couple of small corrections:
* Means to match the preceding expression zero OR MORE times. In this case where it follows '.' it allows for any number of random characters.
\1 Refers back to your match for the last expression in parentheses. In this case this means the character that matched '(\w)'.
In total '(\w).*\1' equates to: An alphanumeric character, '\w', followed by any number of random characters, '.*', followed by the same alphanumeric character again, '\1'
Hi PantlessBandit! I'm going to try to explain this since I just got finished looking up how this works.
What chunjef created is known as a regular expression, or regex for short. Regular expressions are a way to describe an analyze string data.
Regular expressions use forward slashes to encapsulate what it is we're looking for in the string.
\w (with a lower case w) means to look for an alphanumeric character
. represents all other characters while * means zero instances
What this means is to leave all the other characters alone like digits.
Finally the 1 means that there should be only 1 instance of each letter.
The i makes the data analysis case insensitive
The ! means NOT
So, to put it all together
Test the string to see if any LETTER (not other characters) does NOT appear more than once.
I hope I explained that right. I just finished learning about it here:
http://eloquentjavascript.net/09_regexp.html#p_uNMQxzr01n
This comment is hidden because it contains spoiler information about the solution
Thank you. Is there really a 7 kyu level question? I must really suck with Objects then. I cannot seem to get this... Time to move on for now.
Gotta admit, I am lost in the sauce here. I saw the hint and looked up defineProperty but I still don't get it. I am horrible with objects like this. Any advice for better understanding definProperty and how it can be used to make dynamic properties?
Got it, thanks again!
Holy crap I didn't even think of apostrophies! Thanks.
Loading more items...