Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GitHub Copilot Suggestion Examples
/* Input */
const recipes = [
{
name: 'Fried Chicken',
categories: ['chicken', 'meat']
},
{
name: 'Spinach Pasta',
categories: ['pasta', 'vegan']
},
{
name: 'Thai Curry with Chicken',
categories: ['chicken', 'thai', 'meat']
}
];
// returns an array of recipes with chicken
/* Input with Suggestion */
const recipes = [
{
name: 'Fried Chicken',
categories: ['chicken', 'meat']
},
{
name: 'Spinach Pasta',
categories: ['pasta', 'vegan']
},
{
name: 'Thai Curry with Chicken',
categories: ['chicken', 'thai', 'meat']
}
];
// returns an array of recipes with chicken
const chickenRecipes = recipes.filter(recipe => recipe.categories.includes('chicken'));
/* Input */
// returns a sorted array of objects based on date
/* Input with Suggestion */
// returns a sorted array of objects based on date
function sortByDate(array) {
/* Input */
function sortArrayByKey
/* Input with Suggestion */
function sortArrayByKey(array, key) {
return array.sort(function(a, b) {
var x = a[key]; var y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
/* Input */
import { getApolloClient } from 'lib/apollo-client';
import { QUERY_ALL_PAGES } from 'data/pages';
function getAllPAges() {
/* Input with Suggestion */
import { getApolloClient } from 'lib/apollo-client';
import { QUERY_ALL_PAGES } from 'data/pages';
function getAllPAges() {
return getApolloClient().query({
query: QUERY_ALL_PAGES
});
}
/* Input */
function sortArrayByKey
/* Synthesized Results */
Sythesizing 10/10 solutions (Duplicates hidden)
=======
function sortArrayByKey(array, key) {
return array.sort(function(a, b) {
var x = a[key]; var y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
=======
...9 more sortArrayByKey results
/* Input */
import { removeExtraSpaces } from './src/lib/until';
// test that extra spaces are removed
/* Synthesized Results */
Sythesizing 10/10 solutions (Duplicates hidden)
=======
expect(removeExtraSpaces(' ')).toBe(' ');
expect(removeExtraSpaces(' a')).toBe(' a');
expect(removeExtraSpaces('a ')).toBe('a ');
expect(removeExtraSpaces('a b')).toBe('a b');
=======
...9 more results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment