gregoriorojas commited on
Commit
0ea011a
1 Parent(s): dd5ba90

filter and map js function - added first training set for

Browse files
javascript_training_data_expanded.json ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "instruction": "Use map function to double each element in an array.",
4
+ "input": "[1, 2, 3, 4]",
5
+ "output": "function double(x) {\n return x * 2;\n}\n\nlet result = array.map(double);"
6
+ },
7
+ {
8
+ "instruction": "Use filter function to get only even numbers from an array.",
9
+ "input": "[1, 2, 3, 4, 5, 6]",
10
+ "output": "function isEven(x) {\n return x % 2 === 0;\n}\n\nlet result = array.filter(isEven);"
11
+ },
12
+ {
13
+ "instruction": "Use map function to square each element in an array.",
14
+ "input": "[1, 2, 3, 4]",
15
+ "output": "function square(x) {\n return x * x;\n}\n\nlet result = array.map(square);"
16
+ },
17
+ {
18
+ "instruction": "Use filter function to get only numbers greater than 3 from an array.",
19
+ "input": "[1, 2, 3, 4, 5]",
20
+ "output": "function greaterThanThree(x) {\n return x > 3;\n}\n\nlet result = array.filter(greaterThanThree);"
21
+ },
22
+ {
23
+ "instruction": "Use map function to convert each element in an array to a string.",
24
+ "input": "[1, 2, 3, 4]",
25
+ "output": "function toString(x) {\n return x.toString();\n}\n\nlet result = array.map(toString);"
26
+ },
27
+ {
28
+ "instruction": "Use filter function to get only numbers less than 5 from an array.",
29
+ "input": "[3, 5, 8, 1, 4]",
30
+ "output": "function lessThanFive(x) {\n return x < 5;\n}\n\nlet result = array.filter(lessThanFive);"
31
+ },
32
+ {
33
+ "instruction": "Use map function to add 10 to each element in an array.",
34
+ "input": "[5, 10, 15]",
35
+ "output": "function addTen(x) {\n return x + 10;\n}\n\nlet result = array.map(addTen);"
36
+ },
37
+ {
38
+ "instruction": "Use filter function to get only odd numbers from an array.",
39
+ "input": "[2, 3, 4, 5, 6]",
40
+ "output": "function isOdd(x) {\n return x % 2 !== 0;\n}\n\nlet result = array.filter(isOdd);"
41
+ },
42
+ {
43
+ "instruction": "Use map function to negate each element in an array.",
44
+ "input": "[-1, 2, -3, 4]",
45
+ "output": "function negate(x) {\n return -x;\n}\n\nlet result = array.map(negate);"
46
+ },
47
+ {
48
+ "instruction": "Use filter function to get only positive numbers from an array.",
49
+ "input": "[-3, -2, 0, 2, 4]",
50
+ "output": "function isPositive(x) {\n return x > 0;\n}\n\nlet result = array.filter(isPositive);"
51
+ },
52
+ {
53
+ "instruction": "Use map function to get the length of each string in an array.",
54
+ "input": "[\"apple\", \"banana\", \"cherry\"]",
55
+ "output": "function getLength(x) {\n return x.length;\n}\n\nlet result = array.map(getLength);"
56
+ },
57
+ {
58
+ "instruction": "Use filter function to get only strings longer than 4 characters from an array.",
59
+ "input": "[\"apple\", \"cat\", \"banana\"]",
60
+ "output": "function longerThanFour(x) {\n return x.length > 4;\n}\n\nlet result = array.filter(longerThanFour);"
61
+ },
62
+ {
63
+ "instruction": "Use map function to convert each string in an array to uppercase.",
64
+ "input": "[\"apple\", \"banana\", \"cherry\"]",
65
+ "output": "function toUpperCase(x) {\n return x.toUpperCase();\n}\n\nlet result = array.map(toUpperCase);"
66
+ },
67
+ {
68
+ "instruction": "Use filter function to get only strings containing the letter 'a' from an array.",
69
+ "input": "[\"apple\", \"dog\", \"banana\", \"cherry\"]",
70
+ "output": "function containsA(x) {\n return x.includes('a');\n}\n\nlet result = array.filter(containsA);"
71
+ },
72
+ {
73
+ "instruction": "Use map function to multiply each element in an array by 3.",
74
+ "input": "[1, 2, 3, 4]",
75
+ "output": "function multiplyByThree(x) {\n return x * 3;\n}\n\nlet result = array.map(multiplyByThree);"
76
+ },
77
+ {
78
+ "instruction": "Use filter function to get only numbers divisible by 2 from an array.",
79
+ "input": "[1, 2, 3, 4, 5, 6]",
80
+ "output": "function isDivisibleByTwo(x) {\n return x % 2 === 0;\n}\n\nlet result = array.filter(isDivisibleByTwo);"
81
+ },
82
+ {
83
+ "instruction": "Use map function to subtract 1 from each element in an array.",
84
+ "input": "[1, 2, 3, 4]",
85
+ "output": "function subtractOne(x) {\n return x - 1;\n}\n\nlet result = array.map(subtractOne);"
86
+ },
87
+ {
88
+ "instruction": "Use filter function to get only non-negative numbers from an array.",
89
+ "input": "[-1, 0, 1, 2, -2]",
90
+ "output": "function isNonNegative(x) {\n return x >= 0;\n}\n\nlet result = array.filter(isNonNegative);"
91
+ },
92
+ {
93
+ "instruction": "Use map function to append '!' to each string in an array.",
94
+ "input": "[\"hello\", \"world\"]",
95
+ "output": "function appendExclamation(x) {\n return x + '!';\n}\n\nlet result = array.map(appendExclamation);"
96
+ },
97
+ {
98
+ "instruction": "Use filter function to get only strings that start with the letter 'b' from an array.",
99
+ "input": "[\"apple\", \"banana\", \"cherry\", \"blueberry\"]",
100
+ "output": "function startsWithB(x) {\n return x.startsWith('b');\n}\n\nlet result = array.filter(startsWithB);"
101
+ },
102
+ {
103
+ "instruction": "Use map function to get the names of all persons in an array of person objects.",
104
+ "input": "[{\"name\": \"Alice\", \"age\": 30}, {\"name\": \"Bob\", \"age\": 25}]",
105
+ "output": "function getName(person) {\n return person.name;\n}\n\nlet result = array.map(getName);"
106
+ },
107
+ {
108
+ "instruction": "Use filter function to get all persons older than 25 in an array of person objects.",
109
+ "input": "[{\"name\": \"Alice\", \"age\": 30}, {\"name\": \"Bob\", \"age\": 25}]",
110
+ "output": "function isOlderThan25(person) {\n return person.age > 25;\n}\n\nlet result = array.filter(isOlderThan25);"
111
+ },
112
+ {
113
+ "instruction": "Use map function to get the names of all cars in an array of car objects.",
114
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
115
+ "output": "function getCarName(car) {\n return car.make + ' ' + car.model;\n}\n\nlet result = array.map(getCarName);"
116
+ },
117
+ {
118
+ "instruction": "Use filter function to get all cars of a specific make in an array of car objects.",
119
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
120
+ "output": "function isToyota(car) {\n return car.make === 'Toyota';\n}\n\nlet result = array.filter(isToyota);"
121
+ },
122
+ {
123
+ "instruction": "Use map function to get the names of all cities in an array of city objects.",
124
+ "input": "[{\"name\": \"New York\", \"population\": 8000000}, {\"name\": \"Los Angeles\", \"population\": 4000000}]",
125
+ "output": "function getCityName(city) {\n return city.name;\n}\n\nlet result = array.map(getCityName);"
126
+ },
127
+ {
128
+ "instruction": "Use filter function to get all cities with a population greater than 5 million in an array of city objects.",
129
+ "input": "[{\"name\": \"New York\", \"population\": 8000000}, {\"name\": \"Los Angeles\", \"population\": 4000000}]",
130
+ "output": "function isLargeCity(city) {\n return city.population > 5000000;\n}\n\nlet result = array.filter(isLargeCity);"
131
+ },
132
+ {
133
+ "instruction": "Use map function to get the ages of all persons in an array of person objects.",
134
+ "input": "[{\"name\": \"Alice\", \"age\": 30}, {\"name\": \"Bob\", \"age\": 25}]",
135
+ "output": "function getAge(person) {\n return person.age;\n}\n\nlet result = array.map(getAge);"
136
+ },
137
+ {
138
+ "instruction": "Use filter function to get all persons younger than 30 in an array of person objects.",
139
+ "input": "[{\"name\": \"Alice\", \"age\": 30}, {\"name\": \"Bob\", \"age\": 25}]",
140
+ "output": "function isYoungerThan30(person) {\n return person.age < 30;\n}\n\nlet result = array.filter(isYoungerThan30);"
141
+ },
142
+ {
143
+ "instruction": "Use map function to get the full names of all persons in an array of person objects with first and last names.",
144
+ "input": "[{\"firstName\": \"Alice\", \"lastName\": \"Smith\"}, {\"firstName\": \"Bob\", \"lastName\": \"Johnson\"}]",
145
+ "output": "function getFullName(person) {\n return person.firstName + ' ' + person.lastName;\n}\n\nlet result = array.map(getFullName);"
146
+ },
147
+ {
148
+ "instruction": "Use filter function to get all cars of a specific model in an array of car objects.",
149
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
150
+ "output": "function isCorolla(car) {\n return car.model === 'Corolla';\n}\n\nlet result = array.filter(isCorolla);"
151
+ },
152
+ {
153
+ "instruction": "Use map function to get the populations of all cities in an array of city objects.",
154
+ "input": "[{\"name\": \"New York\", \"population\": 8000000}, {\"name\": \"Los Angeles\", \"population\": 4000000}]",
155
+ "output": "function getPopulation(city) {\n return city.population;\n}\n\nlet result = array.map(getPopulation);"
156
+ },
157
+ {
158
+ "instruction": "Use filter function to get all cities with a name starting with 'N' in an array of city objects.",
159
+ "input": "[{\"name\": \"New York\", \"population\": 8000000}, {\"name\": \"Los Angeles\", \"population\": 4000000}]",
160
+ "output": "function nameStartsWithN(city) {\n return city.name.startsWith('N');\n}\n\nlet result = array.filter(nameStartsWithN);"
161
+ },
162
+ {
163
+ "instruction": "Use map function to get the initials of all persons in an array of person objects with first and last names.",
164
+ "input": "[{\"firstName\": \"Alice\", \"lastName\": \"Smith\"}, {\"firstName\": \"Bob\", \"lastName\": \"Johnson\"}]",
165
+ "output": "function getInitials(person) {\n return person.firstName.charAt(0) + person.lastName.charAt(0);\n}\n\nlet result = array.map(getInitials);"
166
+ },
167
+ {
168
+ "instruction": "Use filter function to get all persons with last names starting with 'S' in an array of person objects.",
169
+ "input": "[{\"firstName\": \"Alice\", \"lastName\": \"Smith\"}, {\"firstName\": \"Bob\", \"lastName\": \"Johnson\"}]",
170
+ "output": "function lastNameStartsWithS(person) {\n return person.lastName.startsWith('S');\n}\n\nlet result = array.filter(lastNameStartsWithS);"
171
+ },
172
+ {
173
+ "instruction": "Use map function to get the lengths of car models in an array of car objects.",
174
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
175
+ "output": "function getModelLength(car) {\n return car.model.length;\n}\n\nlet result = array.map(getModelLength);"
176
+ },
177
+ {
178
+ "instruction": "Use filter function to get all cars with a model length greater than 5 in an array of car objects.",
179
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
180
+ "output": "function modelLengthGreaterThan5(car) {\n return car.model.length > 5;\n}\n\nlet result = array.filter(modelLengthGreaterThan5);"
181
+ },
182
+ {
183
+ "instruction": "Use map function to get the uppercased names of all cities in an array of city objects.",
184
+ "input": "[{\"name\": \"New York\", \"population\": 8000000}, {\"name\": \"Los Angeles\", \"population\": 4000000}]",
185
+ "output": "function getUppercasedName(city) {\n return city.name.toUpperCase();\n}\n\nlet result = array.map(getUppercasedName);"
186
+ },
187
+ {
188
+ "instruction": "Use filter function to get all cities with a name containing 'o' in an array of city objects.",
189
+ "input": "[{\"name\": \"New York\", \"population\": 8000000}, {\"name\": \"Los Angeles\", \"population\": 4000000}]",
190
+ "output": "function nameContainsO(city) {\n return city.name.includes('o');\n}\n\nlet result = array.filter(nameContainsO);"
191
+ },
192
+ {
193
+ "instruction": "Use map function to get the lowercase names of all cars in an array of car objects.",
194
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
195
+ "output": "function getLowercasedName(car) {\n return car.make.toLowerCase() + ' ' + car.model.toLowerCase();\n}\n\nlet result = array.map(getLowercasedName);"
196
+ },
197
+ {
198
+ "instruction": "Use filter function to get all cars with a make containing 'o' in an array of car objects.",
199
+ "input": "[{\"make\": \"Toyota\", \"model\": \"Corolla\"}, {\"make\": \"Honda\", \"model\": \"Civic\"}]",
200
+ "output": "function makeContainsO(car) {\n return car.make.includes('o');\n}\n\nlet result = array.filter(makeContainsO);"
201
+ }
202
+ ]