Skip to content

Instantly share code, notes, and snippets.

@rdavid1099
Created November 25, 2016 17:49
Show Gist options
  • Save rdavid1099/281cc8a72623541512fc4b7b16b7bc8d to your computer and use it in GitHub Desktop.
Save rdavid1099/281cc8a72623541512fc4b7b16b7bc8d to your computer and use it in GitHub Desktop.
Workman Working Through JS Exercisms

##Bob My code: here

  • Responder #1 (here) - This responder presented a much more refactored and cleaner code base than what I came up with. He uses regular expressions and if statements to pass every conditional, whereas I used only one regular expression and single-responsibility functions to determine Bob's responses.

  • Responder #2 (here) - This user used a bit more of a sloppier and harder to read way of getting to the end results. While the three boolean conditionals within the function render the correct results, it looks like the function is written for specific edge cases tested in the spec, instead of writing clear, well-presented boolean conditionals that also catch the edge cases.

  • Responder #3 (here) - This user's approach is similar to the first user I reviewed; however, instead of using regular expressions, the user placed basic boolean conditionals within the function. This approach is different than mine, in the sense that I broke out my booleans into separate functions for readability... but other than that, we had similar approaches.

  • Responder #4 (here) - This is one of the cooler ways I've seen to complete Bob. Using JS objects, the user sets a local var to a certain reply status, which then in turn calls the response needed. Clean boolean conditionals and overall clean code. Very interesting.

  • Responder #5 (here) - This user has an almost identical approach as the first user. He uses regular expressions to test the query statement and returns the necessary statements.

##Beer-Song My code: here

  • Responder #1 (here) - The biggest difference right off the bat is the length of the script. My program was more than 60 lines, while this user's is just under 30. A lot of the logic is self-contained within a generateSong function, while I broke out nearly everything into small functions. I'm not sure which is better, but I can say that this user's code is a whole lot cleaner.

  • Responder #2 (here) - This user's approach looks at more similar to mine. While there are less lines of code, the user broke out basic logic into smaller functions and let them handle the nuances in lyrics. It's clean and readable.

  • Responder #3 (here) - This user cut down on a lot of lines of code by using ternary statements within the necessary responses. This approach allows you to determine the correct lyrics without testing the number in broken out functions. While it is shorter, this approach affects readability and looks a bit awkward.

  • Responder #4 (here) - This approach is similar to mine. Each of the nuanced lines of lyrics are broken out into functions which handle the specific logic for that line. The code is cleaner than mine, using much less white space than I used. Overall, this is a great example of how to nail this exercise.

  • Responder #5 (here) - This user wrote much more advanced JavaScript than I am used to seeing. He saves all the necessary lines to global variables and then manipulates them as the logic is determined. Very impressive, but it's unreadable for someone at my level.

##Linked-List My code: here

  • Responder #1 (here) - A traditional approach to creating and traversing a linked list. This user wrote some very impressive code using a constant variable to look ahead and behind a node. This approach is extremely impressive.

  • Responder #2 (here) - Very clean code, however, this user used built-in JavaScript functions to achieve the goal. For instance, his .pop() just calls JS's .pop() with one line. While this is clean, I took a different approach challenging myself to build my own Ruby-like enumerables to accomplish the tasks at hand.

  • Responder #3 (here) - This user has some very impressive code. It looks more advanced than my current skill level. Due to my lack of depth in JavaScript at this time, I am unable to really determine what this user is doing, but I know it is very clean and performs faster than my code.

  • Responder #4 (here) - Another traditional take on a linked list in JavaScript. This user built functions referring to other nodes and manipulated it as needed. I am starting to realize that I took a very untraditional approach to solving this problem and built more of a queue and less of a linked list using custom functions to navigate and manipulate an array.

  • Responder #5 (here) - Similar to all the other users. This user used nodes and references to elements around it to create the linked list. Clean and impressive. I feel like I am going to redo this problem and challenge myself to build a legitimate linked list and not just an array-navigator of sorts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment