@palerock/exam-qa 1.0.6-patch15 → 1.0.6-patch16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/static/js/manifest.3ad1d5771e9b13dbdad2.js.map +1 -1
- package/lib-json/[JS]/347/254/254/344/270/200/347/253/240 /345/217/230/351/207/217-/347/261/273/345/236/213-/351/233/206/345/220/210.json" +1048 -0
- package/lib-json/[JS]/347/254/254/344/270/203/347/253/240 /346/265/213/350/257/225.json" +356 -0
- package/lib-json/[JS]/347/254/254/344/270/211/347/253/240 /346/265/217/350/247/210/345/231/250/345/222/214/344/272/213/344/273/266.json" +851 -0
- package/lib-json/[JS]/347/254/254/344/272/214/347/253/240 /345/257/271/350/261/241-/345/207/275/346/225/260-/347/261/273.json" +1759 -0
- package/lib-json/[JS]/347/254/254/344/272/224/347/253/240 /345/274/202/346/255/245/347/274/226/347/250/213.json" +547 -0
- package/lib-json/[JS]/347/254/254/345/205/255/347/253/240 /346/234/215/345/212/241/345/231/250/347/253/257JavaScript.json" +613 -0
- package/lib-json/[JS]/347/254/254/345/233/233/347/253/240 /350/260/203/350/257/225/345/222/214/351/224/231/350/257/257/345/244/204/347/220/206.json" +525 -0
- package/lib-json/map.json +8 -1
- package/package.json +1 -1
@@ -0,0 +1,1759 @@
|
|
1
|
+
{
|
2
|
+
"title": "[JS]第二章 对象-函数-类",
|
3
|
+
"category": "JS-1",
|
4
|
+
"questions": [
|
5
|
+
{
|
6
|
+
"describe": "<p>Which function should a developer use to repeatedly execute code at a fixed time interval?</p>",
|
7
|
+
"answerOptions": [
|
8
|
+
{
|
9
|
+
"describe": "<p>setInterval</p>",
|
10
|
+
"isRight": true
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"describe": "<p>setTimeout</p>",
|
14
|
+
"isRight": false
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"describe": "<p>setPeriod</p>",
|
18
|
+
"isRight": false
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"describe": "<p>setInterim</p>",
|
22
|
+
"isRight": false
|
23
|
+
}
|
24
|
+
],
|
25
|
+
"analysis": "<p>The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).</p><p>setTimeout execute a specified block of code once after a specified time has elapsed.</p>",
|
26
|
+
"hashCode": 1543270785
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"describe": "<p>A developer creates an object where its properties should be immutable and prevent properties from being added or modified.Which method should be used to execute this business requirement?</p>",
|
30
|
+
"answerOptions": [
|
31
|
+
{
|
32
|
+
"describe": "<p>Object.seal( )</p>",
|
33
|
+
"isRight": false
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"describe": "<p>Object.const( )</p>",
|
37
|
+
"isRight": false
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"describe": "<p>Object.freeze( )</p>",
|
41
|
+
"isRight": true
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"describe": "<p>Object.lock( )</p>",
|
45
|
+
"isRight": false
|
46
|
+
}
|
47
|
+
],
|
48
|
+
"analysis": "<p>The Object.seal() method seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable.</p><p>The Object.freeze() method freezes an object. A frozen object can no longer be changed; freezing an object prevents new properties from being added to it, existing properties from being removed, prevents changing the enumerability, configurability, or writability of existing properties, and prevents the values of existing properties from being changed. In addition, freezing an object also prevents its prototype from being changed. freeze() returns the same object that was passed in.</p>",
|
49
|
+
"hashCode": -1236958766
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"describe": "<p>Given the following code:</p><p>let x= ( '15' + 10 ) * 2;</p><p>What is the value of x?</p>",
|
53
|
+
"answerOptions": [
|
54
|
+
{
|
55
|
+
"describe": "<p>50</p>",
|
56
|
+
"isRight": false
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"describe": "<p>3020</p>",
|
60
|
+
"isRight": true
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"describe": "<p>35</p>",
|
64
|
+
"isRight": false
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"describe": "<p>1520</p>",
|
68
|
+
"isRight": false
|
69
|
+
}
|
70
|
+
],
|
71
|
+
"analysis": "",
|
72
|
+
"hashCode": 1566378556
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"describe": "<p>Refer to the code below:</p><p>01 const car = {</p><p>02 price: 100,</p><p>03 getPrice: function ( ) {</p><p>04 return this.price;</p><p>05 }</p><p>06 };</p><p>07 const customCar = Object.create(car);</p><p>08 customCar.price = 70;</p><p>09</p><p>10 delete customCar.price;</p><p>11 const result = customCar.getPrice( );</p><p>Considering the implications of line 10 along with prototype inheritance, what is the value of result after the code executes?</p>",
|
76
|
+
"answerOptions": [
|
77
|
+
{
|
78
|
+
"describe": "<p>100</p>",
|
79
|
+
"isRight": true
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"describe": "<p>undefined</p>",
|
83
|
+
"isRight": false
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"describe": "<p>70</p>",
|
87
|
+
"isRight": false
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"describe": "<p>null</p>",
|
91
|
+
"isRight": false
|
92
|
+
}
|
93
|
+
],
|
94
|
+
"analysis": "<p>create() The Object. create() method creates a new object, using an existing object as the prototype of the newly created object</p><p>In line 10, the price property is deleted. But in the prototype chain, therer is another price property.</p><p>{price: 70}</p><p>price: 70</p><p>__proto__:</p><p>getPrice: ƒ ( )</p><p>price: 100</p><p>__proto__: Object</p>",
|
95
|
+
"hashCode": 796642343
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"describe": "<p>Refer to the code below:</p><p>01 function changeValue(obj) {</p><p>02 obj.value = obj.value / 2;</p><p>03 }</p><p>04 const objA = { value : 10};</p><p>05 const objB = objA;</p><p>06</p><p>07 changeValue(objB);</p><p>08 const result = objA.value;</p><p>What is the value of result after the code executes?</p>",
|
99
|
+
"answerOptions": [
|
100
|
+
{
|
101
|
+
"describe": "<p>NaN</p>",
|
102
|
+
"isRight": false
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"describe": "<p>10</p>",
|
106
|
+
"isRight": false
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"describe": "<p>undefined</p>",
|
110
|
+
"isRight": false
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"describe": "<p>5</p>",
|
114
|
+
"isRight": true
|
115
|
+
}
|
116
|
+
],
|
117
|
+
"analysis": "<p>objA and objB point to the same address in the stack. So they are same object. In line 7, the method changes the object.value, so in line8, the object.value = 5</p>",
|
118
|
+
"hashCode": -1558274561
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"describe": "<p>Which three options show valid methods for creating a fat arrow function? Choose 3 answer</p>",
|
122
|
+
"answerOptions": [
|
123
|
+
{
|
124
|
+
"describe": "<p>[ ] => { console.log( 'executed' ); }</p>",
|
125
|
+
"isRight": false
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"describe": "<p>( ) => { console.log( 'executed' ); }</p>",
|
129
|
+
"isRight": true
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"describe": "<p>( x, y, z ) => { console.log( 'executed' ); }</p>",
|
133
|
+
"isRight": true
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"describe": "<p>x, y, z => { console.log( 'executed' ); }</p>",
|
137
|
+
"isRight": false
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"describe": "<p>x => { console.log( 'executed' ); }</p>",
|
141
|
+
"isRight": true
|
142
|
+
}
|
143
|
+
],
|
144
|
+
"analysis": "<p>If no parameter, the () should not be omitted, if more than one parameter, the () should not be omitted, if only one parameter, the () can be omitted</p>",
|
145
|
+
"hashCode": -710754372
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"describe": "<p>Refer to the following code block:</p><p>01 class Student {</p><p>02 constructor(name) {</p><p>03 this.name = name;</p><p>04 }</p><p>05</p><p>06 takeTest() {</p><p>07 console.log(`${this.name} got 70% on test.`);</p><p>08 }</p><p>09 }</p><p>10</p><p>11 class BetterStudent extends Student {</p><p>12 constructor(name) {</p><p>13 super(name);</p><p>14 this.name = 'Better student ' + name;</p><p>15 }</p><p>16 takeTest() {</p><p>17 console.log(`${this.name} got 100% on the test.`);</p><p>18 }</p><p>19 }</p><p>20</p><p>21 let student = new BetterStudent('Jackie');</p><p>22 student.takeTest();</p><p>What is the console output?</p>",
|
149
|
+
"answerOptions": [
|
150
|
+
{
|
151
|
+
"describe": "<p>> Jackie got 70% on test.</p>",
|
152
|
+
"isRight": false
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"describe": "<p>> Better student Jackie got 100% on test.</p>",
|
156
|
+
"isRight": true
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"describe": "<p>> Better student Jackie got 70% on test.</p>",
|
160
|
+
"isRight": false
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"describe": "<p>> Uncaught ReferenceError</p>",
|
164
|
+
"isRight": false
|
165
|
+
}
|
166
|
+
],
|
167
|
+
"analysis": "<p>line 13 super(name) will call line 3. Then in line 13, this.name will update the name.</p><p>the takeTest() method is line 16 will be called. Only if in current class there is no such a method, js will look at the parent class.</p>",
|
168
|
+
"hashCode": 516074974
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"describe": "<p>A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed. The developer needs to find what is missing in the code below.</p><p>01 const sumFunction = arr =>{</p><p>02 return arr.reduce((result, current) =>{</p><p>03 //</p><p>04 result += current;</p><p>05 //</p><p>06 },10);</p><p>07 };</p><p>Which option makes the code work as expected?</p>",
|
172
|
+
"answerOptions": [
|
173
|
+
{
|
174
|
+
"describe": "<p>Replace line 02 with return arr.map((result, current) =>{</p>",
|
175
|
+
"isRight": false
|
176
|
+
},
|
177
|
+
{
|
178
|
+
"describe": "<p>Replace line 05 with return result;</p>",
|
179
|
+
"isRight": true
|
180
|
+
},
|
181
|
+
{
|
182
|
+
"describe": "<p>Replace line 04 with result = result + current;</p>",
|
183
|
+
"isRight": false
|
184
|
+
},
|
185
|
+
{
|
186
|
+
"describe": "<p>Replace line 03 with if(arr.length == 0) {return 0;}</p>",
|
187
|
+
"isRight": false
|
188
|
+
}
|
189
|
+
],
|
190
|
+
"analysis": "<p>JS Array Reduce method: https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/array/reduce</p><p>map method will return an array by executing the callback method for each of the element in the original array</p><p>result +=current equals to result = result + current</p>",
|
191
|
+
"hashCode": 2083887382
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"describe": "<p>Given the code below:</p><p>01 function myFunction() {</p><p>02 a = 5;</p><p>03 var b = 1;</p><p>04 }</p><p>05</p><p>06 myFunction();</p><p>07</p><p>08 console.log(a);</p><p>09 console.log(b);</p><p>What is the expected output?</p>",
|
195
|
+
"answerOptions": [
|
196
|
+
{
|
197
|
+
"describe": "<p>Line 08 outputs the variable, but line 09 throws an error.</p>",
|
198
|
+
"isRight": false
|
199
|
+
},
|
200
|
+
{
|
201
|
+
"describe": "<p>Both lines 08 and 09 are executed, and the variables are outputted.</p>",
|
202
|
+
"isRight": false
|
203
|
+
},
|
204
|
+
{
|
205
|
+
"describe": "<p>Line 08 throws an error, therefore line 09 is never executed.</p>",
|
206
|
+
"isRight": false
|
207
|
+
},
|
208
|
+
{
|
209
|
+
"describe": "<p>Both lines 08 and 09 are executed, but the values outputted are undefined.</p>",
|
210
|
+
"isRight": true
|
211
|
+
}
|
212
|
+
],
|
213
|
+
"analysis": "",
|
214
|
+
"hashCode": -399108392
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"describe": "<p>Refer to the following code:</p><p>01 function Tiger() {</p><p>02 this.type = 'Cat';</p><p>03 this.size = 'large';</p><p>04 }</p><p>05</p><p>06 let tony = new Tiger();</p><p>07 tony.roar = () => {</p><p>08 console.log('They\\'re great!');</p><p>09 };</p><p>10</p><p>11 function Lion() {</p><p>12 this.type = 'Cat';</p><p>13 this.size = 'large';</p><p>14 }</p><p>15</p><p>16 let leo = new Lion();</p><p>17 // Insert code here</p><p>18 leo.roar();</p><p>Which two statements could be inserted at line 17 to enable the function call on line 18? Choose 2 answers</p><p></p>",
|
218
|
+
"answerOptions": [
|
219
|
+
{
|
220
|
+
"describe": "<p>Object.assign(leo, tony);</p>",
|
221
|
+
"isRight": true
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"describe": "<p>Object.assign(leo, Tiger);</p>",
|
225
|
+
"isRight": false
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"describe": "<p>leo.prototype.roar = () => {console.log('They\\'re pretty good!');};</p>",
|
229
|
+
"isRight": false
|
230
|
+
},
|
231
|
+
{
|
232
|
+
"describe": "<p>leo.roar = () => {console.log('They\\'re pretty good!');};</p>",
|
233
|
+
"isRight": true
|
234
|
+
}
|
235
|
+
],
|
236
|
+
"analysis": "<p>The Object. assign() method only copies enumerable and own properties from a source object to a target object. But Tiger is a function.</p><p>The JavaScript prototype property allows you to add new properties to object constructors. Should be Lion.prototype.roar.</p>",
|
237
|
+
"hashCode": 1036209143
|
238
|
+
},
|
239
|
+
{
|
240
|
+
"describe": "<p>Refer to the code declarations below:</p><p>let str1 = 'Java';</p><p>let str2 = 'Script';</p><p>Which three expressions return the string JavaScript? Choose 3 answers</p>",
|
241
|
+
"answerOptions": [
|
242
|
+
{
|
243
|
+
"describe": "<p>str1.join(str2);</p>",
|
244
|
+
"isRight": false
|
245
|
+
},
|
246
|
+
{
|
247
|
+
"describe": "<p>str1.concat(str2);</p>",
|
248
|
+
"isRight": true
|
249
|
+
},
|
250
|
+
{
|
251
|
+
"describe": "<p>`${str1}${str2}`;</p>",
|
252
|
+
"isRight": true
|
253
|
+
},
|
254
|
+
{
|
255
|
+
"describe": "<p>concat(str1, str2);</p>",
|
256
|
+
"isRight": false
|
257
|
+
},
|
258
|
+
{
|
259
|
+
"describe": "<p>str1 + str2;</p>",
|
260
|
+
"isRight": true
|
261
|
+
}
|
262
|
+
],
|
263
|
+
"analysis": "<p>No join method on String: join</p><p>Should be str1.concat(str2);</p>",
|
264
|
+
"hashCode": -656405866
|
265
|
+
},
|
266
|
+
{
|
267
|
+
"describe": "<p></p>",
|
268
|
+
"answerOptions": [
|
269
|
+
{
|
270
|
+
"describe": "<p>developer has two ways to write a function:</p><p>Option A:</p><p>01 function Monster( ) {</p><p>02 this.growl = ( ) => {</p><p>03 console.log(\"Grr!\");</p><p>04 }</p><p>05 }</p><p>Option B:</p><p>01 function Monster( ) { };</p><p>02 Monster.prototype.growl = ( ) => {</p><p>03 console.log(\"Grr!\");</p><p>04 }</p><p>After deciding on an option, the developer creates 1000 monster objects.</p><p>How many growl methods are created with Option A and Option</p>",
|
271
|
+
"isRight": false
|
272
|
+
},
|
273
|
+
{
|
274
|
+
"describe": "<p>?</p><p>A 1000 growl methods are created regardless of which option is used.</p><p>B 1 growl method is created regardless of which option is used.</p>",
|
275
|
+
"isRight": false
|
276
|
+
},
|
277
|
+
{
|
278
|
+
"describe": "<p>1000 growl methods are created for Option A.1 growl method is created for Option B.</p>",
|
279
|
+
"isRight": true
|
280
|
+
},
|
281
|
+
{
|
282
|
+
"describe": "<p>1 growl method is created for Option A. 1000 growl methods are created for Option B.</p>",
|
283
|
+
"isRight": false
|
284
|
+
}
|
285
|
+
],
|
286
|
+
"analysis": "<p>with prototype, the growl function will be existing in Monster's prototype chain. All instances initialized from Monster will share the same function reference.</p><p>In Option A, however, each instance of Monster will have their own growl function.</p>",
|
287
|
+
"hashCode": 0
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"describe": "<p>Refer to the code below:</p><p>01 let first = 'Who';</p><p>02 let second = 'What';</p><p>03 try {</p><p>04 try {</p><p>05 throw new Error('Sad trombone');</p><p>06 } catch (err) {</p><p>07 first = 'Why' ;</p><p>08 throw err;</p><p>09 } finally {</p><p>10 second = 'When' ;</p><p>11 }</p><p>12 } catch (err) {</p><p>13 second = 'Where' ;</p><p>14 }</p><p>What are the values for first and second once the code executes?</p><p></p>",
|
291
|
+
"answerOptions": [
|
292
|
+
{
|
293
|
+
"describe": "<p>First is Who and second is When.</p>",
|
294
|
+
"isRight": false
|
295
|
+
},
|
296
|
+
{
|
297
|
+
"describe": "<p>First is Why and second is Where.</p>",
|
298
|
+
"isRight": true
|
299
|
+
},
|
300
|
+
{
|
301
|
+
"describe": "<p>first is Who and second is Where.</p>",
|
302
|
+
"isRight": false
|
303
|
+
},
|
304
|
+
{
|
305
|
+
"describe": "<p>first is Why and second is When.</p>",
|
306
|
+
"isRight": false
|
307
|
+
}
|
308
|
+
],
|
309
|
+
"analysis": "",
|
310
|
+
"hashCode": 73813081
|
311
|
+
},
|
312
|
+
{
|
313
|
+
"describe": "<p>A developer wants to create an object from a function in the browser using the code below.</p><p>01 function Monster( ){ this.name = 'hello' };</p><p>02 const m = Monster( );</p><p>What happens due to the lack of the new keyword on line 02?</p><p></p>",
|
314
|
+
"answerOptions": [
|
315
|
+
{
|
316
|
+
"describe": "<p>window.name is assigned to 'hello' and the variable m remains undefined.</p>",
|
317
|
+
"isRight": true
|
318
|
+
},
|
319
|
+
{
|
320
|
+
"describe": "<p>The m variable is assigned the correct object but this.name remains undefined.</p>",
|
321
|
+
"isRight": false
|
322
|
+
},
|
323
|
+
{
|
324
|
+
"describe": "<p>The m variable is assigned the correct object.</p>",
|
325
|
+
"isRight": false
|
326
|
+
},
|
327
|
+
{
|
328
|
+
"describe": "<p>window.m is assigned the correct object.</p>",
|
329
|
+
"isRight": false
|
330
|
+
}
|
331
|
+
],
|
332
|
+
"analysis": "<p>without new, it is like calling Monster() function, and at this time, this points to windows object. So it is like assigning a name attribtue to the window object</p>",
|
333
|
+
"hashCode": 1929130382
|
334
|
+
},
|
335
|
+
{
|
336
|
+
"describe": "<p>Refer to the code below:</p><p>01 let o = {</p><p>02 get js( ) {</p><p>03 let city1 = String('st. Louis');</p><p>04 let city2 = String('New York');</p><p>05</p><p>06 return {</p><p>07 firstCity: city1.toLowerCase( ) ,</p><p>08 secondCity: city2.toLowerCase( ) ,</p><p>09 }</p><p>10 }</p><p>11 }</p><p>What value can a developer expect when referencing o.js.secondCity?</p><p></p>",
|
337
|
+
"answerOptions": [
|
338
|
+
{
|
339
|
+
"describe": "<p>'new york'</p>",
|
340
|
+
"isRight": true
|
341
|
+
},
|
342
|
+
{
|
343
|
+
"describe": "<p>undefined</p>",
|
344
|
+
"isRight": false
|
345
|
+
},
|
346
|
+
{
|
347
|
+
"describe": "<p>'New York'</p>",
|
348
|
+
"isRight": false
|
349
|
+
},
|
350
|
+
{
|
351
|
+
"describe": "<p>An error</p>",
|
352
|
+
"isRight": false
|
353
|
+
}
|
354
|
+
],
|
355
|
+
"analysis": "",
|
356
|
+
"hashCode": 458433156
|
357
|
+
},
|
358
|
+
{
|
359
|
+
"describe": "<p>Refer to the code below:</p><p>01 const objBook = {</p><p>02 title: 'JavaScript' ,</p><p>03 };</p><p>04 Object.preventExtensions (objBook) ;</p><p>05 const newObjBook = objBook;</p><p>06 newObjBook.author = 'Robert' ;</p><p>What are the values of objBook and newObjBook respectively?</p><p></p>",
|
360
|
+
"answerOptions": [
|
361
|
+
{
|
362
|
+
"describe": "<p>{ title: \"JavaScript\" }</p><p>{ title: \"JavaScript\" }</p>",
|
363
|
+
"isRight": true
|
364
|
+
},
|
365
|
+
{
|
366
|
+
"describe": "<p>{ author: \"Robert\", title: \"JavaScript\" }</p><p>{ author: \"Robert\", title: \"JavaScript\" }</p>",
|
367
|
+
"isRight": false
|
368
|
+
},
|
369
|
+
{
|
370
|
+
"describe": "<p>{ author: \"Robert\", title: \"JavaScript\" }</p><p>undefined</p>",
|
371
|
+
"isRight": false
|
372
|
+
},
|
373
|
+
{
|
374
|
+
"describe": "<p>{ author: \"Robert\" }</p><p>{ author: \"Robert\", title: \"JavaScript\" }</p>",
|
375
|
+
"isRight": false
|
376
|
+
}
|
377
|
+
],
|
378
|
+
"analysis": "<p>The Object.preventExtensions() method prevents new properties from ever being added to an object</p>",
|
379
|
+
"hashCode": 1760512837
|
380
|
+
},
|
381
|
+
{
|
382
|
+
"describe": "<p>What are two unique features of functions defined with a fat arrow as compared to normal function definition? Choose 2 answers</p><p></p>",
|
383
|
+
"answerOptions": [
|
384
|
+
{
|
385
|
+
"describe": "<p>The function generates its own this making it useful for separating the function's scope from its enclosing scope.</p>",
|
386
|
+
"isRight": false
|
387
|
+
},
|
388
|
+
{
|
389
|
+
"describe": "<p>The function uses the this from the enclosing scope.</p>",
|
390
|
+
"isRight": true
|
391
|
+
},
|
392
|
+
{
|
393
|
+
"describe": "<p>If the function has a single expression in the function body, the expression will be evaluated and implicitly returned.</p>",
|
394
|
+
"isRight": true
|
395
|
+
},
|
396
|
+
{
|
397
|
+
"describe": "<p>The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope.</p>",
|
398
|
+
"isRight": false
|
399
|
+
}
|
400
|
+
],
|
401
|
+
"analysis": "",
|
402
|
+
"hashCode": 1172379641
|
403
|
+
},
|
404
|
+
{
|
405
|
+
"describe": "<p>Refer to the code below:</p><p>01 const myFunction = arr => {</p><p>02 return arr. reduce((result, current) => {</p><p>03 return result + current;</p><p>04 }, 10);</p><p>05 }</p><p>What is the output if this function when called with an empty array?</p><p></p>",
|
406
|
+
"answerOptions": [
|
407
|
+
{
|
408
|
+
"describe": "<p>Returns 10</p>",
|
409
|
+
"isRight": true
|
410
|
+
},
|
411
|
+
{
|
412
|
+
"describe": "<p>Returns 0</p>",
|
413
|
+
"isRight": false
|
414
|
+
},
|
415
|
+
{
|
416
|
+
"describe": "<p>Throws an error</p>",
|
417
|
+
"isRight": false
|
418
|
+
},
|
419
|
+
{
|
420
|
+
"describe": "<p>Returns NaN</p>",
|
421
|
+
"isRight": false
|
422
|
+
}
|
423
|
+
],
|
424
|
+
"analysis": "<p>check array reduce method</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce</p>",
|
425
|
+
"hashCode": -224928759
|
426
|
+
},
|
427
|
+
{
|
428
|
+
"describe": "<p>Refer to the code:</p><p>01 function Animal(size, type) {</p><p>02 this.type = type || 'Animal' ;</p><p>03 this.canTalk = false ;</p><p>04 }</p><p>05</p><p>06 Animal.prototype.speak = function( ) {</p><p>07 if (this.canTalk) {</p><p>08 console.log(\"It spoke!\") ;</p><p>09 }</p><p>10 } ;</p><p>11</p><p>12 let Pet = function(size, type ,name, owner) {</p><p>13 Animal.call(this, size, type);</p><p>14 this.size = size;</p><p>15 this.name = name;</p><p>16 this.owner = owner;</p><p>17 }</p><p>18</p><p>19 Pet.prototype = Object.create(Animal.prototype);</p><p>20 let pet1 = new Pet( );</p><p>Given the code above, which three properties are set for pet1? Choose 3 answers</p>",
|
429
|
+
"answerOptions": [
|
430
|
+
{
|
431
|
+
"describe": "<p>speak</p>",
|
432
|
+
"isRight": true
|
433
|
+
},
|
434
|
+
{
|
435
|
+
"describe": "<p>canTalk</p>",
|
436
|
+
"isRight": true
|
437
|
+
},
|
438
|
+
{
|
439
|
+
"describe": "<p>owner</p>",
|
440
|
+
"isRight": false
|
441
|
+
},
|
442
|
+
{
|
443
|
+
"describe": "<p>name</p>",
|
444
|
+
"isRight": false
|
445
|
+
},
|
446
|
+
{
|
447
|
+
"describe": "<p>type</p>",
|
448
|
+
"isRight": true
|
449
|
+
}
|
450
|
+
],
|
451
|
+
"analysis": "<p>speak is a function in pet1's prototype chain</p><p>size, name, owner of pet1 is undefined</p>",
|
452
|
+
"hashCode": 1047844977
|
453
|
+
},
|
454
|
+
{
|
455
|
+
"describe": "<p>Given the code below:</p><p>01 function Person (name, email) {</p><p>02 this.name = name ;</p><p>03 this.email = email ;</p><p>04 }</p><p>05</p><p>06 const john = new Person('John', 'john@email.com');</p><p>07 const jane = new Person('Jane', 'jane@email.com');</p><p>08 const emily = new Person(' Emily', 'emily@email.com');</p><p>09</p><p>10 let usersList = [john, jane, emily];</p><p>Which method can be used to provide a visual representation of the list of users and to allow sorting by the name or email attribute?</p><p></p>",
|
456
|
+
"answerOptions": [
|
457
|
+
{
|
458
|
+
"describe": "<p>console.group (usersList) ;</p>",
|
459
|
+
"isRight": false
|
460
|
+
},
|
461
|
+
{
|
462
|
+
"describe": "<p>console.table (usersList) ;</p>",
|
463
|
+
"isRight": true
|
464
|
+
},
|
465
|
+
{
|
466
|
+
"describe": "<p>console.groupCollapsed(usersList) ;</p>",
|
467
|
+
"isRight": false
|
468
|
+
},
|
469
|
+
{
|
470
|
+
"describe": "<p>console.info(usersList);</p>",
|
471
|
+
"isRight": false
|
472
|
+
}
|
473
|
+
],
|
474
|
+
"analysis": "<p>This function takes one mandatory argument data, which must be an array or an object, and one additional optional parameter columns.</p><p>It logs data as a table. Each element in the array (or enumerable property if data is an object) will be a row in the table.</p><p>check console.table();</p><p>https://developer.mozilla.org/en-US/docs/Web/API/Console/table</p>",
|
475
|
+
"hashCode": -377381709
|
476
|
+
},
|
477
|
+
{
|
478
|
+
"describe": "<p>A developer wants to use a module named universalContainersLib and then call functions from it.</p><p>How should a developer import every function from the module and then call the functions foo and bar?</p><p></p>",
|
479
|
+
"answerOptions": [
|
480
|
+
{
|
481
|
+
"describe": "<p>import * as lib from '/path/universalContainersLib.js' ;</p><p>lib.foo( ) ;</p><p>lib.bar( ) ;</p>",
|
482
|
+
"isRight": true
|
483
|
+
},
|
484
|
+
{
|
485
|
+
"describe": "<p>import all from '/path/universalContainersLib.js' ;</p><p>universalContainersLib. foo( ) ;</p><p>universalContainersLib.bar( ) ;</p>",
|
486
|
+
"isRight": false
|
487
|
+
},
|
488
|
+
{
|
489
|
+
"describe": "<p>import * from 'path/universalContainersLib.js' ;</p><p>universalContainersLib. foo( ) ;</p><p>universalContainersLib.bar( ) ;</p>",
|
490
|
+
"isRight": false
|
491
|
+
},
|
492
|
+
{
|
493
|
+
"describe": "<p>import {foo,bar} from 'path/universalContainersLib.js' ;</p><p>foo( ) ;</p><p>bar( ) ;</p>",
|
494
|
+
"isRight": false
|
495
|
+
}
|
496
|
+
],
|
497
|
+
"analysis": "<p>check named import:</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import</p><p>import {foo,bar} from 'path/universalContainersLib.js' ;</p><p>this one will only import foo and bar function, not all function, from the module</p>",
|
498
|
+
"hashCode": -1405888802
|
499
|
+
},
|
500
|
+
{
|
501
|
+
"describe": "<p>At Universal Containers, every team has its own way of copying JavaScript objects. The codesnippet shows an implementation from one team:</p><p>01 function Person( ) {</p><p>02 this.firstName = \"John\" ;</p><p>03 this.lastName = \"Doe\" ;</p><p>04 this.name = ( ) => {</p><p>05 console.log(`Hello ${this.firstName} ${this. lastName}`);</p><p>06 }</p><p>07 }</p><p>08</p><p>09 const john = new Person( ) ;</p><p>10 const dan = JSON.parse (JSON . stringify (john));</p><p>11 dan.firstName = 'Dan';</p><p>12 dan.name( ) ;</p><p>What is the output of the code execution?</p><p></p>",
|
502
|
+
"answerOptions": [
|
503
|
+
{
|
504
|
+
"describe": "<p>TypeError: Assignment to constant variable</p>",
|
505
|
+
"isRight": false
|
506
|
+
},
|
507
|
+
{
|
508
|
+
"describe": "<p>Hello Dan Doe</p>",
|
509
|
+
"isRight": false
|
510
|
+
},
|
511
|
+
{
|
512
|
+
"describe": "<p>TypeError: dan.name is not a function</p>",
|
513
|
+
"isRight": true
|
514
|
+
},
|
515
|
+
{
|
516
|
+
"describe": "<p>Hello John Doe</p>",
|
517
|
+
"isRight": false
|
518
|
+
}
|
519
|
+
],
|
520
|
+
"analysis": "<p>line10 will convert john to a JSON Object and thus no such name function</p>",
|
521
|
+
"hashCode": -1654727508
|
522
|
+
},
|
523
|
+
{
|
524
|
+
"describe": "<p>Refer to the code below:</p><p>01 console. log(0) ;</p><p>02</p><p>03 setTimeout(( ) => {</p><p>04 console.log(1) ;</p><p>05 });</p><p>06</p><p>07 console.log(2) ;</p><p>08</p><p>09 setTimeout(( ) => {</p><p>10 console.log(3) ;</p><p>11 },0) ;</p><p>12</p><p>13 console.log(4) ;</p><p>In which sequence will the numbers be logged?</p><p></p>",
|
525
|
+
"answerOptions": [
|
526
|
+
{
|
527
|
+
"describe": "<p>0 1 2 3 4</p>",
|
528
|
+
"isRight": false
|
529
|
+
},
|
530
|
+
{
|
531
|
+
"describe": "<p>0 2 4 3 1</p>",
|
532
|
+
"isRight": false
|
533
|
+
},
|
534
|
+
{
|
535
|
+
"describe": "<p>0 2 4 1 3</p>",
|
536
|
+
"isRight": true
|
537
|
+
},
|
538
|
+
{
|
539
|
+
"describe": "<p>1 3 0 2 4</p>",
|
540
|
+
"isRight": false
|
541
|
+
}
|
542
|
+
],
|
543
|
+
"analysis": "",
|
544
|
+
"hashCode": -87784688
|
545
|
+
},
|
546
|
+
{
|
547
|
+
"describe": "<p>A class was written to represent items purchase in an online store, and a second class representing items that are on sales at a discounted price. The constructor sets the name to the first value passed in. The pseudocode is below:</p><p>class Item {</p><p>constructor (name, price) {</p><p>... // Constructor Implementation</p><p>}</p><p>}</p><p>class SaleItem extends Item {</p><p>constructor (name, price, discount) {</p><p>... // Constructor Implementation</p><p>}</p><p>}</p><p>There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem.</p><p>01 let regItem = new Item('Scarf', 55) ;</p><p>02 let saleItem = new SaleItem('Shirt', 80, .1) ;</p><p>03 Item.prototype.description = function( ){ return 'This is a ' + this.name; }</p><p>04 console.log (regItem.description( ));</p><p>05 console.log(saleItem.description( )) ;</p><p>06</p><p>07 SaleItem. prototype. description = function( ) { return 'This is a discounted'+ this.name; }</p><p>08 console.log(regItem. description( ));</p><p>09 console.log (saleItem. description( )) ;</p><p>What is the output when executing the code above?</p><p></p>",
|
548
|
+
"answerOptions": [
|
549
|
+
{
|
550
|
+
"describe": "<p>This is a Scarf</p><p>Uncaught TypeError: saleItem.description is not a function</p><p>This is a Scarf</p><p>This is a discounted Shirt</p>",
|
551
|
+
"isRight": false
|
552
|
+
},
|
553
|
+
{
|
554
|
+
"describe": "<p>This is a Scarf</p><p>Uncaught TypeError: saleItem.description is not a function</p><p>This is a Shirt</p><p>This is a discounted Shirt</p>",
|
555
|
+
"isRight": false
|
556
|
+
},
|
557
|
+
{
|
558
|
+
"describe": "<p>This is a Scarf</p><p>This is a Shirt</p><p>This is a discounted Scarf</p><p>This is a discounted Shirt</p>",
|
559
|
+
"isRight": false
|
560
|
+
},
|
561
|
+
{
|
562
|
+
"describe": "<p>This is a Scarf</p><p>This is a Shirt</p><p>This is a Scarf</p><p>This is a discounted Shirt</p>",
|
563
|
+
"isRight": true
|
564
|
+
}
|
565
|
+
],
|
566
|
+
"analysis": "",
|
567
|
+
"hashCode": 1276310888
|
568
|
+
},
|
569
|
+
{
|
570
|
+
"describe": "<p>A developer writes the code below to return a message to a user attempting to register a new username. If the username is available, a variable named msg is declared and assigned a value on line 03.</p><p>01 function getAvailabilityMessage (item) {</p><p>02 if (getAvailability (item)) {</p><p>03 var msg = \"Username available\" ;</p><p>04 }</p><p>05 return msg;</p><p>06 }</p><p>What is the value of msg when getAvailabilityMessage (\" newUserName\") is executed and getAvailability (\"newUserName\") returns true?</p><p></p>",
|
571
|
+
"answerOptions": [
|
572
|
+
{
|
573
|
+
"describe": "<p>undefined</p>",
|
574
|
+
"isRight": false
|
575
|
+
},
|
576
|
+
{
|
577
|
+
"describe": "<p>Username available</p>",
|
578
|
+
"isRight": true
|
579
|
+
},
|
580
|
+
{
|
581
|
+
"describe": "<p>msg is not defined</p>",
|
582
|
+
"isRight": false
|
583
|
+
},
|
584
|
+
{
|
585
|
+
"describe": "<p>NewUserName</p>",
|
586
|
+
"isRight": false
|
587
|
+
}
|
588
|
+
],
|
589
|
+
"analysis": "",
|
590
|
+
"hashCode": -1439546997
|
591
|
+
},
|
592
|
+
{
|
593
|
+
"describe": "<p>Refer to the code below:</p><p>01 function changeValue (param) {</p><p>02 param = 5 ;</p><p>03 }</p><p>04 let a =10 ;</p><p>05 let b = a ;</p><p>06</p><p>07 changeValue (b) ;</p><p>08 const result =a+' - '+b ;</p><p>What is the value of result when the code executes?</p><p></p>",
|
594
|
+
"answerOptions": [
|
595
|
+
{
|
596
|
+
"describe": "<p>5-10</p>",
|
597
|
+
"isRight": false
|
598
|
+
},
|
599
|
+
{
|
600
|
+
"describe": "<p>10-5</p>",
|
601
|
+
"isRight": false
|
602
|
+
},
|
603
|
+
{
|
604
|
+
"describe": "<p>5-5</p>",
|
605
|
+
"isRight": false
|
606
|
+
},
|
607
|
+
{
|
608
|
+
"describe": "<p>10-10</p>",
|
609
|
+
"isRight": true
|
610
|
+
}
|
611
|
+
],
|
612
|
+
"analysis": "",
|
613
|
+
"hashCode": 1902407972
|
614
|
+
},
|
615
|
+
{
|
616
|
+
"describe": "<p>Given the code block below:</p><p>01 function GameConsole (name) {</p><p>02 this.name = name ;</p><p>03 }</p><p>04</p><p>05 GameConsole.prototype.load = function (gamename) {</p><p>06 console.log(`${this.name} is loading a game: $ {gamename}...`) ;</p><p>07 }</p><p>08</p><p>09 function Console16bit (name) {</p><p>10 GameConsole.call (this, name) ;</p><p>11 }</p><p>12</p><p>13 Console16bit. prototype = Object. create (GameConsole. prototype) ;</p><p>14</p><p>15 // insert code here</p><p>16 console.log( ${this.name} is loading a cartridge game: ${gamename} ...`) ;</p><p>17 }</p><p>18</p><p>19 const console16bit = new Console16bit(' SNEGeneziz') ;</p><p>20 console16bit. load('Super Monic 3x Force') ;</p><p>What should a developer insert at line 15 to output the following message using the load method?</p><p>> SNEGeneziz is loading a cartridge game: Super Monic 3x Force. . .</p><p></p>",
|
617
|
+
"answerOptions": [
|
618
|
+
{
|
619
|
+
"describe": "<p>Console16bit.prototype.load = function (gamename) {</p>",
|
620
|
+
"isRight": true
|
621
|
+
},
|
622
|
+
{
|
623
|
+
"describe": "<p>Console16bit.prototype.load (gamename) = function( ) {</p>",
|
624
|
+
"isRight": false
|
625
|
+
},
|
626
|
+
{
|
627
|
+
"describe": "<p>Console16bit = Object.create (GameConsole .prototype).load =function (gamename) {</p>",
|
628
|
+
"isRight": false
|
629
|
+
},
|
630
|
+
{
|
631
|
+
"describe": "<p>Console16bit.prototype.load (gamename) {</p>",
|
632
|
+
"isRight": false
|
633
|
+
}
|
634
|
+
],
|
635
|
+
"analysis": "",
|
636
|
+
"hashCode": -338334712
|
637
|
+
},
|
638
|
+
{
|
639
|
+
"describe": "<p>Refer to the following code that performs a basic mathematical operation on a provided input:</p><p>01 function calculate (num) {</p><p>02 return (num + 10) / 3;</p><p>03 }</p><p>How should line 02 be written to ensure that x evaluates to 6 in the line below?</p><p>let x = calculate(\"8\") ;</p><p></p>",
|
640
|
+
"answerOptions": [
|
641
|
+
{
|
642
|
+
"describe": "<p>return Number (num + 10) / 3;</p>",
|
643
|
+
"isRight": false
|
644
|
+
},
|
645
|
+
{
|
646
|
+
"describe": "<p>return Integer(num + 10) / 3;</p>",
|
647
|
+
"isRight": false
|
648
|
+
},
|
649
|
+
{
|
650
|
+
"describe": "<p>return (Number(num) + 10) / 3;</p>",
|
651
|
+
"isRight": true
|
652
|
+
},
|
653
|
+
{
|
654
|
+
"describe": "<p>return Number((num + 10) / 3);</p>",
|
655
|
+
"isRight": false
|
656
|
+
}
|
657
|
+
],
|
658
|
+
"analysis": "",
|
659
|
+
"hashCode": -1251380895
|
660
|
+
},
|
661
|
+
{
|
662
|
+
"describe": "<p>A dveloper implements a fuction that adds a few values.</p><p>01 function sum (num) {</p><p>02 if (num === undefined) {</p><p>03 num = 0;</p><p>04 }</p><p>05 return function (num2, num3) {</p><p>06 if (num3 === undefined) {</p><p>07 num3=0</p><p>08 }</p><p>09 return num + num2 + num3 ;</p><p>10 }</p><p>11 }</p><p>Which three options can the developer invoke for this function to get a return value of 10?Choose 3 answers</p>",
|
663
|
+
"answerOptions": [
|
664
|
+
{
|
665
|
+
"describe": "<p>sum(10) ( )</p>",
|
666
|
+
"isRight": false
|
667
|
+
},
|
668
|
+
{
|
669
|
+
"describe": "<p>sum( ) (10)</p>",
|
670
|
+
"isRight": true
|
671
|
+
},
|
672
|
+
{
|
673
|
+
"describe": "<p>sum( )(5, 5)</p>",
|
674
|
+
"isRight": true
|
675
|
+
},
|
676
|
+
{
|
677
|
+
"describe": "<p>sum(5) (5)</p>",
|
678
|
+
"isRight": true
|
679
|
+
},
|
680
|
+
{
|
681
|
+
"describe": "<p>sum(5, 5) ( )</p>",
|
682
|
+
"isRight": false
|
683
|
+
}
|
684
|
+
],
|
685
|
+
"analysis": "<p>sum(10) ( ) and sum(5, 5) ( ) return NaN</p>",
|
686
|
+
"hashCode": 1273586046
|
687
|
+
},
|
688
|
+
{
|
689
|
+
"describe": "<p>Given the code below:</p><p>01 setCurrentUrl( ) ;</p><p>02 console.log('The current URL is: ' + url);</p><p>03</p><p>04 function setCurrentUrl ( ) {</p><p>05 url = window. location.href ;</p><p>06 }</p><p>What happens when the code executes?</p><p></p>",
|
690
|
+
"answerOptions": [
|
691
|
+
{
|
692
|
+
"describe": "<p>The url variable has global scope and line 02 executes correctly.</p>",
|
693
|
+
"isRight": true
|
694
|
+
},
|
695
|
+
{
|
696
|
+
"describe": "<p>The url variable has local scope and line 02 throws an error.</p>",
|
697
|
+
"isRight": false
|
698
|
+
},
|
699
|
+
{
|
700
|
+
"describe": "<p>The url variale has local scope and line 02 executes correctly.</p>",
|
701
|
+
"isRight": false
|
702
|
+
},
|
703
|
+
{
|
704
|
+
"describe": "<p>The url variable has global scope and line 02 throws an error.</p>",
|
705
|
+
"isRight": false
|
706
|
+
}
|
707
|
+
],
|
708
|
+
"analysis": "<p>Scope of the variables declared without var keyword become global irrespective of where it is declared. Global variables can be accessed from anywhere in the web page.</p>",
|
709
|
+
"hashCode": 1704091411
|
710
|
+
},
|
711
|
+
{
|
712
|
+
"describe": "<p>A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown below:</p><p>import printPrice from ' /path PricePrettyPrint.js' ;</p><p>Based on the code, what must be true about the printPrice function of the PricePrettyPrint module for this import to work?</p><p></p>",
|
713
|
+
"answerOptions": [
|
714
|
+
{
|
715
|
+
"describe": "<p>printPrice must be a multi export</p>",
|
716
|
+
"isRight": false
|
717
|
+
},
|
718
|
+
{
|
719
|
+
"describe": "<p>printPrice must be an all export</p>",
|
720
|
+
"isRight": false
|
721
|
+
},
|
722
|
+
{
|
723
|
+
"describe": "<p>printPrice must be a named export</p>",
|
724
|
+
"isRight": false
|
725
|
+
},
|
726
|
+
{
|
727
|
+
"describe": "<p>printPrice must be the default export</p>",
|
728
|
+
"isRight": true
|
729
|
+
}
|
730
|
+
],
|
731
|
+
"analysis": "<p>check default export:</p><p>https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export</p><p>if the printPrice is a named export, it would be: import { printPrice } from xxx;</p>",
|
732
|
+
"hashCode": -682085488
|
733
|
+
},
|
734
|
+
{
|
735
|
+
"describe": "<p>Given the JavaScript below:</p><p>01 function filterDOM (searchString) {</p><p>02 const parsedSearchstring = searchString && searchString. toLowerCase( ) ;</p><p>03 document . querySelectorAll (' .account') . forEach (account => {</p><p>04 const accountName = account . innerHTML. toLowerCase( ) ;</p><p>05 account.style.display = accountName . includes(parsedSearchString)? / * Insert code here */ ;</p><p>06 });</p><p>07 }</p><p>Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string?</p><p></p>",
|
736
|
+
"answerOptions": [
|
737
|
+
{
|
738
|
+
"describe": "<p>'block' : 'none'</p>",
|
739
|
+
"isRight": true
|
740
|
+
},
|
741
|
+
{
|
742
|
+
"describe": "<p>'none' : 'block'</p>",
|
743
|
+
"isRight": false
|
744
|
+
},
|
745
|
+
{
|
746
|
+
"describe": "<p>'visible' : 'hidden'</p>",
|
747
|
+
"isRight": false
|
748
|
+
},
|
749
|
+
{
|
750
|
+
"describe": "<p>'hidden' : 'visible'</p>",
|
751
|
+
"isRight": false
|
752
|
+
}
|
753
|
+
],
|
754
|
+
"analysis": "<p>check HTML style dispay property:</p><p>https://www.w3schools.com/JSREF/prop_style_display.asp</p><p>no 'hidden' or 'visible' property</p>",
|
755
|
+
"hashCode": 977031262
|
756
|
+
},
|
757
|
+
{
|
758
|
+
"describe": "<p>Which of the following can best describe a callback function?</p><p>A</p>",
|
759
|
+
"answerOptions": [
|
760
|
+
{
|
761
|
+
"describe": "<p>function passed into a function to be called later.</p>",
|
762
|
+
"isRight": true
|
763
|
+
},
|
764
|
+
{
|
765
|
+
"describe": "<p>A synchronous function that can be executed along with the main thread.</p>",
|
766
|
+
"isRight": false
|
767
|
+
},
|
768
|
+
{
|
769
|
+
"describe": "<p>A function that can be easily chained to another function.</p>",
|
770
|
+
"isRight": true
|
771
|
+
},
|
772
|
+
{
|
773
|
+
"describe": "<p>A function to be executed when there is an error.</p>",
|
774
|
+
"isRight": false
|
775
|
+
}
|
776
|
+
],
|
777
|
+
"analysis": "<p>A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.</p><p>Here is a quick example:</p><p>function greeting(name) {</p><p>alert('Hello ' + name);</p><p>}</p><p>function processUserInput(callback) {</p><p>var name = prompt('Please enter your name.');</p><p>callback(name);</p><p>}</p><p>processUserInput(greeting);</p><p>The above example is a synchronous callback, as it is executed immediately. However, that callbacks are often used to continue code execution after an asynchronous operation has completed — these are called asynchronous callbacks. A good example is the callback functions executed inside a .then() block chained onto the end of a promise after that promise fulfills or rejects. Another example would be the setTimeout function.</p>",
|
778
|
+
"hashCode": 121790993
|
779
|
+
},
|
780
|
+
{
|
781
|
+
"describe": "<p>A developer creates a class that represents a blog post based on the requirements that a Post should have a body, author, and view count. The code is shown below:</p><p>01 class Post {</p><p>02 // Insert code here</p><p>03 this.body = body;</p><p>04 this.author = author;</p><p>05 this. viewCount = viewCount;</p><p>06 }</p><p>07 }</p><p>Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instance of a Post with the three attributes correctly populated?</p><p></p>",
|
782
|
+
"answerOptions": [
|
783
|
+
{
|
784
|
+
"describe": "<p>function Post (body, author, viewCount) {</p>",
|
785
|
+
"isRight": false
|
786
|
+
},
|
787
|
+
{
|
788
|
+
"describe": "<p>super (body, author, viewCount) {</p>",
|
789
|
+
"isRight": false
|
790
|
+
},
|
791
|
+
{
|
792
|
+
"describe": "<p>constructor() {</p>",
|
793
|
+
"isRight": false
|
794
|
+
},
|
795
|
+
{
|
796
|
+
"describe": "<p>constructor (body, author, viewCount) {</p>",
|
797
|
+
"isRight": true
|
798
|
+
}
|
799
|
+
],
|
800
|
+
"analysis": "",
|
801
|
+
"hashCode": 201627949
|
802
|
+
},
|
803
|
+
{
|
804
|
+
"describe": "<p>Which of the following is the correct use of template literals?</p><p></p>",
|
805
|
+
"answerOptions": [
|
806
|
+
{
|
807
|
+
"describe": "<p>let str = \"Fifteen is ${a + b} and not ${2 * a + b}.\";</p>",
|
808
|
+
"isRight": false
|
809
|
+
},
|
810
|
+
{
|
811
|
+
"describe": "<p>let str = `Fifteen is ${a + b} and not ${2 * a + b}.`;</p>",
|
812
|
+
"isRight": true
|
813
|
+
},
|
814
|
+
{
|
815
|
+
"describe": "<p>let str = `Fifteen is $(a + b) and not $(2 * a + b).`</p>",
|
816
|
+
"isRight": false
|
817
|
+
},
|
818
|
+
{
|
819
|
+
"describe": "<p>let str = ${`Fifteen is ` + ( a + b ) + ` and not ` + (2 * a + b) + `.`};</p>",
|
820
|
+
"isRight": false
|
821
|
+
}
|
822
|
+
],
|
823
|
+
"analysis": "<p>Template literals are enclosed by the backtick (` `) and contain placeholders indicated by dollar sign and curly braces like ${expression}.</p><p>let str = `Fifteen is ${a + b} and not ${2 * a + b}.` is the right way of using template literals with placeholders.</p><p>let str = \"Fifteen is ${a + b} and not ${2 * a + b}.\" is incorrect because it is not enclosed by backticks but rather regular double quotes.</p><p>let str = ${`Fifteen is ` + ( a + b ) + ` and not ` + (2 * a + b) + `.`}; is incorrect as the dollar sign and curly braces are not inside the backticks.</p><p>let str = `Fifteen is $(a + b) and not $(2 * a + b).` is incorrect because the placeholder is enclosed by round brackets, not curly braces.</p>",
|
824
|
+
"hashCode": -156482148
|
825
|
+
},
|
826
|
+
{
|
827
|
+
"describe": "<p>A developer would like to understand the scope of functions, hence he wrote a simple script:</p><p>var p = 5;</p><p>function func() {</p><p>var p = 9;</p><p>function decl() {</p><p>console.log(p);</p><p>}</p><p>var expr = function() {</p><p>console.log(p);</p><p>};</p><p>var cons = new Function('\\tconsole.log(p);');</p><p>decl();</p><p>expr();</p><p>cons();</p><p>}</p><p>func();</p><p>What is the correct output that will be displayed on the console when the code is executed?</p><p></p>",
|
828
|
+
"answerOptions": [
|
829
|
+
{
|
830
|
+
"describe": "<p>9 9 5</p>",
|
831
|
+
"isRight": true
|
832
|
+
},
|
833
|
+
{
|
834
|
+
"describe": "<p>9 9 9</p>",
|
835
|
+
"isRight": false
|
836
|
+
},
|
837
|
+
{
|
838
|
+
"describe": "<p>9 5 9</p>",
|
839
|
+
"isRight": false
|
840
|
+
},
|
841
|
+
{
|
842
|
+
"describe": "<p>5 5 9</p>",
|
843
|
+
"isRight": false
|
844
|
+
}
|
845
|
+
],
|
846
|
+
"analysis": "<p>The correct output of the script is 9 9 5.</p><p>A function defined by a function expression (indicated by expr()) or by a function declaration (indicated by decl()) inherits the current scope. That is, the function forms a closure. On the other hand, a function defined by a Function constructor (indicated by cons()) does not inherit any scope other than the global scope (which all functions inherit).</p>",
|
847
|
+
"hashCode": -1353616245
|
848
|
+
},
|
849
|
+
{
|
850
|
+
"describe": "<p>const target = { a: 1, b: 2 };</p><p>const source = { b: 4, c: 5 };</p><p>const returnedTarget = Object.assign(target, source);</p><p>target.a = 6;</p><p>source.c = 12;</p><p>console.log(returnedTarget.a);</p><p>console.log(returnedTarget.b);</p><p>console.log(returnedTarget.c);</p><p>Given the code above, what would be printed out in the console?</p><p></p>",
|
851
|
+
"answerOptions": [
|
852
|
+
{
|
853
|
+
"describe": "<p>6 4 12</p>",
|
854
|
+
"isRight": false
|
855
|
+
},
|
856
|
+
{
|
857
|
+
"describe": "<p>1 4 5</p>",
|
858
|
+
"isRight": false
|
859
|
+
},
|
860
|
+
{
|
861
|
+
"describe": "<p>1 2 5</p>",
|
862
|
+
"isRight": false
|
863
|
+
},
|
864
|
+
{
|
865
|
+
"describe": "<p>6 4 5</p>",
|
866
|
+
"isRight": true
|
867
|
+
}
|
868
|
+
],
|
869
|
+
"analysis": "<p>The correct output sequence will be 6, 4 and 5.</p><p>Object.assign(dest, [src1, src2, src3…]) copies the properties of all source objects into the target destination (first parameter) which is also the target object in this scenario. Since the target object is assigned to returnedTarget, the change of properties in target object will also reflect on returnedTarget object, hence we get 6, 4, 5. The change of properties in source object does not reflect on returnedTarget because the source properties are copied by value into target object which then assigned to returnedTarget object.</p>",
|
870
|
+
"hashCode": 694078930
|
871
|
+
},
|
872
|
+
{
|
873
|
+
"describe": "<p>Which of the following statements regarding an object property is correct? Choose 2 answers.</p><p></p>",
|
874
|
+
"answerOptions": [
|
875
|
+
{
|
876
|
+
"describe": "<p>In order to remove an object property, we could use delete operator to remove the property.</p>",
|
877
|
+
"isRight": true
|
878
|
+
},
|
879
|
+
{
|
880
|
+
"describe": "<p>An object declared as const cannot be modified.</p>",
|
881
|
+
"isRight": false
|
882
|
+
},
|
883
|
+
{
|
884
|
+
"describe": "<p>You cannot use specific language-reserved words such as \"for\", \"let\", \"return\" and etc. for an object property.</p>",
|
885
|
+
"isRight": false
|
886
|
+
},
|
887
|
+
{
|
888
|
+
"describe": "<p>It is possible to use square brackets in an object literal when creating an object.</p>",
|
889
|
+
"isRight": true
|
890
|
+
}
|
891
|
+
],
|
892
|
+
"analysis": "<p>An object property can be removed by using delete operator. Here’s an example:</p><p>let user = { // an object</p><p>name: \"John\", // by key \"name\" store value \"John\"</p><p>age: 30 // by key \"age\" store value 30</p><p>};</p><p>delete user.age;</p><p>When an object is declared as const, it can be modified actually. The const fixes the value of the object, not its contents. For example:</p><p>const user = {</p><p>name: \"John\"</p><p>};</p><p>user.name = \"Pete\"; // no error is thrown</p><p>user = {}; // uncaught TypeError: Assignment to constant variable</p><p>It is possible to use square brackets in an object literal when creating an object. For example:</p><p>let fruit = prompt(\"Which fruit to buy?\", \"apple\");</p><p>let bag = {</p><p>[fruit]: 5, // the name of the property is taken from the variable fruit</p><p>};</p><p>console.log( bag.apple ); // 5 if fruit=\"apple\"</p><p>a variable cannot have a name equal to one of language-reserved words like “for”, “let”, “return” etc. But for an object property, there’s no such restriction:</p><p>// these properties are all right</p><p>let obj = {</p><p>for: 1,</p><p>let: 2,</p><p>return: 3</p><p>};</p><p>console.log( obj.for + obj.let + obj.return ); // 6</p>",
|
893
|
+
"hashCode": 542607607
|
894
|
+
},
|
895
|
+
{
|
896
|
+
"describe": "<p>Which of the following regarding function is correct? Choose 3 answers.</p><p>A The default parameter in the function will always be evaluated.</p><p>B A f</p>",
|
897
|
+
"answerOptions": [
|
898
|
+
{
|
899
|
+
"describe": "<p>function may not be accessed outer variables if the variable is declared with \"let\" keyword.</p><p>C jQuery library defines a function with \"$\" while the Lodash library defines its main core function with \"_\".</p><p>D Never add a newline between return and the value.</p><p>E If a function does not return a value, it is the same as if it returns undefined.</p>",
|
900
|
+
"isRight": false
|
901
|
+
}
|
902
|
+
],
|
903
|
+
"analysis": "<p>A default parameter will be evaluated if the function is called without the respective parameter</p><p>If a function does not return a value, it is the same as if it returns undefined</p><p>An empty return is also the same as return undefined</p><p>jQuery library defines a function with “$” while the Lodash library defines its main core function with “_”.</p><p>You should not add a newline between return and the value you want to return. Reason being, JavaScript might interpret your code differently. For example, you want to return a long expression like this:</p><p>return</p><p>(some + long + expression + or + whatever * f(a) + f(b))</p><p>The code will not work as expected. JavaScript assumes there is a semicolon after return keyword, which effectively becomes an empty return. However, if you really want to do so, make sure you wrap your expression at the same line as return keyword like this:</p><p>return (</p><p>some + long + expression</p><p>+ or +</p><p>whatever * f(a) + f(b)</p><p>)</p><p>That way, JavaScript will not misinterpret your code.</p>",
|
904
|
+
"hashCode": 1548391267
|
905
|
+
},
|
906
|
+
{
|
907
|
+
"describe": "<p>A developer wants to use a module called DatePrettyPrint. This module exports one default function called printDate(). How can a developer import and use the printDate() function?</p><p></p>",
|
908
|
+
"answerOptions": [
|
909
|
+
{
|
910
|
+
"describe": "<p>import printDate from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate();</p>",
|
911
|
+
"isRight": false
|
912
|
+
},
|
913
|
+
{
|
914
|
+
"describe": "<p>import printDate from '/path/DatePrettyPrint.js'; printDate();</p>",
|
915
|
+
"isRight": true
|
916
|
+
},
|
917
|
+
{
|
918
|
+
"describe": "<p>import DatePrettyPrint from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate();</p>",
|
919
|
+
"isRight": false
|
920
|
+
},
|
921
|
+
{
|
922
|
+
"describe": "<p>import printDate() from '/path/DatePrettyPrint.js'; printDate();</p>",
|
923
|
+
"isRight": false
|
924
|
+
}
|
925
|
+
],
|
926
|
+
"analysis": "<p>import printDate from '/path/DatePrettyPrint.js'; printDate(); is the simplest version of code for importing the default.</p><p>import printDate() from '/path/DatePrettyPrint.js'; printDate(); is incorrect. When naming the export function the parentheses are not needed.</p><p>import DatePrettyPrint from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate(); is incorrect. You must call the methods directly or use the * to import all methods.</p><p>import printDate from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate(); is incorrect. Once imported by name, you must call the imported method directly by name.</p>",
|
927
|
+
"hashCode": -388162408
|
928
|
+
},
|
929
|
+
{
|
930
|
+
"describe": "<p>Given the code below:</p><p>let x = 2;</p><p>let y = 3;</p><p>let add = x => y => x + y;</p><p>The “add” variable is an arrow function which is used to sum two numbers. What is the correct way of calling this function? Choose 1 answer.</p><p></p>",
|
931
|
+
"answerOptions": [
|
932
|
+
{
|
933
|
+
"describe": "<p>add(x)(y)</p>",
|
934
|
+
"isRight": true
|
935
|
+
},
|
936
|
+
{
|
937
|
+
"describe": "<p>add()</p>",
|
938
|
+
"isRight": false
|
939
|
+
},
|
940
|
+
{
|
941
|
+
"describe": "<p>add.x.y</p>",
|
942
|
+
"isRight": false
|
943
|
+
},
|
944
|
+
{
|
945
|
+
"describe": "<p>add(x, y)</p>",
|
946
|
+
"isRight": false
|
947
|
+
}
|
948
|
+
],
|
949
|
+
"analysis": "<p>The correct way of calling this add function is add(x)(y). The arrow function is equivalent to the following code:</p><p>const add = function (x) {</p><p>return function (y) {</p><p>return x + y;</p><p>}</p><p>}</p><p>This is also called “Curried Function“. Currying is a transform that makes f(a, b, c) callable as f(a)(b)(c). The advantage of currying is that it allows us to easily get the partials. For example, we might just want to call f(a) or f(a)(b), depending on our own needs.</p>",
|
950
|
+
"hashCode": 972403238
|
951
|
+
},
|
952
|
+
{
|
953
|
+
"describe": "<p>Which syntax for accessing the property of an object in JavaScript is correct? Choose 3 answers.</p>",
|
954
|
+
"answerOptions": [
|
955
|
+
{
|
956
|
+
"describe": "<p>objectName[\"property\"] // person[\"age\"]</p>",
|
957
|
+
"isRight": true
|
958
|
+
},
|
959
|
+
{
|
960
|
+
"describe": "<p>objectName.property // person.age</p>",
|
961
|
+
"isRight": true
|
962
|
+
},
|
963
|
+
{
|
964
|
+
"describe": "<p>${objectName(property)} // ${person(property)}</p>",
|
965
|
+
"isRight": false
|
966
|
+
},
|
967
|
+
{
|
968
|
+
"describe": "<p>objectName[expression] // x = \"age\"; person[x]</p>",
|
969
|
+
"isRight": true
|
970
|
+
},
|
971
|
+
{
|
972
|
+
"describe": "<p>objectName->property // person->age</p>",
|
973
|
+
"isRight": false
|
974
|
+
}
|
975
|
+
],
|
976
|
+
"analysis": "<p>The correct syntax for accessing the property of an object is:</p><p>objectName.property</p><p>objectName[\"property\"]</p><p>objectName[expression]</p><p>objectName->property is invalid in JavaScript, though it might be valid for some other programming languages such as PHP.</p><p>There is nothing like ${person(property)} in JavaScript or any known programming languages.</p>",
|
977
|
+
"hashCode": -990895308
|
978
|
+
},
|
979
|
+
{
|
980
|
+
"describe": "<p>Which statement sorts the following number array so it is in ascending order?</p><p>const arr = [7, 3, 400, 10];</p><p>Choose 1 answer.</p><p></p>",
|
981
|
+
"answerOptions": [
|
982
|
+
{
|
983
|
+
"describe": "<p>arr.sort((a, b) => a < b);[/su_highlight]</p>",
|
984
|
+
"isRight": false
|
985
|
+
},
|
986
|
+
{
|
987
|
+
"describe": "<p>arr.sort();</p>",
|
988
|
+
"isRight": false
|
989
|
+
},
|
990
|
+
{
|
991
|
+
"describe": "<p>arr.sort((a, b) => a – b);</p>",
|
992
|
+
"isRight": true
|
993
|
+
},
|
994
|
+
{
|
995
|
+
"describe": "<p>arr.sort((a, b) => b – a);</p>",
|
996
|
+
"isRight": false
|
997
|
+
}
|
998
|
+
],
|
999
|
+
"analysis": "<p>By default, the sort() function sorts values as strings.</p><p>arr.sort( (a, b) => a – b); is the correct answer. The compare function passed in sort() defines an alternative sort order.</p><p>arr.sort(); is incorrect because the sort() function sorts values as strings, which will sort this as [10, 3, 400, 7].</p><p>arr.sort((a, b) => a < b); is incorrect. The compare function expects a positive, negative, or 0 to be returned, not the Boolean expression.</p><p>arr.sort((a, b) => b – a); is incorrect. The compare function will actually reverse the order of the numbers.</p>",
|
1000
|
+
"hashCode": 577492143
|
1001
|
+
},
|
1002
|
+
{
|
1003
|
+
"describe": "<p>You are given the following code:</p><p>let user = { name: \"John\"};</p><p>user.canView = false;</p><p>user.canEdit = false;</p><p>let permissions1 = { canView: true, canEdit: false };</p><p>let permissions2 = { canView: false, canEdit: true };</p><p>Object.assign(user, permissions1, permissions2);</p><p>console.log(user);</p><p>What will the output be when the code is executed? Choose 1 answer.</p><p></p>",
|
1004
|
+
"answerOptions": [
|
1005
|
+
{
|
1006
|
+
"describe": "<p>{</p><p>name:\"John\",</p><p>canView:false,</p><p>canEdit:false</p><p>}</p>",
|
1007
|
+
"isRight": false
|
1008
|
+
},
|
1009
|
+
{
|
1010
|
+
"describe": "<p>{</p><p>name:\"John\",</p><p>canView:true,</p><p>canEdit:false</p><p>}</p>",
|
1011
|
+
"isRight": false
|
1012
|
+
},
|
1013
|
+
{
|
1014
|
+
"describe": "<p>{</p><p>name:\"John\",</p><p>canView:false,</p><p>canEdit:true</p><p>}</p>",
|
1015
|
+
"isRight": true
|
1016
|
+
},
|
1017
|
+
{
|
1018
|
+
"describe": "<p>{</p><p>name:\"John\",</p><p>canView:true,</p><p>canEdit:true</p><p>}</p>",
|
1019
|
+
"isRight": false
|
1020
|
+
}
|
1021
|
+
],
|
1022
|
+
"analysis": "<p>The correct answer is:</p><p>{</p><p>name:\"John\",</p><p>canView:false,</p><p>canEdit:true</p><p>}</p><p>Object.assign() method copies all enumerable own properties from one or more source objects to a target object. The properties are overwritten by other objects that have the same properties later in the order of the parameters.</p>",
|
1023
|
+
"hashCode": -1848566150
|
1024
|
+
},
|
1025
|
+
{
|
1026
|
+
"describe": "<p>Given the following Car constructor:</p><p>function Car(size, model) {</p><p>this.size= size;</p><p>this.model = model;</p><p>}</p><p>Which method creates a new instance of the object? Choose 1 answer.</p><p></p>",
|
1027
|
+
"answerOptions": [
|
1028
|
+
{
|
1029
|
+
"describe": "<p>new Car('large', 'Audi');</p>",
|
1030
|
+
"isRight": true
|
1031
|
+
},
|
1032
|
+
{
|
1033
|
+
"describe": "<p>Object.prototype(Car);</p>",
|
1034
|
+
"isRight": false
|
1035
|
+
},
|
1036
|
+
{
|
1037
|
+
"describe": "<p>Object.new(Car);</p>",
|
1038
|
+
"isRight": false
|
1039
|
+
},
|
1040
|
+
{
|
1041
|
+
"describe": "<p>Object.create('Car');</p>",
|
1042
|
+
"isRight": false
|
1043
|
+
}
|
1044
|
+
],
|
1045
|
+
"analysis": "<p>new Car('large', 'Audi'); is the correct way of creating a new instance of object.</p><p>Object.create('Car'); is incorrect. The argument for Object.create() method should be a new object with the specified prototype object and properties.</p><p>Object.prototype(Animal); is incorrect. Prototypes are usually used to add methods to existing constructors.</p><p>Object.new(Animal); is incorrect as well. There is no Object.new() in JavaScript.</p>",
|
1046
|
+
"hashCode": -1880423419
|
1047
|
+
},
|
1048
|
+
{
|
1049
|
+
"describe": "<p>function func() {</p><p>try {</p><p>return 1;</p><p>} finally {</p><p>console.log( 'finally' );</p><p>}</p><p>}</p><p>console.log( func() );</p><p>Which of the following statement is correct when the code above is executed? Choose 1 answer.</p><p></p>",
|
1050
|
+
"answerOptions": [
|
1051
|
+
{
|
1052
|
+
"describe": "<p>The console output will display \"1\" first, then \"finally\".</p>",
|
1053
|
+
"isRight": false
|
1054
|
+
},
|
1055
|
+
{
|
1056
|
+
"describe": "<p>The console output will display \"finally\" first, then \"1\".</p>",
|
1057
|
+
"isRight": true
|
1058
|
+
},
|
1059
|
+
{
|
1060
|
+
"describe": "<p>The finally block will not be executed because the function is returned before the finally code block.</p>",
|
1061
|
+
"isRight": false
|
1062
|
+
},
|
1063
|
+
{
|
1064
|
+
"describe": "<p>The code will not work because it is missing the catch block.</p>",
|
1065
|
+
"isRight": false
|
1066
|
+
}
|
1067
|
+
],
|
1068
|
+
"analysis": "<p>Finally block will be executed before the code returns to the outer code, hence the output will display “finally” first, then “1”.</p><p>Catch block is not mandatory if we are not to catch the error when executing the code.</p>",
|
1069
|
+
"hashCode": -1140449447
|
1070
|
+
},
|
1071
|
+
{
|
1072
|
+
"describe": "<p>Which of the following regarding Classes in JavaScript is correct? Choose 3 answers.</p>",
|
1073
|
+
"answerOptions": [
|
1074
|
+
{
|
1075
|
+
"describe": "<p>Class expressions can be named or unnamed and the name given to a named class expression is local to the class's body.</p>",
|
1076
|
+
"isRight": true
|
1077
|
+
},
|
1078
|
+
{
|
1079
|
+
"describe": "<p>JavaScript classes are introduced in ECMAScript 2016 Edition.</p>",
|
1080
|
+
"isRight": false
|
1081
|
+
},
|
1082
|
+
{
|
1083
|
+
"describe": "<p>Classes are the \"special functions\" which are primarily syntactical sugar over JavaScript's existing prototype-based inheritance.</p>",
|
1084
|
+
"isRight": true
|
1085
|
+
},
|
1086
|
+
{
|
1087
|
+
"describe": "<p>There are two ways to define a class: class declaration and class expression.</p>",
|
1088
|
+
"isRight": true
|
1089
|
+
},
|
1090
|
+
{
|
1091
|
+
"describe": "<p>The difference between function declarations and class declarations is that class declarations are hoisted and function declarations are not.</p>",
|
1092
|
+
"isRight": false
|
1093
|
+
}
|
1094
|
+
],
|
1095
|
+
"analysis": "<p>Classes are the “special functions” which are primarily syntactical sugar over JavaScript’s existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript.</p><p>The class syntax has two components: class expressions and class declarations.</p><p>Class declaration example:</p><p>// class declaration</p><p>class Rectangle {</p><p>constructor(height, width) {</p><p>this.height = height;</p><p>this.width = width;</p><p>}</p><p>}</p><p>Class expression examples:</p><p>// unnamed class expression</p><p>let Rectangle = class {</p><p>constructor(height, width) {</p><p>this.height = height;</p><p>this.width = width;</p><p>}</p><p>};</p><p>// named class expression</p><p>let Rectangle = class Rectangle2 {</p><p>constructor(height, width) {</p><p>this.height = height;</p><p>this.width = width;</p><p>}</p><p>};</p><p>Function declarations are hoisted but class declarations are not. The following example with throw an error:</p><p>const p = new Rectangle(); // ReferenceError</p><p>class Rectangle { }</p><p>JavaScript classes are introduced in ECMAScript 2015, also known as JavaScript ES6.</p>",
|
1096
|
+
"hashCode": -104347577
|
1097
|
+
},
|
1098
|
+
{
|
1099
|
+
"describe": "<p>Which of the following statements is correct regarding the JSON and object literal notation? Choose 2 answers.</p><p></p>",
|
1100
|
+
"answerOptions": [
|
1101
|
+
{
|
1102
|
+
"describe": "<p>JSON and object literal notation are the same.</p>",
|
1103
|
+
"isRight": false
|
1104
|
+
},
|
1105
|
+
{
|
1106
|
+
"describe": "<p>Object literal notation spec is based on JSON.</p>",
|
1107
|
+
"isRight": false
|
1108
|
+
},
|
1109
|
+
{
|
1110
|
+
"describe": "<p>Object literal notation is a programming syntax.</p>",
|
1111
|
+
"isRight": true
|
1112
|
+
},
|
1113
|
+
{
|
1114
|
+
"describe": "<p>JSON is a data-interchange format.</p>",
|
1115
|
+
"isRight": true
|
1116
|
+
}
|
1117
|
+
],
|
1118
|
+
"analysis": "<p>JSON (JavaScript Object Notation) is a data-interchange format.</p><p>Object literal notation is a programming syntax.</p><p>JSON and object literal notation resemble each other, but they’re not the same.</p><p>JSON spec is based on object-literal notation, not the other way round.</p>",
|
1119
|
+
"hashCode": 1491692238
|
1120
|
+
},
|
1121
|
+
{
|
1122
|
+
"describe": "<p>Which of the following is a feature of prototypical inheritance?</p><p>A</p>",
|
1123
|
+
"answerOptions": [
|
1124
|
+
{
|
1125
|
+
"describe": "<p>class that defines all objects of a common type.</p>",
|
1126
|
+
"isRight": false
|
1127
|
+
},
|
1128
|
+
{
|
1129
|
+
"describe": "<p>Module code artifacts that define a single reusable feature.</p>",
|
1130
|
+
"isRight": false
|
1131
|
+
},
|
1132
|
+
{
|
1133
|
+
"describe": "<p>Architecture that ensures data from some objects can be passed to other objects.</p>",
|
1134
|
+
"isRight": false
|
1135
|
+
},
|
1136
|
+
{
|
1137
|
+
"describe": "<p>An in-memory object that defines properties and functions of other objects.</p>",
|
1138
|
+
"isRight": true
|
1139
|
+
}
|
1140
|
+
],
|
1141
|
+
"analysis": "<p>Despite not having classes as defined by classical languages, JavaScript still has an inheritance model which is called prototype inheritance. A prototype is another object that sits in memory and defines properties or functions that other objects inherit if they share the same prototype.</p>",
|
1142
|
+
"hashCode": 2035832970
|
1143
|
+
},
|
1144
|
+
{
|
1145
|
+
"describe": "<p>Which of the following can be best described modules? Choose 2 answers.</p><p>A Modules work on HTTP, HTTPS, and website document that stores locally on your computer.</p><p>B Modules can be set \"use strict\" optionally.</p><p>C A m</p>",
|
1146
|
+
"answerOptions": [
|
1147
|
+
{
|
1148
|
+
"describe": "<p>module is just a file that may contain a class or a library of functions for a specific purpose.</p><p>D Modules can load each other and special directives such as export and import can be used interchangeably.</p>",
|
1149
|
+
"isRight": false
|
1150
|
+
}
|
1151
|
+
],
|
1152
|
+
"analysis": "<p>A module is just a file. One script is one module. As simple as that. A module may contain a class or a library of functions for a specific purpose.</p><p>We must tell the browser that a script should be treated as a module by using the attribute</p>",
|
1153
|
+
"hashCode": -514234380
|
1154
|
+
},
|
1155
|
+
{
|
1156
|
+
"describe": "<p>The developer has a function that prints \"Hello\" to an input name. To test this, the developer</p><p>created a function that returns \"World\". However, the following snippet does not print \"Hello World\".</p><p>01 const sayHello = (name) => {</p><p>02 console.log('Hello ', name) ;</p><p>03 };</p><p>04</p><p>05 const world= ( ) => {</p><p>06 return 'World' ;</p><p>07 } ;</p><p>08</p><p>09 sayHello (world) ;</p><p>What can the developer do to change the code to print \"Hello World\"?</p><p></p>",
|
1157
|
+
"answerOptions": [
|
1158
|
+
{
|
1159
|
+
"describe": "<p>Change line 7 to } ( ) ;</p>",
|
1160
|
+
"isRight": false
|
1161
|
+
},
|
1162
|
+
{
|
1163
|
+
"describe": "<p>Change line 5 to function world( ) {</p>",
|
1164
|
+
"isRight": false
|
1165
|
+
},
|
1166
|
+
{
|
1167
|
+
"describe": "<p>Change line 2 to consololoe. log('Hello', name( ));</p>",
|
1168
|
+
"isRight": true
|
1169
|
+
},
|
1170
|
+
{
|
1171
|
+
"describe": "<p>Change line 9 to sayHello(world)( ) ;</p>",
|
1172
|
+
"isRight": false
|
1173
|
+
}
|
1174
|
+
],
|
1175
|
+
"analysis": "<p>world is a function, call sayHello and pass in the world function will print out the function body itself</p>",
|
1176
|
+
"hashCode": -320362966
|
1177
|
+
},
|
1178
|
+
{
|
1179
|
+
"describe": "<p>Refer to the code below:</p><p>01 function foo( ) {</p><p>02 const a = 2;</p><p>03 function bar( ) {</p><p>04 console.log(a) ;</p><p>05 }</p><p>06 return bar;</p><p>07 }</p><p>Why does the function bar have access to variable a?</p><p></p>",
|
1180
|
+
"answerOptions": [
|
1181
|
+
{
|
1182
|
+
"describe": "<p>Inner function's scope</p>",
|
1183
|
+
"isRight": false
|
1184
|
+
},
|
1185
|
+
{
|
1186
|
+
"describe": "<p>Hoisting</p>",
|
1187
|
+
"isRight": false
|
1188
|
+
},
|
1189
|
+
{
|
1190
|
+
"describe": "<p>Outer function's scope</p>",
|
1191
|
+
"isRight": true
|
1192
|
+
},
|
1193
|
+
{
|
1194
|
+
"describe": "<p>Prototype chain</p>",
|
1195
|
+
"isRight": false
|
1196
|
+
}
|
1197
|
+
],
|
1198
|
+
"analysis": "<p>check JavaScript Closure</p><p>a closure gives you access to an outer function's scope from an inner function.</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures</p>",
|
1199
|
+
"hashCode": 2049249383
|
1200
|
+
},
|
1201
|
+
{
|
1202
|
+
"describe": "<p>A developer uses a parsed JSON string to work with user informationas in the block below:</p><p>01 const userInformation = {</p><p>02 \"id\" : \"user-01\",</p><p>03 \"email\" : \"user01@universalcontainers . demo\" ,</p><p>04 \"age\" : 25</p><p>05 };</p><p>Which two options access the email attriuite in the object? Choose 2 answers</p><p></p>",
|
1203
|
+
"answerOptions": [
|
1204
|
+
{
|
1205
|
+
"describe": "<p>userInformation[\"email\"]</p>",
|
1206
|
+
"isRight": true
|
1207
|
+
},
|
1208
|
+
{
|
1209
|
+
"describe": "<p>userInformation. email</p>",
|
1210
|
+
"isRight": true
|
1211
|
+
},
|
1212
|
+
{
|
1213
|
+
"describe": "<p>userInformation. get (\"email\")</p>",
|
1214
|
+
"isRight": false
|
1215
|
+
},
|
1216
|
+
{
|
1217
|
+
"describe": "<p>userInformation[email]</p>",
|
1218
|
+
"isRight": false
|
1219
|
+
}
|
1220
|
+
],
|
1221
|
+
"analysis": "",
|
1222
|
+
"hashCode": 415077733
|
1223
|
+
},
|
1224
|
+
{
|
1225
|
+
"describe": "<p>Refer to the code below:</p><p>flag( ) ;</p><p>anotherFlag( ) ;</p><p>function flag( ) {</p><p>console.log('flag') ;</p><p>}</p><p>const anotherFlag = ( ) => {</p><p>console.log( 'another flag') ;</p><p>}</p><p>What is result of the code block?</p><p></p>",
|
1226
|
+
"answerOptions": [
|
1227
|
+
{
|
1228
|
+
"describe": "<p>An error is thrown.</p>",
|
1229
|
+
"isRight": false
|
1230
|
+
},
|
1231
|
+
{
|
1232
|
+
"describe": "<p>The console logs only 'flag'.</p>",
|
1233
|
+
"isRight": false
|
1234
|
+
},
|
1235
|
+
{
|
1236
|
+
"describe": "<p>The console logs 'flag' and then an error is thrown.</p>",
|
1237
|
+
"isRight": true
|
1238
|
+
},
|
1239
|
+
{
|
1240
|
+
"describe": "<p>The console logs 'flag' and 'another flag'.</p>",
|
1241
|
+
"isRight": false
|
1242
|
+
}
|
1243
|
+
],
|
1244
|
+
"analysis": "<p>const declarations must be initialized</p><p>const initialization must be happening before calling</p><p>flag() is called first and output 'flag', then call anotherFlag(), get error: Cannot access 'anotherFlag' before initialization</p>",
|
1245
|
+
"hashCode": -926091128
|
1246
|
+
},
|
1247
|
+
{
|
1248
|
+
"describe": "<p>Refer to the following code:</p><p>01 function test(val) {</p><p>02 if (val === undefined) {</p><p>03 return 'Undefined value!' ;</p><p>04 }</p><p>05 if (val === null) {</p><p>06 return 'Null value!' ;</p><p>07 }</p><p>08 return val;</p><p>09 }</p><p>10</p><p>11 let x ;</p><p>12</p><p>13 test(x) ;</p><p>What is returned by the function call on line 13?</p><p></p>",
|
1249
|
+
"answerOptions": [
|
1250
|
+
{
|
1251
|
+
"describe": "<p>undefined</p>",
|
1252
|
+
"isRight": false
|
1253
|
+
},
|
1254
|
+
{
|
1255
|
+
"describe": "<p>Line 13 throws an error.</p>",
|
1256
|
+
"isRight": false
|
1257
|
+
},
|
1258
|
+
{
|
1259
|
+
"describe": "<p>'Null value!'</p>",
|
1260
|
+
"isRight": false
|
1261
|
+
},
|
1262
|
+
{
|
1263
|
+
"describe": "<p>'Undefined value!'</p>",
|
1264
|
+
"isRight": true
|
1265
|
+
}
|
1266
|
+
],
|
1267
|
+
"analysis": "<p>line 11, x is undefined</p>",
|
1268
|
+
"hashCode": -173811572
|
1269
|
+
},
|
1270
|
+
{
|
1271
|
+
"describe": "<p>Refer to the code below:</p><p>01 let first = 'Who';</p><p>02 let second = 'What';</p><p>03 try {</p><p>04 try {</p><p>05 throw new Error('Sad trombone');</p><p>06 } catch (err) {</p><p>07 first = 'Why' ;</p><p>08 } finally {</p><p>09 second = 'When';</p><p>10 }</p><p>11 } catch (err) {</p><p>12 second = 'Where' ;</p><p>13 }</p><p>What are the values for first and second once the code executes?</p><p></p>",
|
1272
|
+
"answerOptions": [
|
1273
|
+
{
|
1274
|
+
"describe": "<p>first is Why and second is Where.</p>",
|
1275
|
+
"isRight": false
|
1276
|
+
},
|
1277
|
+
{
|
1278
|
+
"describe": "<p>first is Who and second is When.</p>",
|
1279
|
+
"isRight": false
|
1280
|
+
},
|
1281
|
+
{
|
1282
|
+
"describe": "<p>first is Why and second is When.</p>",
|
1283
|
+
"isRight": true
|
1284
|
+
},
|
1285
|
+
{
|
1286
|
+
"describe": "<p>first is Who and second is Where.</p>",
|
1287
|
+
"isRight": false
|
1288
|
+
}
|
1289
|
+
],
|
1290
|
+
"analysis": "<p>inner try block throws an error, so first was changed to Why</p><p>finally block will be executed next, so second will be changed to When</p><p>outter catch block is skipped</p>",
|
1291
|
+
"hashCode": 255077162
|
1292
|
+
},
|
1293
|
+
{
|
1294
|
+
"describe": "<p>Refer to the following object:</p><p>01 const cat = {</p><p>02 firstName: ' Fancy' ,</p><p>03 lastName: ' Whiskers' ,</p><p>04 get fullName( ) {</p><p>05 return this. firstName + ' ' + this.lastName ;</p><p>06 }</p><p>07 };</p><p>How can a developer access the fullName property for cat?</p><p></p>",
|
1295
|
+
"answerOptions": [
|
1296
|
+
{
|
1297
|
+
"describe": "<p>cat.fullName</p>",
|
1298
|
+
"isRight": true
|
1299
|
+
},
|
1300
|
+
{
|
1301
|
+
"describe": "<p>cat.get.fullName</p>",
|
1302
|
+
"isRight": false
|
1303
|
+
},
|
1304
|
+
{
|
1305
|
+
"describe": "<p>cat.fullName( )</p>",
|
1306
|
+
"isRight": false
|
1307
|
+
},
|
1308
|
+
{
|
1309
|
+
"describe": "<p>cat.function.fullName( )</p>",
|
1310
|
+
"isRight": false
|
1311
|
+
}
|
1312
|
+
],
|
1313
|
+
"analysis": "<p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get</p>",
|
1314
|
+
"hashCode": 206805179
|
1315
|
+
},
|
1316
|
+
{
|
1317
|
+
"describe": "<p>Cloud Kicks has a class to represent items for sale in an online store, as shown belows:</p><p>01 class Item {</p><p>02 constructor (name, price) {</p><p>03 this.name = name;</p><p>04 this.price = price;</p><p>05 }</p><p>06</p><p>07 formattedPrice( ) {</p><p>08 return '$' + string (this.price) ;</p><p>09 }</p><p>10 }</p><p>A new business requirement comes in that requests a ClothingItem class, that should have all of the properties and methods of the Item class, but will also have properties that are specific to clothes.Which line of code properly declares the ClothingItem class such that it inherits from Item?</p><p></p>",
|
1318
|
+
"answerOptions": [
|
1319
|
+
{
|
1320
|
+
"describe": "<p>class ClothingItem super Item {</p>",
|
1321
|
+
"isRight": false
|
1322
|
+
},
|
1323
|
+
{
|
1324
|
+
"describe": "<p>class ClothingItem implements Item {</p>",
|
1325
|
+
"isRight": false
|
1326
|
+
},
|
1327
|
+
{
|
1328
|
+
"describe": "<p>class ClothingItem extends Item {</p>",
|
1329
|
+
"isRight": true
|
1330
|
+
},
|
1331
|
+
{
|
1332
|
+
"describe": "<p>class ClothingItem {</p>",
|
1333
|
+
"isRight": false
|
1334
|
+
}
|
1335
|
+
],
|
1336
|
+
"analysis": "",
|
1337
|
+
"hashCode": 1529418526
|
1338
|
+
},
|
1339
|
+
{
|
1340
|
+
"describe": "<p>Which JavaScript methods can be used to serialize an object into a string and deserialize a JSON string into an object, respectively?</p><p></p>",
|
1341
|
+
"answerOptions": [
|
1342
|
+
{
|
1343
|
+
"describe": "<p>JSON.serialize and JSON.deserialize</p>",
|
1344
|
+
"isRight": false
|
1345
|
+
},
|
1346
|
+
{
|
1347
|
+
"describe": "<p>JSON.encode and JSON.decode</p>",
|
1348
|
+
"isRight": false
|
1349
|
+
},
|
1350
|
+
{
|
1351
|
+
"describe": "<p>JSON.parse and JSON.deserialize</p>",
|
1352
|
+
"isRight": false
|
1353
|
+
},
|
1354
|
+
{
|
1355
|
+
"describe": "<p>JSON.stringify and JSON.parse</p>",
|
1356
|
+
"isRight": true
|
1357
|
+
}
|
1358
|
+
],
|
1359
|
+
"analysis": "<p>The JSON.parse() method parses a string and returns a JavaScript object.</p><p>The JSON.stringify() method converts a JavaScript object or value to a JSON string</p>",
|
1360
|
+
"hashCode": 497847359
|
1361
|
+
},
|
1362
|
+
{
|
1363
|
+
"describe": "<p>Refer to the code below:</p><p>01 function myFunction(reassign) {</p><p>02 let x = 1;</p><p>03 var y = 1;</p><p>04</p><p>05 if(reassign) {</p><p>06 let x = 2 ;</p><p>07 var y = 2 ;</p><p>08 console.log(x) ;</p><p>09 console.log(y) ;</p><p>10 }</p><p>11</p><p>12 console.log(x) ;</p><p>13 console.log(y) ;</p><p>14 }</p><p>What is displayed when myFunction (true) is called?</p><p></p>",
|
1364
|
+
"answerOptions": [
|
1365
|
+
{
|
1366
|
+
"describe": "<p>2 2 undefined undefined</p>",
|
1367
|
+
"isRight": false
|
1368
|
+
},
|
1369
|
+
{
|
1370
|
+
"describe": "<p>2 2 2 2</p>",
|
1371
|
+
"isRight": false
|
1372
|
+
},
|
1373
|
+
{
|
1374
|
+
"describe": "<p>2 2 1 2</p>",
|
1375
|
+
"isRight": true
|
1376
|
+
},
|
1377
|
+
{
|
1378
|
+
"describe": "<p>2 2 1 1</p>",
|
1379
|
+
"isRight": false
|
1380
|
+
}
|
1381
|
+
],
|
1382
|
+
"analysis": "",
|
1383
|
+
"hashCode": -1111513407
|
1384
|
+
},
|
1385
|
+
{
|
1386
|
+
"describe": "<p>Which two code snippets show working examples of a recursive function? Choose 2 answers</p><p></p>",
|
1387
|
+
"answerOptions": [
|
1388
|
+
{
|
1389
|
+
"describe": "<p>const factorial = numVar => {</p><p>if (numVar < 0) return ;</p><p>if (numVar === 0) return 1 ;</p><p>return numVar * factorial (numVar - 1);</p><p>}</p>",
|
1390
|
+
"isRight": true
|
1391
|
+
},
|
1392
|
+
{
|
1393
|
+
"describe": "<p>let countingDown = function(startNumber) {</p><p>if (startNumber > 0) {</p><p>console.log (startNumber) ;</p><p>return countingDown(startNumber - 1);</p><p>} else {</p><p>return startNumber;</p><p>}</p><p>} ;</p>",
|
1394
|
+
"isRight": true
|
1395
|
+
},
|
1396
|
+
{
|
1397
|
+
"describe": "<p>function factorial (numVar) {</p><p>if (numVar < 0) return;</p><p>if (numVar === 0) return 1;</p><p>return numVar - 1;</p><p>}</p>",
|
1398
|
+
"isRight": false
|
1399
|
+
},
|
1400
|
+
{
|
1401
|
+
"describe": "<p>const sumToTen = numVar => {</p><p>if (numVar < 0)</p><p>return ;</p><p>return sumToTen(numVar + 1);</p><p>} ;</p>",
|
1402
|
+
"isRight": false
|
1403
|
+
}
|
1404
|
+
],
|
1405
|
+
"analysis": "",
|
1406
|
+
"hashCode": 1507102128
|
1407
|
+
},
|
1408
|
+
{
|
1409
|
+
"describe": "<p>Refer to the code below:</p><p>01 x = 3.14 ;</p><p>02</p><p>03 function myFunction( ) {</p><p>04 'use strict' ;</p><p>05 y=x ;</p><p>06 }</p><p>07</p><p>08 z=x ;</p><p>09 myFunction( ) ;</p><p>Considering the implications of 'use strict' on line 04, which three statements describe the execution of the code? Choose 3 answers</p>",
|
1410
|
+
"answerOptions": [
|
1411
|
+
{
|
1412
|
+
"describe": "<p>'use strict' has an effect between line 04 and the end of the file.</p>",
|
1413
|
+
"isRight": false
|
1414
|
+
},
|
1415
|
+
{
|
1416
|
+
"describe": "<p>'use strict' has an effect only on line 05.</p>",
|
1417
|
+
"isRight": true
|
1418
|
+
},
|
1419
|
+
{
|
1420
|
+
"describe": "<p>z is equal to 3.14.</p>",
|
1421
|
+
"isRight": true
|
1422
|
+
},
|
1423
|
+
{
|
1424
|
+
"describe": "<p>'use strict' is hoisted, so it has an effect on all lines.</p>",
|
1425
|
+
"isRight": false
|
1426
|
+
},
|
1427
|
+
{
|
1428
|
+
"describe": "<p>Line 05 throws an error.</p>",
|
1429
|
+
"isRight": true
|
1430
|
+
}
|
1431
|
+
],
|
1432
|
+
"analysis": "<p>To invoke strict mode for an entire script, put the exact statement \"use strict\"; (or 'use strict';) before any other statements.</p><p>to invoke strict mode for a function, put the exact statement \"use strict\"; (or 'use strict';) in the function's body before any other statements.</p><p>check strict mode</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode</p>",
|
1433
|
+
"hashCode": -1960355230
|
1434
|
+
},
|
1435
|
+
{
|
1436
|
+
"describe": "<p>A developer wants to create an object from a function in the browser using the code below.</p><p>01 function Monster( ){ this.name = 'hello' };</p><p>02 const m = Monster( );</p><p>What happens due to the lack of the new keyword on line 02?</p><p></p>",
|
1437
|
+
"answerOptions": [
|
1438
|
+
{
|
1439
|
+
"describe": "<p>The m variable is assigned the correct object but this.name remains undefined.</p>",
|
1440
|
+
"isRight": false
|
1441
|
+
},
|
1442
|
+
{
|
1443
|
+
"describe": "<p>window.name is assigned to 'hello' and the variable m remains undefined.</p>",
|
1444
|
+
"isRight": true
|
1445
|
+
},
|
1446
|
+
{
|
1447
|
+
"describe": "<p>window.m is assigned the correct object.</p>",
|
1448
|
+
"isRight": false
|
1449
|
+
},
|
1450
|
+
{
|
1451
|
+
"describe": "<p>The m variable is assigned the correct object.</p>",
|
1452
|
+
"isRight": false
|
1453
|
+
}
|
1454
|
+
],
|
1455
|
+
"analysis": "<p>without new, it is like calling Monster() function, and at this time, this points to windows object. So it is like assigning a name attribtue to the window object</p>",
|
1456
|
+
"hashCode": 834722722
|
1457
|
+
},
|
1458
|
+
{
|
1459
|
+
"describe": "<p>Refer to the code below:</p><p>01 function Person( ) {</p><p>02 this . firstName = 'John' ;</p><p>03 }</p><p>04</p><p>05 Person. prototype = {</p><p>06 job: x => 'Developer '</p><p>07 } ;</p><p>08</p><p>09 const myFather = new Person( ) ;</p><p>10 const result = myFather . firstName + ' ' + myFather. job( ) ;</p><p>What is the value of result after line 10 executes?</p><p></p>",
|
1460
|
+
"answerOptions": [
|
1461
|
+
{
|
1462
|
+
"describe": "<p>John Developer</p>",
|
1463
|
+
"isRight": true
|
1464
|
+
},
|
1465
|
+
{
|
1466
|
+
"describe": "<p>Error: myFather.job is not a function</p>",
|
1467
|
+
"isRight": false
|
1468
|
+
},
|
1469
|
+
{
|
1470
|
+
"describe": "<p>undefined Developer</p>",
|
1471
|
+
"isRight": false
|
1472
|
+
},
|
1473
|
+
{
|
1474
|
+
"describe": "<p>John undefined</p>",
|
1475
|
+
"isRight": false
|
1476
|
+
}
|
1477
|
+
],
|
1478
|
+
"analysis": "",
|
1479
|
+
"hashCode": -379898079
|
1480
|
+
},
|
1481
|
+
{
|
1482
|
+
"describe": "<p>Refer to the following code block:</p><p>01 let array= [1, 2, 3, 4, 5, 6,7, 8, 9, 10, 11];</p><p>02 let output = 0 ;</p><p>03</p><p>04 for (let num of array) {</p><p>05 if (output > 10) {</p><p>06 break;</p><p>07 }</p><p>08 if (num % 2 == 0) {</p><p>09 continue;</p><p>10 }</p><p>11 output += num;</p><p>12 }</p><p>What is the value of output after the code executes?</p><p></p>",
|
1483
|
+
"answerOptions": [
|
1484
|
+
{
|
1485
|
+
"describe": "<p>25</p>",
|
1486
|
+
"isRight": false
|
1487
|
+
},
|
1488
|
+
{
|
1489
|
+
"describe": "<p>36</p>",
|
1490
|
+
"isRight": false
|
1491
|
+
},
|
1492
|
+
{
|
1493
|
+
"describe": "<p>11</p>",
|
1494
|
+
"isRight": false
|
1495
|
+
},
|
1496
|
+
{
|
1497
|
+
"describe": "<p>16</p>",
|
1498
|
+
"isRight": true
|
1499
|
+
}
|
1500
|
+
],
|
1501
|
+
"analysis": "<p>break will stop current loop, continue will skip to next looping item</p>",
|
1502
|
+
"hashCode": 408011449
|
1503
|
+
},
|
1504
|
+
{
|
1505
|
+
"describe": "<p>Refer to the following code:</p><p>01 class Vehicle {</p><p>02 constructor(plate) {</p><p>03 this. plate = plate;</p><p>04 }</p><p>05 }</p><p>06</p><p>07 class Truck extends Vehicle {</p><p>08 constructor(plate, weight) {</p><p>09 //Missing code</p><p>10 this.weight = weight;</p><p>11 }</p><p>12 displayWieght( ) {</p><p>13 console. log(`The truck ${this.plate} has a weight of ${this.weight} 1b. `);</p><p>14 }</p><p>15 }</p><p>16</p><p>17 let myTruck = new Truck('123AB', 5000);</p><p>18 myTruck. displayweight ( ) ;</p><p>Which statement should be added to line 09 for the code to display 'The truck 123AB has a weight of 5000 lb.'?</p><p></p>",
|
1506
|
+
"answerOptions": [
|
1507
|
+
{
|
1508
|
+
"describe": "<p>this.plate = plate;</p>",
|
1509
|
+
"isRight": false
|
1510
|
+
},
|
1511
|
+
{
|
1512
|
+
"describe": "<p>super (plate);</p>",
|
1513
|
+
"isRight": true
|
1514
|
+
},
|
1515
|
+
{
|
1516
|
+
"describe": "<p>Vehicle.plate = plate;</p>",
|
1517
|
+
"isRight": false
|
1518
|
+
},
|
1519
|
+
{
|
1520
|
+
"describe": "<p>super.plate = plate;</p>",
|
1521
|
+
"isRight": false
|
1522
|
+
}
|
1523
|
+
],
|
1524
|
+
"analysis": "",
|
1525
|
+
"hashCode": 1143599746
|
1526
|
+
},
|
1527
|
+
{
|
1528
|
+
"describe": "<p>A developer has the following array of hourly wages:</p><p>let arr = [8.5, 9.75, 11.25, 7.75, 13.25];</p><p>For workers making less than $10 an hour, their rate should be multiplied by 1.25 and returned in a new array. How should the developer implement the request?</p><p></p>",
|
1529
|
+
"answerOptions": [
|
1530
|
+
{
|
1531
|
+
"describe": "<p>let arr1 = arr.filter((val) => val < 10).map((num) => num * 1.25);</p>",
|
1532
|
+
"isRight": false
|
1533
|
+
},
|
1534
|
+
{
|
1535
|
+
"describe": "<p>let arr1 = arr.mapArray((val) => { val < 10} ).map((num) => {num * 1.25} );</p>",
|
1536
|
+
"isRight": false
|
1537
|
+
},
|
1538
|
+
{
|
1539
|
+
"describe": "<p>let arr1 = arr.map( (num) => { return num * 1.25 } ).filter( (val) =>{ return val < 10} );</p>",
|
1540
|
+
"isRight": false
|
1541
|
+
},
|
1542
|
+
{
|
1543
|
+
"describe": "<p>let arr1 = arr.filterBy( ( val) => val < 10). mapBy ((num) => num * 1.25);</p>",
|
1544
|
+
"isRight": true
|
1545
|
+
}
|
1546
|
+
],
|
1547
|
+
"analysis": "",
|
1548
|
+
"hashCode": 97594328
|
1549
|
+
},
|
1550
|
+
{
|
1551
|
+
"describe": "<p>Refer to the following code:</p><p>01 let obj = {</p><p>02 foo: 1,</p><p>03 bar: 2</p><p>04 }</p><p>05 let output = [ ];</p><p>06</p><p>07 for (let something of obj) {</p><p>08 output.push(something);</p><p>09 }</p><p>10</p><p>11 console.log(output);</p><p>what is the value of output on line 11?</p><p></p>",
|
1552
|
+
"answerOptions": [
|
1553
|
+
{
|
1554
|
+
"describe": "<p>[1, 2]</p>",
|
1555
|
+
"isRight": false
|
1556
|
+
},
|
1557
|
+
{
|
1558
|
+
"describe": "<p>[\"foo\", \"bar\"]</p>",
|
1559
|
+
"isRight": false
|
1560
|
+
},
|
1561
|
+
{
|
1562
|
+
"describe": "<p>[\"foo:1\", \"bar:2\"]</p>",
|
1563
|
+
"isRight": false
|
1564
|
+
},
|
1565
|
+
{
|
1566
|
+
"describe": "<p>An error will occur due to the incorrect usage of the for…of statement on line 07.</p>",
|
1567
|
+
"isRight": true
|
1568
|
+
}
|
1569
|
+
],
|
1570
|
+
"analysis": "",
|
1571
|
+
"hashCode": 371479167
|
1572
|
+
},
|
1573
|
+
{
|
1574
|
+
"describe": "<p>A developer creates a class that represents a news story based on the requirements that a Story should have a body, author, and view count. The code is shown below:</p><p>01 class Story {</p><p>02 //Insert code here</p><p>03 this.body = body;</p><p>04 this.author = author;</p><p>05 this.viewCount = viewCount;</p><p>06 }</p><p>07 }</p><p>Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instance of a Story with the three attributes correctly populated?</p><p></p>",
|
1575
|
+
"answerOptions": [
|
1576
|
+
{
|
1577
|
+
"describe": "<p>function Story (body, author, viewCount) {</p>",
|
1578
|
+
"isRight": false
|
1579
|
+
},
|
1580
|
+
{
|
1581
|
+
"describe": "<p>super (body, author, viewCount) {</p>",
|
1582
|
+
"isRight": false
|
1583
|
+
},
|
1584
|
+
{
|
1585
|
+
"describe": "<p>constructor (body, author, viewCount) {</p>",
|
1586
|
+
"isRight": true
|
1587
|
+
},
|
1588
|
+
{
|
1589
|
+
"describe": "<p>constructor ( ) {</p>",
|
1590
|
+
"isRight": false
|
1591
|
+
}
|
1592
|
+
],
|
1593
|
+
"analysis": "",
|
1594
|
+
"hashCode": 1040595420
|
1595
|
+
},
|
1596
|
+
{
|
1597
|
+
"describe": "<p>Refer to the following code block:</p><p>01 class Animal {</p><p>02 constructor(name) {</p><p>03 this.name = name;</p><p>04 }</p><p>05</p><p>06 makeSound() {</p><p>07 console.log( '${this.name} is making a sound. ');</p><p>08 }</p><p>09 }</p><p>10</p><p>11 class Dog extends Animal {</p><p>12 constructor(name) {</p><p>13 super(name);</p><p>14 this.name = name;</p><p>15 }</p><p>16 makeSound( ) {</p><p>17 console.log('${this.name} is barking.');</p><p>18 }</p><p>19 }</p><p>20</p><p>21 let myDog = new Dog('Puppy');</p><p>22 myDog.makeSound();</p><p>What is the console output?</p><p></p>",
|
1598
|
+
"answerOptions": [
|
1599
|
+
{
|
1600
|
+
"describe": "<p>> Undefined</p>",
|
1601
|
+
"isRight": false
|
1602
|
+
},
|
1603
|
+
{
|
1604
|
+
"describe": "<p>> Puppy is making a sound.</p>",
|
1605
|
+
"isRight": false
|
1606
|
+
},
|
1607
|
+
{
|
1608
|
+
"describe": "<p>> Puppy is barking.</p>",
|
1609
|
+
"isRight": true
|
1610
|
+
},
|
1611
|
+
{
|
1612
|
+
"describe": "<p>> Uncaught ReferenceError</p>",
|
1613
|
+
"isRight": false
|
1614
|
+
}
|
1615
|
+
],
|
1616
|
+
"analysis": "",
|
1617
|
+
"hashCode": -137451209
|
1618
|
+
},
|
1619
|
+
{
|
1620
|
+
"describe": "<p>Which statement parses successfully?</p><p></p>",
|
1621
|
+
"answerOptions": [
|
1622
|
+
{
|
1623
|
+
"describe": "<p>JSON.parse('foo');</p>",
|
1624
|
+
"isRight": false
|
1625
|
+
},
|
1626
|
+
{
|
1627
|
+
"describe": "<p>JSON.parse(\" 'foo' \");</p>",
|
1628
|
+
"isRight": false
|
1629
|
+
},
|
1630
|
+
{
|
1631
|
+
"describe": "<p>JSON.parse(' \"foo\" ');</p>",
|
1632
|
+
"isRight": false
|
1633
|
+
},
|
1634
|
+
{
|
1635
|
+
"describe": "<p>JSON.parse(\"foo\");</p>",
|
1636
|
+
"isRight": true
|
1637
|
+
}
|
1638
|
+
],
|
1639
|
+
"analysis": "",
|
1640
|
+
"hashCode": -1183134338
|
1641
|
+
},
|
1642
|
+
{
|
1643
|
+
"describe": "<p>A developer writes the code below to calculate the factorial of a given number.</p><p>01 function sum(number) {</p><p>02 return number + sum(number -1);</p><p>03 }</p><p>04 sum(3);</p><p>What is the result of executing line 04?</p><p></p>",
|
1644
|
+
"answerOptions": [
|
1645
|
+
{
|
1646
|
+
"describe": "<p>0</p>",
|
1647
|
+
"isRight": false
|
1648
|
+
},
|
1649
|
+
{
|
1650
|
+
"describe": "<p>6</p>",
|
1651
|
+
"isRight": false
|
1652
|
+
},
|
1653
|
+
{
|
1654
|
+
"describe": "<p>Error</p>",
|
1655
|
+
"isRight": true
|
1656
|
+
},
|
1657
|
+
{
|
1658
|
+
"describe": "<p>-Infinity</p>",
|
1659
|
+
"isRight": false
|
1660
|
+
}
|
1661
|
+
],
|
1662
|
+
"analysis": "",
|
1663
|
+
"hashCode": 181674848
|
1664
|
+
},
|
1665
|
+
{
|
1666
|
+
"describe": "<p>myArray, can have one level, two levels, or more levels. Which statement flattens myArray when it can be arbitrarily nested?</p><p></p>",
|
1667
|
+
"answerOptions": [
|
1668
|
+
{
|
1669
|
+
"describe": "<p>myArray.reduce((prev, curr) => prev.concat(curr), [ ]);</p>",
|
1670
|
+
"isRight": false
|
1671
|
+
},
|
1672
|
+
{
|
1673
|
+
"describe": "<p>myArray.join(\",\").split(\".\");</p>",
|
1674
|
+
"isRight": false
|
1675
|
+
},
|
1676
|
+
{
|
1677
|
+
"describe": "<p>myArray.flat(Infinity);</p>",
|
1678
|
+
"isRight": true
|
1679
|
+
},
|
1680
|
+
{
|
1681
|
+
"describe": "<p>[ ].concat(…myArray);</p>",
|
1682
|
+
"isRight": false
|
1683
|
+
}
|
1684
|
+
],
|
1685
|
+
"analysis": "",
|
1686
|
+
"hashCode": -933703618
|
1687
|
+
},
|
1688
|
+
{
|
1689
|
+
"describe": "<p>Refer to the code below:</p><p>01 function Person(firstName, lastName, eyeColor) {</p><p>02 this.firstName = firstName;</p><p>03 this.lastName = lastName;</p><p>04 this.eyeColor = eyeColor;</p><p>05 }</p><p>06 Person.job = 'Developer';</p><p>07</p><p>08 const myFather = new Person('John', 'Doe');</p><p>09 console.log(myFather.job);</p><p>What is the output after the code executes?</p><p></p>",
|
1690
|
+
"answerOptions": [
|
1691
|
+
{
|
1692
|
+
"describe": "<p>ReferenceError: eyeColor is not defined</p>",
|
1693
|
+
"isRight": false
|
1694
|
+
},
|
1695
|
+
{
|
1696
|
+
"describe": "<p>TypeError: invalid assignment to const variable Person</p>",
|
1697
|
+
"isRight": false
|
1698
|
+
},
|
1699
|
+
{
|
1700
|
+
"describe": "<p>undefined</p>",
|
1701
|
+
"isRight": true
|
1702
|
+
},
|
1703
|
+
{
|
1704
|
+
"describe": "<p>Developer</p>",
|
1705
|
+
"isRight": false
|
1706
|
+
}
|
1707
|
+
],
|
1708
|
+
"analysis": "",
|
1709
|
+
"hashCode": 162330172
|
1710
|
+
},
|
1711
|
+
{
|
1712
|
+
"describe": "<p>Refer to the code below:</p><p>flag( ) ;</p><p>function flag( ) {</p><p>console.log('flag') ;</p><p>}</p><p>const anotherFlag = ( ) => {</p><p>console.log( 'another flag') ;</p><p>}</p><p>anotherFlag( );</p><p>What is result of the code block?</p><p></p>",
|
1713
|
+
"answerOptions": [
|
1714
|
+
{
|
1715
|
+
"describe": "<p>An error is thrown.</p>",
|
1716
|
+
"isRight": false
|
1717
|
+
},
|
1718
|
+
{
|
1719
|
+
"describe": "<p>The console logs only 'flag'.</p>",
|
1720
|
+
"isRight": false
|
1721
|
+
},
|
1722
|
+
{
|
1723
|
+
"describe": "<p>The console logs 'flag' and 'another flag'.</p>",
|
1724
|
+
"isRight": true
|
1725
|
+
},
|
1726
|
+
{
|
1727
|
+
"describe": "<p>The console logs 'flag' and then an error is thrown.</p>",
|
1728
|
+
"isRight": false
|
1729
|
+
}
|
1730
|
+
],
|
1731
|
+
"analysis": "",
|
1732
|
+
"hashCode": 1425998350
|
1733
|
+
},
|
1734
|
+
{
|
1735
|
+
"describe": "<p>A developer copied a JavaScript object:</p><p>01 function Person() {</p><p>02 this.firstName = \"John\";</p><p>03 this.lastName = \"Doe\";</p><p>04 this.name = () => '${this.firstName}, ${this.lastName}';</p><p>05 }</p><p>06</p><p>07 const john = new Person();</p><p>08 const dan = Object.assign(john);</p><p>09 dan.firstName = 'Dan';</p><p>How does the developer access dan's firstName.lastName? Choose 2 answers</p><p></p>",
|
1736
|
+
"answerOptions": [
|
1737
|
+
{
|
1738
|
+
"describe": "<p>dan.name</p>",
|
1739
|
+
"isRight": false
|
1740
|
+
},
|
1741
|
+
{
|
1742
|
+
"describe": "<p>dan.name()</p>",
|
1743
|
+
"isRight": true
|
1744
|
+
},
|
1745
|
+
{
|
1746
|
+
"describe": "<p>dan.firstName + dan.lastName</p>",
|
1747
|
+
"isRight": true
|
1748
|
+
},
|
1749
|
+
{
|
1750
|
+
"describe": "<p>dan.firstName() + dan.lastName()</p>",
|
1751
|
+
"isRight": false
|
1752
|
+
}
|
1753
|
+
],
|
1754
|
+
"analysis": "",
|
1755
|
+
"hashCode": -431743692
|
1756
|
+
}
|
1757
|
+
],
|
1758
|
+
"hashCode": 148683738
|
1759
|
+
}
|