Hacktoberfest 2k18-katas Pull Request

For this post, I will be creating a pull request for the October event, Hacktoberfest 2018. Since this is my first request, I plan to keep it simple and do one of the Hacktoberfest coding challenges just to start me off. I’ve decided to work on the getWordCount function, since it would be a good first pull request. Now, to implement it, first I created a folder and cloned the directory that I planned to work on into the folder. After reading through the README for project, I downloaded the necessary files to run the program, the both node.js and the yarn package and replied to the issues that I planned on taking on the challenge to create a function for getWordCount. Now, after running lint on the function and test file, I needed to implement the function.

What I need to do for this is to get the number of words within the string while ignoring any special characters of numbers. My first plan was to add to the function the split command, and use that to create an array by splitting on any character that is not a letter, and then getting the length of the array. This was my first code.

export const getWordCount = (str) => {
  var words = str.split(new RegExp('/[^A-Za-z]/', 'g'));
  return words.length;
};

After running this, I ran into a problem. Whenever I run into two special characters beside each other, then the split function creates an extra array, and no longer gets the correct length. For example, when there is a period and a space next to each other. Unfortunately, I couldn’t figure out how to implement how to split up the string with multiple special characters, so I decided to go with my previous code, which passed all of the tests./p>

Now, I used the yarn generate removeMultipleSpecialCharacters command to create the new kata for someone else to work on. I decided on this function because I did not have enough time to figure out how to get it to work, so I decided to turn my issue into a challenge for someone else. I created the issue for the challenge, issue #478, and after testing my new code, I pushed it into the original code, through pull request #477

While my first pull request was not a complex one, it was more of an introduction for me to learn how Hacktoberfest works rather then a test of my abilities. I will try and see if my next pull request will be more of a challenge.

Leave a comment