Skip to content

Latest commit

 

History

History
56 lines (29 loc) · 2.74 KB

3. challenge exercises.md

File metadata and controls

56 lines (29 loc) · 2.74 KB

Challenge Exercises

Now you've had an opportunity to get started using GitHub Copilot, we have a number of challenges for you to attempt. Remember the goal here is not to test your programming abilities but rather, see how you can use GitHub Copilot to help you complete these tasks. Even if you're not a developer, you may be surprised how Copilot can help you be successful with these challenge.

Challenge #1 - Adding Unit Tests

Adding Unit Tests

  1. Press CTRL + ` to open the terminal window in VS Code if it is not already open.

  2. Enter npm test in the terminal window and press ENTER to execute the existing unit tests for the Calculator application.

  3. Scroll up in the terminal window to see what tests have been executed. You should see tests for Arithmetic validation, Addition, Multiplication and Division. There are no tests for the subtraction function!

  4. Open the /test/arithmetic.test.js file.

  5. Scroll down to the line with the comment TODO: Challenge #1 (Around line 96)

  6. On the line following the comment, add a new comment to provide context to GitHub Copilot on what you want assistance to do. Try adding this comment // add tests for subtraction and press ENTER to generate a suggestion.

  7. Accept the suggested line if it looks right by pressing TAB then ENTER.

  8. Continue accepting suggestions line by line to see how many unit tests you can have Copiloit assist you in writing.

  9. Once you're happy with a few unit tests, save the file and return to the terminal window. Enter npm test and press ENTER to execute the unit tests again.

NOTE: The advanced features currently available in GitHub CopilotX Chat, provide far more sophisticated assistance in writing unit tests, including the ability to write complete test suites for you. At the time of creating this exercise, Copilot Chat was only available as a pre-release experiment.

Challenge #2 - Adding Unit Tests for the power/exponential function

Adding Unit Tests for the power/exponential function

  1. See if you can now add additional unit tests for the power/exponential function you created in the core exercise.
Challenge #3 - Adding a new function

Adding a new function

  1. See if you can now add an entirely new function to the calculator using GitHub Copilot to assist you. The previous exercises will help you locate where you want to add code.

  2. Once your function is working, consider adding the necessary unit tests to confirm it's functionality.

What's next?

Once you've completed the challenges, you may like to review the additional resources