@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.
@@ -0,0 +1,1048 @@
1
+ {
2
+ "title": "[JS]第一章 变量-类型-集合",
3
+ "category": "JS-1",
4
+ "questions": [
5
+ {
6
+ "describe": "<p>Given the code below:</p><p>let numValue - 1982;</p><p>Which three code segments result in a correct conversion from number to string? Choose 3 answer</p>",
7
+ "answerOptions": [
8
+ {
9
+ "describe": "<p>et strValue = numValue.toString();</p>",
10
+ "isRight": true
11
+ },
12
+ {
13
+ "describe": "<p>et strValue = ' ' + numValue;</p>",
14
+ "isRight": true
15
+ },
16
+ {
17
+ "describe": "<p>et strValue = numValue.toText();</p>",
18
+ "isRight": false
19
+ },
20
+ {
21
+ "describe": "<p>et strValue = String(numValue);</p>",
22
+ "isRight": true
23
+ },
24
+ {
25
+ "describe": "<p>et strValue = (String)numValue;</p>",
26
+ "isRight": false
27
+ }
28
+ ],
29
+ "analysis": "",
30
+ "hashCode": -889661771
31
+ },
32
+ {
33
+ "describe": "<p>Refer to the following array:</p><p>let arr = [1,2,3,4,5];</p><p>Which three options result in x evaluating as [1, 2] ? Choose 3 answer</p>",
34
+ "answerOptions": [
35
+ {
36
+ "describe": "<p>et x = arr.slice (2) ;</p>",
37
+ "isRight": false
38
+ },
39
+ {
40
+ "describe": "<p>et x = arr.slice (0, 2) ;</p>",
41
+ "isRight": true
42
+ },
43
+ {
44
+ "describe": "<p>et x = arr.filter((a)=> { return a<=2 });</p>",
45
+ "isRight": true
46
+ },
47
+ {
48
+ "describe": "<p>et x = arr.filter((a) => { a<= 2 });</p>",
49
+ "isRight": false
50
+ },
51
+ {
52
+ "describe": "<p>et x = arr.splice (0, 2) ;</p>",
53
+ "isRight": true
54
+ }
55
+ ],
56
+ "analysis": "",
57
+ "hashCode": -1669364450
58
+ },
59
+ {
60
+ "describe": "<p>Refer to the code below:</p><p>01 let country = {</p><p>02 get capital ( ) {</p><p>03 let city = Number(\"London\");</p><p>04</p><p>05 return {</p><p>06 cityString: city.toString(),</p><p>07 }</p><p>08 }</p><p>09 }</p><p>Which value can a developer expect when referencing country.capital.cityString?</p>",
61
+ "answerOptions": [
62
+ {
63
+ "describe": "<p>An error</p>",
64
+ "isRight": false
65
+ },
66
+ {
67
+ "describe": "<p>'NaN'</p>",
68
+ "isRight": true
69
+ },
70
+ {
71
+ "describe": "<p>undefined</p>",
72
+ "isRight": false
73
+ },
74
+ {
75
+ "describe": "<p>'London'</p>",
76
+ "isRight": false
77
+ }
78
+ ],
79
+ "analysis": "",
80
+ "hashCode": 1267593409
81
+ },
82
+ {
83
+ "describe": "<p>Refer to the code below:</p><p>01 const monthName = 'July';</p><p>02 const year = 2019;</p><p>03 if (monthName === 'July') {</p><p>04 year = 2020;</p><p>05 }</p><p>A developer receives feedback from the Tech Lead that the code gives an error.</p><p>Which line edit should the developer make so this code runs?</p>",
84
+ "answerOptions": [
85
+ {
86
+ "describe": "<p>03 if (monthName === July) {</p>",
87
+ "isRight": false
88
+ },
89
+ {
90
+ "describe": "<p>02 const year = '2019';</p>",
91
+ "isRight": false
92
+ },
93
+ {
94
+ "describe": "<p>02 let year = 2019;</p>",
95
+ "isRight": true
96
+ },
97
+ {
98
+ "describe": "<p>03 if (monthName == July) {</p>",
99
+ "isRight": false
100
+ }
101
+ ],
102
+ "analysis": "",
103
+ "hashCode": 1806192484
104
+ },
105
+ {
106
+ "describe": "<p>A developer uses the code below to format a date.</p><p>01 const date = new Date(2020, 11, 10);</p><p>02 const dateDisplayOptions = {</p><p>03 year: 'numeric',</p><p>04 month: 'long',</p><p>05 day: 'numeric'</p><p>06 };</p><p>07</p><p>08 const formattedDate = date.toLocaleDateString('en', dateDisplayOptions);</p><p>After executing, what is the value of formattedDate?</p>",
107
+ "answerOptions": [
108
+ {
109
+ "describe": "<p>December 10, 2020</p>",
110
+ "isRight": true
111
+ },
112
+ {
113
+ "describe": "<p>November 11, 2020</p>",
114
+ "isRight": false
115
+ },
116
+ {
117
+ "describe": "<p>October 11, 2020</p>",
118
+ "isRight": false
119
+ },
120
+ {
121
+ "describe": "<p>November 10, 2020</p>",
122
+ "isRight": false
123
+ }
124
+ ],
125
+ "analysis": "",
126
+ "hashCode": 152162165
127
+ },
128
+ {
129
+ "describe": "<p>Refer to the code below:</p><p>01 let foodMenul = ['Pizza', 'Burger', 'French fries'];</p><p>02 let finalMenu = foodMenul;</p><p>03 finalMenu.push('Garlic bread');</p><p>What is the value of foodMenul after the code executes?</p>",
130
+ "answerOptions": [
131
+ {
132
+ "describe": "<p>['Garlic bread', 'Pizza', 'Burger', 'French fries']</p>",
133
+ "isRight": false
134
+ },
135
+ {
136
+ "describe": "<p>['Garlic bread']</p>",
137
+ "isRight": false
138
+ },
139
+ {
140
+ "describe": "<p>['Pizza', 'Burger', 'French fries', 'Garlic bread']</p>",
141
+ "isRight": true
142
+ },
143
+ {
144
+ "describe": "<p>['Pizza', 'Burger', 'French fries']</p>",
145
+ "isRight": false
146
+ }
147
+ ],
148
+ "analysis": "",
149
+ "hashCode": 239200901
150
+ },
151
+ {
152
+ "describe": "<p>Considering type coercion, what does the following expression evaluate to?</p><p>true + 3 + '100' + null</p>",
153
+ "answerOptions": [
154
+ {
155
+ "describe": "<p>'3100null'</p>",
156
+ "isRight": false
157
+ },
158
+ {
159
+ "describe": "<p>104</p>",
160
+ "isRight": false
161
+ },
162
+ {
163
+ "describe": "<p>4100</p>",
164
+ "isRight": false
165
+ },
166
+ {
167
+ "describe": "<p>'4100null'</p>",
168
+ "isRight": true
169
+ }
170
+ ],
171
+ "analysis": "",
172
+ "hashCode": -1048268711
173
+ },
174
+ {
175
+ "describe": "<p>Given two expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions and ensure it is data type string? Choose 2 answers</p>",
176
+ "answerOptions": [
177
+ {
178
+ "describe": "<p>String.concat(var1 + var2)</p>",
179
+ "isRight": true
180
+ },
181
+ {
182
+ "describe": "<p>String(var1).concat(var2)</p>",
183
+ "isRight": false
184
+ },
185
+ {
186
+ "describe": "<p>var1.toString() + var2.toString()</p>",
187
+ "isRight": true
188
+ },
189
+ {
190
+ "describe": "<p>var1 + var2</p>",
191
+ "isRight": false
192
+ }
193
+ ],
194
+ "analysis": "",
195
+ "hashCode": -739401847
196
+ },
197
+ {
198
+ "describe": "<p>Refer to the code snippet below:</p><p>01 let array = [1, 2, 3, 4, 4, 5, 4, 4];</p><p>02 for (let i = 0 ; i< array.length; i++) {</p><p>03 if (array[i] === 4) {</p><p>04 array.splice(i, 1) ;</p><p>05 i--;</p><p>06 }</p><p>07 }</p><p>What is the value of array after the code executes?</p>",
199
+ "answerOptions": [
200
+ {
201
+ "describe": "<p>[1, 2, 3, 4, 4, 5, 4]</p>",
202
+ "isRight": false
203
+ },
204
+ {
205
+ "describe": "<p>[1, 2, 3, 4, 5, 4, 4]</p>",
206
+ "isRight": false
207
+ },
208
+ {
209
+ "describe": "<p>[1, 2, 3, 5]</p>",
210
+ "isRight": true
211
+ },
212
+ {
213
+ "describe": "<p>[1, 2, 3, 4, 5, 4]</p>",
214
+ "isRight": false
215
+ }
216
+ ],
217
+ "analysis": "",
218
+ "hashCode": 2110871203
219
+ },
220
+ {
221
+ "describe": "<p>Refer to the code below:</p><p>const pi = 3.1415926;</p><p>What is the data type of pi:</p>",
222
+ "answerOptions": [
223
+ {
224
+ "describe": "<p>Float</p>",
225
+ "isRight": false
226
+ },
227
+ {
228
+ "describe": "<p>Decimal</p>",
229
+ "isRight": false
230
+ },
231
+ {
232
+ "describe": "<p>Double</p>",
233
+ "isRight": false
234
+ },
235
+ {
236
+ "describe": "<p>Number</p>",
237
+ "isRight": true
238
+ }
239
+ ],
240
+ "analysis": "<p>JavaScript has only one type of numbers.</p>",
241
+ "hashCode": 1533642448
242
+ },
243
+ {
244
+ "describe": "<p>A developer has the following array of student test grades:</p><p>let arr = [7,8,5,8,9];</p><p>The teacher wants to double each score and then see an array of the students who scored more than 15 points.</p><p>How should the developer implement the request?</p>",
245
+ "answerOptions": [
246
+ {
247
+ "describe": "<p>let arr1 = arr.map( ( num ) => num * 2 ).filter ( (val ) => val > 15);</p>",
248
+ "isRight": true
249
+ },
250
+ {
251
+ "describe": "<p>let arr1 = arr.mapBy( (num ) => {return num * 2 } ).filterBy ( (val ) => {return val > 15 });</p>",
252
+ "isRight": false
253
+ },
254
+ {
255
+ "describe": "<p>let arr1 = arr.map ( (num) => {num * 2}).filterBy((val) => {val >15});</p>",
256
+ "isRight": false
257
+ },
258
+ {
259
+ "describe": "<p>let arr1 = arr.filter((val) => { return val > 15} ).map((num) => { return num * 2});</p>",
260
+ "isRight": false
261
+ }
262
+ ],
263
+ "analysis": "<p>Need to do double logic in the map first. Then do filter logic.</p>",
264
+ "hashCode": 612263382
265
+ },
266
+ {
267
+ "describe": "<p>Refer to the following array:</p><p>let arr = [1,2,3,4,5];</p><p>Which three options result in x evaluating as [3, 4, 5] ? Choose 3 answer</p>",
268
+ "answerOptions": [
269
+ {
270
+ "describe": "<p>let x = arr.filter((a)=> { return a>2 });</p>",
271
+ "isRight": true
272
+ },
273
+ {
274
+ "describe": "<p>let x = arr.slice (2, 3) ;</p>",
275
+ "isRight": false
276
+ },
277
+ {
278
+ "describe": "<p>let x = arr.splice (2, 3) ;</p>",
279
+ "isRight": true
280
+ },
281
+ {
282
+ "describe": "<p>let x = arr.filter((a) => { a< 2 });</p>",
283
+ "isRight": false
284
+ },
285
+ {
286
+ "describe": "<p>let x = arr.slice (2) ;</p>",
287
+ "isRight": true
288
+ }
289
+ ],
290
+ "analysis": "<p>The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.</p><p>The filter() method creates a new array with all elements that pass the test implemented by the provided function.</p><p>The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.</p>",
291
+ "hashCode": -67871647
292
+ },
293
+ {
294
+ "describe": "<p>Refer to the code below:</p><p>const searchText = 'Yay! Salesforce is amazing!' ;</p><p>let result1 = searchText.search(/sales/i) ;</p><p>let result2 = searchText. search(/sales/) ;</p><p>console.log(result1) ;</p><p>console.log(result2) ;</p><p>After running this code, which result is displayed on the console?</p>",
295
+ "answerOptions": [
296
+ {
297
+ "describe": "<p>>5 > undefined</p>",
298
+ "isRight": false
299
+ },
300
+ {
301
+ "describe": "<p>> true > false</p>",
302
+ "isRight": false
303
+ },
304
+ {
305
+ "describe": "<p>>5 >0</p>",
306
+ "isRight": false
307
+ },
308
+ {
309
+ "describe": "<p>>5 >-1</p>",
310
+ "isRight": true
311
+ }
312
+ ],
313
+ "analysis": "",
314
+ "hashCode": -845744855
315
+ },
316
+ {
317
+ "describe": "<p>Given the following code:</p><p>01 let X = null;</p><p>02 console.log(typeof x);</p><p>What is the output of line 02?</p>",
318
+ "answerOptions": [
319
+ {
320
+ "describe": "<p>null</p>",
321
+ "isRight": false
322
+ },
323
+ {
324
+ "describe": "<p>x</p>",
325
+ "isRight": false
326
+ },
327
+ {
328
+ "describe": "<p>object</p>",
329
+ "isRight": true
330
+ },
331
+ {
332
+ "describe": "<p>Undefined</p>",
333
+ "isRight": false
334
+ }
335
+ ],
336
+ "analysis": "",
337
+ "hashCode": 324311953
338
+ },
339
+ {
340
+ "describe": "<p>Refer to the code below:</p><p>let textValue = '1984' ;</p><p>Which code segment shows a correct way to convert this string to an integer?</p>",
341
+ "answerOptions": [
342
+ {
343
+ "describe": "<p>let numberValue = Number (textValue) ;</p>",
344
+ "isRight": true
345
+ },
346
+ {
347
+ "describe": "<p>let numberValue = Integer (textValue);</p>",
348
+ "isRight": false
349
+ },
350
+ {
351
+ "describe": "<p>let numberValue = textValue. toInteger( );</p>",
352
+ "isRight": false
353
+ },
354
+ {
355
+ "describe": "<p>let numberValue = (Number) textValue;</p>",
356
+ "isRight": false
357
+ }
358
+ ],
359
+ "analysis": "",
360
+ "hashCode": 1329801806
361
+ },
362
+ {
363
+ "describe": "<p>Refer to the code below:</p><p>01 let foodMenu1 = ['Pizza' , 'Burger' , 'French fries'] ;</p><p>02 let finalMenu = foodMenu1 ;</p><p>03 finalMenu.push( 'Garlic bread' ) ;</p><p>What is the value of foodMenu1 after the code executes?</p>",
364
+ "answerOptions": [
365
+ {
366
+ "describe": "<p>['Pizza', 'Burger', 'French fries']</p>",
367
+ "isRight": false
368
+ },
369
+ {
370
+ "describe": "<p>['Garlic bread', 'Pizza', 'Burger', 'French fries']</p>",
371
+ "isRight": false
372
+ },
373
+ {
374
+ "describe": "<p>['Pizza', 'Burger', 'French fries', 'Garlic bread']</p>",
375
+ "isRight": true
376
+ },
377
+ {
378
+ "describe": "<p>['Garlic bread']</p>",
379
+ "isRight": false
380
+ }
381
+ ],
382
+ "analysis": "<p>check array push method:</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push</p>",
383
+ "hashCode": 298808660
384
+ },
385
+ {
386
+ "describe": "<p>Refer to the code below:</p><p>let productSKU = '8675309' ;</p><p>A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with 'sku', and padded with zeros.</p><p>Which statement assigns the value sk000000008675309?</p>",
387
+ "answerOptions": [
388
+ {
389
+ "describe": "<p>productSKU = productSKU.padStart(16, '0').padStart(19, 'sku') ;</p>",
390
+ "isRight": true
391
+ },
392
+ {
393
+ "describe": "<p>productSKU = productSKU.padEnd(16, '0'). padStart('sku') ;</p>",
394
+ "isRight": false
395
+ },
396
+ {
397
+ "describe": "<p>productSKU = productSKU.padEnd(19, '0').padStart('sku') ;</p>",
398
+ "isRight": false
399
+ },
400
+ {
401
+ "describe": "<p>productSKU = productSKU.padEnd(16, '0').padStart(19, 'sku') ;</p>",
402
+ "isRight": false
403
+ }
404
+ ],
405
+ "analysis": "<p>productSKU = productSKU.padEnd(16, '0').padStart(19, 'sku') ; output: \"sku8675309000000000\"</p><p>productSKU = productSKU.padEnd(19, '0').padStart('sku') ; output: \"8675309000000000000\"</p><p>productSKU = productSKU.padEnd(16, '0'). padStart('sku') ; output: \"8675309000000000\"</p>",
406
+ "hashCode": 508991885
407
+ },
408
+ {
409
+ "describe": "<p>Refer to the expression below:</p><p>let x = ('1'+ 2) ==(6*2);</p><p>How should this expression be modified to ensure that x evaluates to false?</p>",
410
+ "answerOptions": [
411
+ {
412
+ "describe": "<p>let x = (1+2) === (6/2);</p>",
413
+ "isRight": false
414
+ },
415
+ {
416
+ "describe": "<p>let x = (1+2) == ('6'/2);</p>",
417
+ "isRight": false
418
+ },
419
+ {
420
+ "describe": "<p>let x = ('1'+'2') == (6*2);</p>",
421
+ "isRight": false
422
+ },
423
+ {
424
+ "describe": "<p>let x = ('1'+2) === (6*2);</p>",
425
+ "isRight": true
426
+ }
427
+ ],
428
+ "analysis": "",
429
+ "hashCode": -582217548
430
+ },
431
+ {
432
+ "describe": "<p>Given the code below, what would be the output in the console?</p><p>let myArray = [1, \"5\", \"eleven\", \"11\" + 17];</p><p>let newArray = myArray.map( function(item){ return item / 2 ; } );</p><p>console.log(newArray);</p><p></p>",
433
+ "answerOptions": [
434
+ {
435
+ "describe": "<p>[0.5, 2.5, 0, 558.5]</p>",
436
+ "isRight": false
437
+ },
438
+ {
439
+ "describe": "<p>[0.5, 2.5, NaN, 14]</p>",
440
+ "isRight": false
441
+ },
442
+ {
443
+ "describe": "<p>[0.5, 2.5, NaN, 558.5]</p>",
444
+ "isRight": true
445
+ },
446
+ {
447
+ "describe": "<p>[0.5, 2.5, undefined, 14]</p>",
448
+ "isRight": false
449
+ }
450
+ ],
451
+ "analysis": "<p>The output will be [0.5, 2.5, NaN, 558.5].</p><p>“eleven” is a string which cannot be divided by any number, resulting in NaN.</p><p>“11” + 17 will not automatically concert “11” to number, instead, it concatenates the number 17 to the “11” string, becoming a new string “1117”. When the string is divided by 2, it is converted to number 1117 automatically, resulting in 558.5.</p>",
452
+ "hashCode": -1523540419
453
+ },
454
+ {
455
+ "describe": "<p>An array is an ordered list of values that you refer to with a name and an index. Which of the following code snippets regarding the array’s method is correct? Choose 3 answers.</p>",
456
+ "answerOptions": [
457
+ {
458
+ "describe": "<p>let myArray = new Array('1', '2', '3');</p><p>myArray = myArray.concat('a', 'b', 'c');</p><p>console.log(myArray); // myArray is [\"1\", \"2\", \"3\", \"a\", \"b\", \"c\"]</p>",
459
+ "isRight": true
460
+ },
461
+ {
462
+ "describe": "<p>let myArray = new Array('1', '2', '3');</p><p>myArray = myArray.join(' - ');</p><p>console.log(myArray); // myArray is \"1 - 2 - 3\"</p>",
463
+ "isRight": true
464
+ },
465
+ {
466
+ "describe": "<p>let myArray = new Array('1', '2', '3', '4', '5');</p><p>myArray.splice(1, 3, 'a', 'b', 'c', 'd');</p><p>console.log(myArray); // myArray is [\"1\", \"a\", \"b\", \"c\", \"d\", \"5\"]</p>",
467
+ "isRight": true
468
+ },
469
+ {
470
+ "describe": "<p>let myArray = new Array('1', '2', '3');</p><p>myArray.unshift('4', '5');</p><p>console.log(myArray); // myArray is [\"1\", \"2\", \"3\", \"4\", \"5\"]</p>",
471
+ "isRight": false
472
+ },
473
+ {
474
+ "describe": "<p>let myArray = new Array('102', '23', '34');</p><p>myArray.reverse();</p><p>console.log(myArray); // myArray is [\"102\", \"34\", \"23\"]</p>",
475
+ "isRight": false
476
+ }
477
+ ],
478
+ "analysis": "<p>reverse() method reverses the element of an array. The first array element becomes the last and the last becomes the first. Do not get confused with reverse sort() method!</p><p>unshift() method adds item(s) to the beginning of the array, not the end. Do not get confused with shift() method which is used to remove an item from the beginning of an array.</p>",
479
+ "hashCode": 739784097
480
+ },
481
+ {
482
+ "describe": "<p>Which of the expressions will be treated as falsy? Choose 3 answers.</p>",
483
+ "answerOptions": [
484
+ {
485
+ "describe": "<p>undefined</p>",
486
+ "isRight": true
487
+ },
488
+ {
489
+ "describe": "<p>[]</p>",
490
+ "isRight": false
491
+ },
492
+ {
493
+ "describe": "<p>0</p>",
494
+ "isRight": true
495
+ },
496
+ {
497
+ "describe": "<p>null</p>",
498
+ "isRight": true
499
+ },
500
+ {
501
+ "describe": "<p>{}</p>",
502
+ "isRight": false
503
+ }
504
+ ],
505
+ "analysis": "<p>The following values will be coerced to false:</p><p>0</p><p>null</p><p>undefined</p><p>NaN</p><p>“” or ” (an empty string)</p><p>false</p><p>These values are referred to as falsy. Any other value of any type is coerced to true, and we call these values as truthy.</p>",
506
+ "hashCode": 1993482165
507
+ },
508
+ {
509
+ "describe": "<p>ECMAScript 2015 introduces a new data structure to map values to values. A Map object is a simple key/value map and can iterate its elements in insertion order. Let’s say the map has been initialized:</p><p>let sayings = new Map();</p><p>Which of the following is a valid operation of Map object?</p><p></p>",
510
+ "answerOptions": [
511
+ {
512
+ "describe": "<p>myMap.get(3, 'three');</p>",
513
+ "isRight": false
514
+ },
515
+ {
516
+ "describe": "<p>myMap.put(0, 'zero');</p>",
517
+ "isRight": false
518
+ },
519
+ {
520
+ "describe": "<p>myMap.set(1, 'one');</p>",
521
+ "isRight": true
522
+ },
523
+ {
524
+ "describe": "<p>myMap.add(2, 'two');</p>",
525
+ "isRight": false
526
+ }
527
+ ],
528
+ "analysis": "<p>myMap.set(1, 'one'); is the correct answer.</p>",
529
+ "hashCode": 1943730319
530
+ },
531
+ {
532
+ "describe": "<p>Given a string “Stringify”, which of the following method will yield a valid substring “gif” in JavaScript? Choose 3 answers.</p>",
533
+ "answerOptions": [
534
+ {
535
+ "describe": "<p>console.log( \"Stringify\".slice(8,5));</p>",
536
+ "isRight": false
537
+ },
538
+ {
539
+ "describe": "<p>console.log( \"Stringify\".substring(8, 5));</p>",
540
+ "isRight": true
541
+ },
542
+ {
543
+ "describe": "<p>console.log( \"Stringify\".substr(5, 8));</p>",
544
+ "isRight": false
545
+ },
546
+ {
547
+ "describe": "<p>console.log( \"Stringify\".substring(5, 8));</p>",
548
+ "isRight": true
549
+ },
550
+ {
551
+ "describe": "<p>console.log( \"Stringify\".slice(5,8));</p>",
552
+ "isRight": true
553
+ }
554
+ ],
555
+ "analysis": "<p>The correct answers are:</p><p>console.log( \"Stringify\".substring(8, 5)); // \"gif\"</p><p>console.log( \"Stringify\".substring(5, 8)); // \"gif\"</p><p>console.log( \"Stringify\".slice(5,8)); // \"gif\"</p><p>console.log( \"Stringify\".substr(5, 8)); returns “gify” because str.substr(start [, length]) returns the part of the string from start, with the given length. Unlike str.substring(start [, end]) which returns the part of the string between start and end.</p><p>console.log( \"Stringify\".slice(8,5)); returns “” (empty string).</p><p>str.substring(start [, end]) does not allow negative values for the indexes. It will be treated as 0 if the value is negative.</p><p>str.slice(start [, end]) allows negative values which means that the position is counted from the string end. For example, console.log( \"Stringify\".slice(-4,-1)); will also return “gif”.</p>",
556
+ "hashCode": 550622132
557
+ },
558
+ {
559
+ "describe": "<p>Which of the following is a valid data type in Javascript? Choose 3 answers.</p>",
560
+ "answerOptions": [
561
+ {
562
+ "describe": "<p>BigInt</p>",
563
+ "isRight": true
564
+ },
565
+ {
566
+ "describe": "<p>The \"null\" value</p>",
567
+ "isRight": true
568
+ },
569
+ {
570
+ "describe": "<p>Text</p>",
571
+ "isRight": false
572
+ },
573
+ {
574
+ "describe": "<p>Object</p>",
575
+ "isRight": true
576
+ },
577
+ {
578
+ "describe": "<p>Date</p>",
579
+ "isRight": false
580
+ }
581
+ ],
582
+ "analysis": "<p>The valid data types are BigInt, Object, and the “null” value.</p><p>There are eight basic data types in JavaScript (source from javascript.info):</p><p>String</p><p>Number</p><p>BigInt</p><p>Boolean</p><p>null</p><p>undefined</p><p>Object</p><p>Symbol</p>",
583
+ "hashCode": 2031695947
584
+ },
585
+ {
586
+ "describe": "<p>While of the following statements regarding primitive number type is correct? Choose 3 answers.</p><p></p>",
587
+ "answerOptions": [
588
+ {
589
+ "describe": "<p>0 is represented as both -0 and +0 (0 is an alias for +0).</p>",
590
+ "isRight": true
591
+ },
592
+ {
593
+ "describe": "<p>The number type is a double-precision 64-bit binary format value which supports ranges from -(2^53 − 1) and 2^53 − 1).</p>",
594
+ "isRight": true
595
+ },
596
+ {
597
+ "describe": "<p>The number type has three symbolic values: +Infinity, -Infinity, and NaN (\"Not a Number\").</p>",
598
+ "isRight": true
599
+ },
600
+ {
601
+ "describe": "<p>If you divide a number by negative zero, you will end up with a value of NaN (\"Not a Number\").</p>",
602
+ "isRight": false
603
+ }
604
+ ],
605
+ "analysis": "<p>If you divide a number by negative zero, you will end up with a value of -Infinity. For example: 42 / -0 = -Infinity</p><p>The rest of the statements are correct.</p>",
606
+ "hashCode": 985298809
607
+ },
608
+ {
609
+ "describe": "<p>Strings are useful for holding data that can be represented in text form. What are the correct ways of assigning String variables? Choose 2 answers.</p><p></p>",
610
+ "answerOptions": [
611
+ {
612
+ "describe": "<p>const str = `string primitive`;</p>",
613
+ "isRight": true
614
+ },
615
+ {
616
+ "describe": "<p>const str = new StringBuilder('string object');</p>",
617
+ "isRight": false
618
+ },
619
+ {
620
+ "describe": "<p>const str = new String['string object'];</p>",
621
+ "isRight": false
622
+ },
623
+ {
624
+ "describe": "<p>const str = new String('string object');</p>",
625
+ "isRight": true
626
+ }
627
+ ],
628
+ "analysis": "<p>String literals can be denoted by double quotes, single quotes, or backtick characters. Hence, const str = `string primitive`; is valid.</p><p>const str = new String('string object'); is the right way of creating a new String object.</p><p>NOTE: If possible, avoid creating strings as objects as it will slow down the execution speed.</p>",
629
+ "hashCode": -1020974899
630
+ },
631
+ {
632
+ "describe": "<p>Which of the following is JavaScript framework? Choose 3 answers.</p>",
633
+ "answerOptions": [
634
+ {
635
+ "describe": "<p>Node.js</p>",
636
+ "isRight": true
637
+ },
638
+ {
639
+ "describe": "<p>Flutter JS</p>",
640
+ "isRight": false
641
+ },
642
+ {
643
+ "describe": "<p>Angular</p>",
644
+ "isRight": true
645
+ },
646
+ {
647
+ "describe": "<p>React</p>",
648
+ "isRight": true
649
+ },
650
+ {
651
+ "describe": "<p>Laravel JS</p>",
652
+ "isRight": false
653
+ }
654
+ ],
655
+ "analysis": "<p>Angular is a JavaScript based open-source front-end web framework mainly maintained by Google.</p><p>React is an open-source Javascript framework for buiding user interface mainly maintained by Facebook.</p><p>Node.js is an open-source, cross-platform, JavaScript runtime environment (framework) that executes JavaScript code outside a web browser.</p><p>There is nothing called “Laravel JS”. However, there is a PHP web application framework called “Laravel” (no JS).</p><p>There is nothing called “Flutter JS”. However, there is an open-source UI software development kit created by Google, which is called “Flutter” (no JS).</p>",
656
+ "hashCode": -195928783
657
+ },
658
+ {
659
+ "describe": "<p>Implicit type coercion can be very confusing sometimes. Which of the following comparisons will yield the true Boolean value? Choose 3 answers.</p>",
660
+ "answerOptions": [
661
+ {
662
+ "describe": "<p>false == \"0\"</p>",
663
+ "isRight": true
664
+ },
665
+ {
666
+ "describe": "<p>false === \"\"</p>",
667
+ "isRight": false
668
+ },
669
+ {
670
+ "describe": "<p>\"\" == \"0\"</p>",
671
+ "isRight": false
672
+ },
673
+ {
674
+ "describe": "<p>false == \"\"</p>",
675
+ "isRight": true
676
+ },
677
+ {
678
+ "describe": "<p>[0] == 0</p>",
679
+ "isRight": true
680
+ }
681
+ ],
682
+ "analysis": "<p>The Boolean comparison results are displayed as below:</p><p>[0] == 0; // true</p><p>false == \"\"; // true</p><p>false == \"0\"; // true</p><p>\"\" == \"0\"; // false</p><p>false === \"\"; // false</p><p>For Boolean comparison the best practice is to use === and !==. With these operators, primitive types are only equivalent when both type and value match, and object comparisons are only true when their respective pointers are pointing to the same memory address. For example:</p><p>false === \"\"; // false</p><p>false === \"0\"; // false</p><p>\"\" === \"0\"; // false</p><p>[0] === 0; // false</p>",
683
+ "hashCode": 338556065
684
+ },
685
+ {
686
+ "describe": "<p>Which of the following is the correct way of assigning variables? Choose 3 answers.</p>",
687
+ "answerOptions": [
688
+ {
689
+ "describe": "<p>var strLang = javascript;</p>",
690
+ "isRight": false
691
+ },
692
+ {
693
+ "describe": "<p>var const strLang = 'javascript';</p>",
694
+ "isRight": false
695
+ },
696
+ {
697
+ "describe": "<p>let strLang = \"javascript\";</p>",
698
+ "isRight": true
699
+ },
700
+ {
701
+ "describe": "<p>const strLang = 'javascript';</p>",
702
+ "isRight": true
703
+ },
704
+ {
705
+ "describe": "<p>let strLang = 'javascript';</p>",
706
+ "isRight": true
707
+ }
708
+ ],
709
+ "analysis": "<p>The following code syntaxes are correct:</p><p>let strLang = 'javascript';</p><p>let strLang = \"javascript\";</p><p>const strLang = 'javascript';</p><p>The var strLang = javascript; is incorrect because the javascript text is missing the quote symbol wrapping around the text.</p><p>There is no var const in Javascript. You will receive an error of Unexpected keyword ‘const’ in the console if you do so.</p>",
710
+ "hashCode": -1312946363
711
+ },
712
+ {
713
+ "describe": "<p>Under what circumstance is it acceptable to use implicit type coercion?</p><p></p>",
714
+ "answerOptions": [
715
+ {
716
+ "describe": "<p>Always</p>",
717
+ "isRight": false
718
+ },
719
+ {
720
+ "describe": "<p>To test a \"falsy\" or \"truth\" variable value in an if conditional expression. For instance, if(myVariable){…}</p>",
721
+ "isRight": true
722
+ },
723
+ {
724
+ "describe": "<p>There is never a safe way to use implicit type coercion.</p>",
725
+ "isRight": false
726
+ },
727
+ {
728
+ "describe": "<p>When comparing two non-Boolean values with Boolean operators. For instance, 1 == \"1\"</p>",
729
+ "isRight": false
730
+ }
731
+ ],
732
+ "analysis": "<p>The correct answer is to test whether a variable is “truthy” or “falsy” in a conditional expression. For example:</p><p>if(myVariable) console.log('myVariable is truthy.');</p>",
733
+ "hashCode": 1928633600
734
+ },
735
+ {
736
+ "describe": "<p>Which of the following data type assumptions regarding typeof operator is correct? Choose 3 answers.</p>",
737
+ "answerOptions": [
738
+ {
739
+ "describe": "<p>console.log( typeof [1,2,3,4] ); // returns \"array\"</p>",
740
+ "isRight": false
741
+ },
742
+ {
743
+ "describe": "<p>console.log( typeof function () {} ); // returns \"function\"</p>",
744
+ "isRight": true
745
+ },
746
+ {
747
+ "describe": "<p>console.log( typeof null ); // returns \"object\"</p>",
748
+ "isRight": true
749
+ },
750
+ {
751
+ "describe": "<p>console.log( typeof NaN ); // returns \"undefined\"</p>",
752
+ "isRight": false
753
+ },
754
+ {
755
+ "describe": "<p>console.log( typeof new Date() ); // returns \"object\"</p>",
756
+ "isRight": true
757
+ }
758
+ ],
759
+ "analysis": "<p>Here’s a list of data types of a JavaScript variable:</p><p>typeof \"John\" // returns \"string\"</p><p>typeof 3.14 // returns \"number\"</p><p>typeof NaN // returns \"number\"</p><p>typeof false // returns \"boolean\"</p><p>typeof [1,2,3,4] // returns \"object\"</p><p>typeof {name:'John', age:34} // returns \"object\"</p><p>typeof new Date() // returns \"object\"</p><p>typeof function () {} // returns \"function\"</p><p>typeof myCar // returns \"undefined\"</p><p>typeof null // returns \"object\"</p>",
760
+ "hashCode": 2118694244
761
+ },
762
+ {
763
+ "describe": "<p>Which of the number type conversion is correct? Choose 3 answers.</p>",
764
+ "answerOptions": [
765
+ {
766
+ "describe": "<p>console.log( Number( \"99 88\" ) ) // returns 9988</p>",
767
+ "isRight": false
768
+ },
769
+ {
770
+ "describe": "<p>console.log( Number( \"\" ) ) // returns 0</p>",
771
+ "isRight": true
772
+ },
773
+ {
774
+ "describe": "<p>console.log( Number( true ) ) // returns 1</p>",
775
+ "isRight": true
776
+ },
777
+ {
778
+ "describe": "<p>console.log( Number( \"5\" + null ) ) // returns NaN</p>",
779
+ "isRight": true
780
+ },
781
+ {
782
+ "describe": "<p>console.log( Number( new Date() ) ) // returns Thu Jul 17 2014 15:38:19 GMT+0200</p>",
783
+ "isRight": false
784
+ }
785
+ ],
786
+ "analysis": "<p>Number(\"99 88\") will return NaN because the string contains a space in between the numbers which cannot be automatically converted to a number.</p><p>Number( new Date() ) will return system timestamp like 1594620083661, not the human-readable date format.</p>",
787
+ "hashCode": 942113396
788
+ },
789
+ {
790
+ "describe": "<p>Refer to the code snippet below:</p><p>01 let array = [1, 2, 3, 4, 4, 5, 4, 4];</p><p>02 for (let i = 0 ; i< array.length; i++) {</p><p>03 if (array[i] === 4) {</p><p>04 array.splice(i, 1) ;</p><p>05 }</p><p>06 }</p><p>What is the value of array after the code executes?</p><p></p>",
791
+ "answerOptions": [
792
+ {
793
+ "describe": "<p>[1, 2, 3, 4, 4, 5, 4]</p>",
794
+ "isRight": false
795
+ },
796
+ {
797
+ "describe": "<p>[1, 2, 3, 4, 5, 4, 4]</p>",
798
+ "isRight": false
799
+ },
800
+ {
801
+ "describe": "<p>[1, 2, 3, 5]</p>",
802
+ "isRight": false
803
+ },
804
+ {
805
+ "describe": "<p>[1, 2, 3, 4, 5, 4]</p>",
806
+ "isRight": true
807
+ }
808
+ ],
809
+ "analysis": "<p>The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice</p>",
810
+ "hashCode": 1798605178
811
+ },
812
+ {
813
+ "describe": "<p>Refer to the code below:</p><p>01 let a = 'a';</p><p>02 let b;</p><p>03 // b = a;</p><p>04 console.log (b) ;</p><p>What is displayed when the code executes?</p><p></p>",
814
+ "answerOptions": [
815
+ {
816
+ "describe": "<p>ReferenceError: b is not defined</p>",
817
+ "isRight": false
818
+ },
819
+ {
820
+ "describe": "<p>a</p>",
821
+ "isRight": false
822
+ },
823
+ {
824
+ "describe": "<p>null</p>",
825
+ "isRight": false
826
+ },
827
+ {
828
+ "describe": "<p>Undefined</p>",
829
+ "isRight": true
830
+ }
831
+ ],
832
+ "analysis": "",
833
+ "hashCode": -1726967701
834
+ },
835
+ {
836
+ "describe": "<p>Given a value, which two options can a developer use to detect if the value is NaN?Choose 2 answers</p><p></p>",
837
+ "answerOptions": [
838
+ {
839
+ "describe": "<p>value == NaN</p>",
840
+ "isRight": true
841
+ },
842
+ {
843
+ "describe": "<p>Object.is(value, NaN)</p>",
844
+ "isRight": false
845
+ },
846
+ {
847
+ "describe": "<p>value === Number. NaN</p>",
848
+ "isRight": false
849
+ },
850
+ {
851
+ "describe": "<p>isNaN(value)</p>",
852
+ "isRight": true
853
+ }
854
+ ],
855
+ "analysis": "<p>The isNaN() function determines whether a value is NaN or not</p>",
856
+ "hashCode": 576060705
857
+ },
858
+ {
859
+ "describe": "<p>Refer to the following code:</p><p>let sampleText = 'The quick brown fox jumps ' ;</p><p>A developer needs to determine if a certain substring is part of a string.</p><p>Which three expressions return true for the given substring? Choose 3 answers</p>",
860
+ "answerOptions": [
861
+ {
862
+ "describe": "<p>sampleText. includes('fox') ;</p>",
863
+ "isRight": true
864
+ },
865
+ {
866
+ "describe": "<p>sampleText. includes('fox', 3) ;</p>",
867
+ "isRight": true
868
+ },
869
+ {
870
+ "describe": "<p>sampleText. includes('quick', 4) ;</p>",
871
+ "isRight": true
872
+ },
873
+ {
874
+ "describe": "<p>sampleText. substring('fox') ;</p>",
875
+ "isRight": false
876
+ },
877
+ {
878
+ "describe": "<p>sampleText. indexOf('quick' !== -1)</p>",
879
+ "isRight": false
880
+ }
881
+ ],
882
+ "analysis": "",
883
+ "hashCode": -2040295789
884
+ },
885
+ {
886
+ "describe": "<p>Given two expressions var1 and var2, what are two valid ways to return the logical AND of the two expressions and ensure it is data type Boolean? Choose 2 answers</p><p></p>",
887
+ "answerOptions": [
888
+ {
889
+ "describe": "<p>Boolean(var1) && Boolean(var2)</p>",
890
+ "isRight": true
891
+ },
892
+ {
893
+ "describe": "<p>var1 && var2</p>",
894
+ "isRight": false
895
+ },
896
+ {
897
+ "describe": "<p>var1.toBoolean( ) && var2. toBoolean ( )</p>",
898
+ "isRight": false
899
+ },
900
+ {
901
+ "describe": "<p>Boolean(var1 && var2)</p>",
902
+ "isRight": true
903
+ }
904
+ ],
905
+ "analysis": "<p>var1 && var2 output 2</p>",
906
+ "hashCode": 1061090132
907
+ },
908
+ {
909
+ "describe": "<p>Refer to the code below.</p><p>01 let str = 'javascript' ;</p><p>02 str[0] = 'J' ;</p><p>03 str[4] = 'S' ;</p><p>After changing the string index values, the value of str is 'javascript'. What is the reason for this value?</p><p></p>",
910
+ "answerOptions": [
911
+ {
912
+ "describe": "<p>Non-primitive values are immutable.</p>",
913
+ "isRight": false
914
+ },
915
+ {
916
+ "describe": "<p>Non-primitive values are mutable.</p>",
917
+ "isRight": false
918
+ },
919
+ {
920
+ "describe": "<p>Primitive values are mutable.</p>",
921
+ "isRight": false
922
+ },
923
+ {
924
+ "describe": "<p>Primitive values are immutable.</p>",
925
+ "isRight": true
926
+ }
927
+ ],
928
+ "analysis": "<p>https://developer.mozilla.org/en-US/docs/Glossary/Mutable#:~:text=In%20JavaScript%2C%20only%20objects%20and,is%20still%20held%20in%20memory.&text=Immutables%20are%20the%20objects%20whose,Strings%20and%20Numbers%20are%20Immutable.</p>",
929
+ "hashCode": 1724487884
930
+ },
931
+ {
932
+ "describe": "<p>Given the code below:</p><p>const copy = JSON. stringify( [new String('false'), new Boolean(false) , undefined]);</p><p>What is the value of copy?</p><p></p>",
933
+ "answerOptions": [
934
+ {
935
+ "describe": "<p>[\\\"false\\\", { }]\" \"</p>",
936
+ "isRight": false
937
+ },
938
+ {
939
+ "describe": "<p>[false, { }]\" \"</p>",
940
+ "isRight": false
941
+ },
942
+ {
943
+ "describe": "<p>[\\\"false\\\", false, null]\" \"</p>",
944
+ "isRight": true
945
+ },
946
+ {
947
+ "describe": "<p>[\\\"false\\\", false, undefined]\" \"</p>",
948
+ "isRight": false
949
+ }
950
+ ],
951
+ "analysis": "",
952
+ "hashCode": 411571118
953
+ },
954
+ {
955
+ "describe": "<p>Refer to the following array:</p><p>let arr1= [1,2,3,4,5];</p><p>Which two lines of code result in a second array, arr2, being created such that arr2 is not a reference to arr1? Choose 2 answers</p><p></p>",
956
+ "answerOptions": [
957
+ {
958
+ "describe": "<p>let arr2 = arr1.slice(0, 5) ;</p>",
959
+ "isRight": true
960
+ },
961
+ {
962
+ "describe": "<p>let arr2 = arr1 ;</p>",
963
+ "isRight": false
964
+ },
965
+ {
966
+ "describe": "<p>let arr2 = Array.from(arr1) ;</p>",
967
+ "isRight": true
968
+ },
969
+ {
970
+ "describe": "<p>let arr2 = arr1.sort( ) ;</p>",
971
+ "isRight": false
972
+ }
973
+ ],
974
+ "analysis": "<p>The slice() method returns a shallow copy of a portion of an array into a new array object</p><p>The Array.from() method returns an Array object from any object with a length property or an iterable object.</p><p>let arr2 = arr1 ; and let arr2 = arr1.sort( ) ; both have same reference to the original array</p>",
975
+ "hashCode": -285824208
976
+ },
977
+ {
978
+ "describe": "<p>Refer to the code below:</p><p>let inArray = [ [1,2] , [3,4,5] ];</p><p>Which two statements result in the array [ 1, 2, 3, 4, 5 ] ? Choose 2 answers</p><p></p>",
979
+ "answerOptions": [
980
+ {
981
+ "describe": "<p>[ ] . concat(...inArray) ;</p>",
982
+ "isRight": true
983
+ },
984
+ {
985
+ "describe": "<p>[ ] . concat.apply (inArray, [ ]) ;</p>",
986
+ "isRight": false
987
+ },
988
+ {
989
+ "describe": "<p>[ ] . concat.apply([ ], inArray) ;</p>",
990
+ "isRight": true
991
+ },
992
+ {
993
+ "describe": "<p>[ ] . concat([...inArray]) ;</p>",
994
+ "isRight": false
995
+ }
996
+ ],
997
+ "analysis": "<p>check spread operator</p><p>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax</p><p>The concat() method is used to merge two or more arrays.</p><p>Apply() method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply</p>",
998
+ "hashCode": -1942165035
999
+ },
1000
+ {
1001
+ "describe": "<p>Which two console logs output NaN? Choose 2 answers</p><p></p>",
1002
+ "answerOptions": [
1003
+ {
1004
+ "describe": "<p>console.log(10 / 'five') ;</p>",
1005
+ "isRight": true
1006
+ },
1007
+ {
1008
+ "describe": "<p>console.log(parseInt('two')) ;</p>",
1009
+ "isRight": true
1010
+ },
1011
+ {
1012
+ "describe": "<p>console.log(10 / Number('5')) ;</p>",
1013
+ "isRight": false
1014
+ },
1015
+ {
1016
+ "describe": "<p>console.log(10 / 0) ;</p>",
1017
+ "isRight": false
1018
+ }
1019
+ ],
1020
+ "analysis": "",
1021
+ "hashCode": 1408757534
1022
+ },
1023
+ {
1024
+ "describe": "<p>Considering type coercion, what does the following expression evaluate to?</p><p>true + '13' + NaN</p><p></p>",
1025
+ "answerOptions": [
1026
+ {
1027
+ "describe": "<p>'113NaN'</p>",
1028
+ "isRight": false
1029
+ },
1030
+ {
1031
+ "describe": "<p>14</p>",
1032
+ "isRight": false
1033
+ },
1034
+ {
1035
+ "describe": "<p>'true13NaN'</p>",
1036
+ "isRight": true
1037
+ },
1038
+ {
1039
+ "describe": "<p>'true13'</p>",
1040
+ "isRight": false
1041
+ }
1042
+ ],
1043
+ "analysis": "",
1044
+ "hashCode": -719271442
1045
+ }
1046
+ ],
1047
+ "hashCode": 665492707
1048
+ }