Refactor Workshop

Learning Goals

  • Identify areas of code that need to be refactored
  • Utilize arguments and parameters to DRY up code


  • DRY Don’t Repeat Yourself!
  • refactor Rewriting working code for readability, maintainability, or performance without changing it’s behavior

Warm Up

Talk with your partner: If someone says “this needs to be refactored”, what might they see that makes them say that?

Then, scroll through this main.js for a Number Guesser project (do NOT clone it down right now), and take note of 2-3 opportunities for refactoring.

Modeling a Refactor

As you watch a real person refactor in real time, take note of the questions they ask themselves and the things they consider.

Your Turn

Clone down this repo. Make sure you are familiar with the current functionality (i.e., run the app in the browser!)

  • There are many refactoring opportunities here. With your partner, decide on one area to focus your energy.
  • Decide if you want to pair or work solo, but either way, work on the same goal.
  • While you are refactoring, make sure you are utilizing console.log and checking what is happening in the browser.
  • Once you feel like you are done, ensure that the app is behaving as it originally was in the browser. Make sure to clean up any old comments, old code, whitespace, etc.

Lesson Search Results

Showing top 10 results