Jest versus Enzyme
I got to meet up with my former Launch Academy crew last night, and they told me that they've been using Enzyme to test their React Apps. I guess that means I have a new goal on my plate?
Today I've been working on a few CodeFight challenges. I'm always amused when I come back to a problem that really stumped me when I first saw it, and the answer is immediately clear. The last problem I was working on involved being given a string, and having to find the shortest way to add letters only to the end of it to form a palindrome.
Because it was something immediately simple to try, I first set about finding the longest way to make a palindrome, then looked to see if there was a pattern that would lead me to an answer to the actual problem. I realized that I would need to try adding 1 letter from the front to the end, then test it. If that didn't work, I would add 2 letters from the front (in reverse order) to the end, and test that - etc.
With most of the CodeFight challenges that I undertake, I try to break them down into smaller functions/steps that I know I can do without issue. For this one, I knew that meant:
Today I've been working on a few CodeFight challenges. I'm always amused when I come back to a problem that really stumped me when I first saw it, and the answer is immediately clear. The last problem I was working on involved being given a string, and having to find the shortest way to add letters only to the end of it to form a palindrome.
Because it was something immediately simple to try, I first set about finding the longest way to make a palindrome, then looked to see if there was a pattern that would lead me to an answer to the actual problem. I realized that I would need to try adding 1 letter from the front to the end, then test it. If that didn't work, I would add 2 letters from the front (in reverse order) to the end, and test that - etc.
With most of the CodeFight challenges that I undertake, I try to break them down into smaller functions/steps that I know I can do without issue. For this one, I knew that meant:
- Testing whether I had created a palindrome - isPalindrome()
- Reversing a string - reverseString()
- The actual function I had been tasked to create
Comments
Post a Comment
Thank you for reading my blog! I look forward to hearing from you.