title | description | category | authors | platforms | level | aliases | |||||
---|---|---|---|---|---|---|---|---|---|---|---|
Code Completion |
Simple code completion with GitHub Copilot |
general |
|
|
lv3 |
|
One of the simplest uses of GitHub Copilot is code completion. Code completion enhances developer productivity by offering potential code snippets as the developer is typing. For example, imagine defining a function in JavaScript. As you input the code below, GitHub Copilot will suggest potential code that could be used inside the function, such as the following code.
function calculateSum(a, b) {
// Enter your code here
}
function calculateSum(a, b) {
// Enter your code here
const sum = a + b;
return sum;
}
- Exercise 1: Complete the
calculateSum(a, b)
function by utilizing GitHub Copilot's suggestions. Explore how different prompts or partial code inputs influence the suggestions made by Copilot.
- Did your code output resemble the sample code provided?
- Is the outputted code robust? Is error handling considered? If not, how could you improve the code?
- What prompts or context can you add to write more precise code?