@palerock/exam-qa 1.0.6-patch18 → 1.0.6-patch19

Sign up to get free protection for your applications and to get access to all the features.
@@ -121,23 +121,23 @@
121
121
  "describe": "<p>Which three options show valid methods for creating a fat arrow function? Choose 3 answer</p>",
122
122
  "answerOptions": [
123
123
  {
124
- "describe": "<p>[ ] => { console.log( 'executed' ); }</p>",
124
+ "describe": "<p>[ ] =&gt; { console.log( 'executed' ); }</p>",
125
125
  "isRight": false
126
126
  },
127
127
  {
128
- "describe": "<p>( ) => { console.log( 'executed' ); }</p>",
128
+ "describe": "<p>( ) =&gt; { console.log( 'executed' ); }</p>",
129
129
  "isRight": true
130
130
  },
131
131
  {
132
- "describe": "<p>( x, y, z ) => { console.log( 'executed' ); }</p>",
132
+ "describe": "<p>( x, y, z ) =&gt; { console.log( 'executed' ); }</p>",
133
133
  "isRight": true
134
134
  },
135
135
  {
136
- "describe": "<p>x, y, z => { console.log( 'executed' ); }</p>",
136
+ "describe": "<p>x, y, z =&gt; { console.log( 'executed' ); }</p>",
137
137
  "isRight": false
138
138
  },
139
139
  {
140
- "describe": "<p>x => { console.log( 'executed' ); }</p>",
140
+ "describe": "<p>x =&gt; { console.log( 'executed' ); }</p>",
141
141
  "isRight": true
142
142
  }
143
143
  ],
@@ -148,19 +148,19 @@
148
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
149
  "answerOptions": [
150
150
  {
151
- "describe": "<p>> Jackie got 70% on test.</p>",
151
+ "describe": "<p>&gt; Jackie got 70% on test.</p>",
152
152
  "isRight": false
153
153
  },
154
154
  {
155
- "describe": "<p>> Better student Jackie got 100% on test.</p>",
155
+ "describe": "<p>&gt; Better student Jackie got 100% on test.</p>",
156
156
  "isRight": true
157
157
  },
158
158
  {
159
- "describe": "<p>> Better student Jackie got 70% on test.</p>",
159
+ "describe": "<p>&gt; Better student Jackie got 70% on test.</p>",
160
160
  "isRight": false
161
161
  },
162
162
  {
163
- "describe": "<p>> Uncaught ReferenceError</p>",
163
+ "describe": "<p>&gt; Uncaught ReferenceError</p>",
164
164
  "isRight": false
165
165
  }
166
166
  ],
@@ -168,10 +168,10 @@
168
168
  "hashCode": 516074974
169
169
  },
170
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>",
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 =&gt;{</p><p>02 return arr.reduce((result, current) =&gt;{</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
172
  "answerOptions": [
173
173
  {
174
- "describe": "<p>Replace line 02 with return arr.map((result, current) =>{</p>",
174
+ "describe": "<p>Replace line 02 with return arr.map((result, current) =&gt;{</p>",
175
175
  "isRight": false
176
176
  },
177
177
  {
@@ -214,7 +214,7 @@
214
214
  "hashCode": -399108392
215
215
  },
216
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>",
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 = () =&gt; {</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
218
  "answerOptions": [
219
219
  {
220
220
  "describe": "<p>Object.assign(leo, tony);</p>",
@@ -225,11 +225,11 @@
225
225
  "isRight": false
226
226
  },
227
227
  {
228
- "describe": "<p>leo.prototype.roar = () => {console.log('They\\'re pretty good!');};</p>",
228
+ "describe": "<p>leo.prototype.roar = () =&gt; {console.log('They\\'re pretty good!');};</p>",
229
229
  "isRight": false
230
230
  },
231
231
  {
232
- "describe": "<p>leo.roar = () => {console.log('They\\'re pretty good!');};</p>",
232
+ "describe": "<p>leo.roar = () =&gt; {console.log('They\\'re pretty good!');};</p>",
233
233
  "isRight": true
234
234
  }
235
235
  ],
@@ -267,7 +267,7 @@
267
267
  "describe": "<p></p>",
268
268
  "answerOptions": [
269
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>",
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 = ( ) =&gt; {</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 = ( ) =&gt; {</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
271
  "isRight": false
272
272
  },
273
273
  {
@@ -402,7 +402,7 @@
402
402
  "hashCode": 1172379641
403
403
  },
404
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>",
405
+ "describe": "<p>Refer to the code below:</p><p>01 const myFunction = arr =&gt; {</p><p>02 return arr. reduce((result, current) =&gt; {</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
406
  "answerOptions": [
407
407
  {
408
408
  "describe": "<p>Returns 10</p>",
@@ -498,7 +498,7 @@
498
498
  "hashCode": -1405888802
499
499
  },
500
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>",
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 = ( ) =&gt; {</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
502
  "answerOptions": [
503
503
  {
504
504
  "describe": "<p>TypeError: Assignment to constant variable</p>",
@@ -521,7 +521,7 @@
521
521
  "hashCode": -1654727508
522
522
  },
523
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>",
524
+ "describe": "<p>Refer to the code below:</p><p>01 console. log(0) ;</p><p>02</p><p>03 setTimeout(( ) =&gt; {</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(( ) =&gt; {</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
525
  "answerOptions": [
526
526
  {
527
527
  "describe": "<p>0 1 2 3 4</p>",
@@ -613,7 +613,7 @@
613
613
  "hashCode": 1902407972
614
614
  },
615
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>",
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>&gt; SNEGeneziz is loading a cartridge game: Super Monic 3x Force. . .</p><p></p>",
617
617
  "answerOptions": [
618
618
  {
619
619
  "describe": "<p>Console16bit.prototype.load = function (gamename) {</p>",
@@ -732,7 +732,7 @@
732
732
  "hashCode": -682085488
733
733
  },
734
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>",
735
+ "describe": "<p>Given the JavaScript below:</p><p>01 function filterDOM (searchString) {</p><p>02 const parsedSearchstring = searchString &amp;&amp; searchString. toLowerCase( ) ;</p><p>03 document . querySelectorAll (' .account') . forEach (account =&gt; {</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
736
  "answerOptions": [
737
737
  {
738
738
  "describe": "<p>'block' : 'none'</p>",
@@ -943,7 +943,7 @@
943
943
  "hashCode": -388162408
944
944
  },
945
945
  {
946
- "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>",
946
+ "describe": "<p>Given the code below:</p><p>let x = 2;</p><p>let y = 3;</p><p>let add = x =&gt; y =&gt; 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>",
947
947
  "answerOptions": [
948
948
  {
949
949
  "describe": "<p>add(x)(y)</p>",
@@ -985,18 +985,18 @@
985
985
  "isRight": true
986
986
  },
987
987
  {
988
- "describe": "<p>objectName->property // person->age</p>",
988
+ "describe": "<p>objectName-&gt;property // person-&gt;age</p>",
989
989
  "isRight": false
990
990
  }
991
991
  ],
992
- "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>",
992
+ "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-&gt;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>",
993
993
  "hashCode": -990895308
994
994
  },
995
995
  {
996
996
  "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>",
997
997
  "answerOptions": [
998
998
  {
999
- "describe": "<p>arr.sort((a, b) => a < b);[/su_highlight]</p>",
999
+ "describe": "<p>arr.sort((a, b) =&gt; a &lt; b);[/su_highlight]</p>",
1000
1000
  "isRight": false
1001
1001
  },
1002
1002
  {
@@ -1004,15 +1004,15 @@
1004
1004
  "isRight": false
1005
1005
  },
1006
1006
  {
1007
- "describe": "<p>arr.sort((a, b) => a – b);</p>",
1007
+ "describe": "<p>arr.sort((a, b) =&gt; a – b);</p>",
1008
1008
  "isRight": true
1009
1009
  },
1010
1010
  {
1011
- "describe": "<p>arr.sort((a, b) => b – a);</p>",
1011
+ "describe": "<p>arr.sort((a, b) =&gt; b – a);</p>",
1012
1012
  "isRight": false
1013
1013
  }
1014
1014
  ],
1015
- "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>",
1015
+ "analysis": "<p>By default, the sort() function sorts values as strings.</p><p>arr.sort( (a, b) =&gt; 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) =&gt; a &lt; 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) =&gt; b – a); is incorrect. The compare function will actually reverse the order of the numbers.</p>",
1016
1016
  "hashCode": 577492143
1017
1017
  },
1018
1018
  {
@@ -1181,7 +1181,7 @@
1181
1181
  "hashCode": -514234380
1182
1182
  },
1183
1183
  {
1184
- "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>",
1184
+ "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) =&gt; {</p><p>02 console.log('Hello ', name) ;</p><p>03 };</p><p>04</p><p>05 const world= ( ) =&gt; {</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>",
1185
1185
  "answerOptions": [
1186
1186
  {
1187
1187
  "describe": "<p>Change line 7 to } ( ) ;</p>",
@@ -1250,7 +1250,7 @@
1250
1250
  "hashCode": 415077733
1251
1251
  },
1252
1252
  {
1253
- "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>",
1253
+ "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 = ( ) =&gt; {</p><p>console.log( 'another flag') ;</p><p>}</p><p>What is result of the code block?</p><p></p>",
1254
1254
  "answerOptions": [
1255
1255
  {
1256
1256
  "describe": "<p>An error is thrown.</p>",
@@ -1414,19 +1414,19 @@
1414
1414
  "describe": "<p>Which two code snippets show working examples of a recursive function? Choose 2 answers</p><p></p>",
1415
1415
  "answerOptions": [
1416
1416
  {
1417
- "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>",
1417
+ "describe": "<p>const factorial = numVar =&gt; {</p><p>if (numVar &lt; 0) return ;</p><p>if (numVar === 0) return 1 ;</p><p>return numVar * factorial (numVar - 1);</p><p>}</p>",
1418
1418
  "isRight": true
1419
1419
  },
1420
1420
  {
1421
- "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>",
1421
+ "describe": "<p>let countingDown = function(startNumber) {</p><p>if (startNumber &gt; 0) {</p><p>console.log (startNumber) ;</p><p>return countingDown(startNumber - 1);</p><p>} else {</p><p>return startNumber;</p><p>}</p><p>} ;</p>",
1422
1422
  "isRight": true
1423
1423
  },
1424
1424
  {
1425
- "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>",
1425
+ "describe": "<p>function factorial (numVar) {</p><p>if (numVar &lt; 0) return;</p><p>if (numVar === 0) return 1;</p><p>return numVar - 1;</p><p>}</p>",
1426
1426
  "isRight": false
1427
1427
  },
1428
1428
  {
1429
- "describe": "<p>const sumToTen = numVar => {</p><p>if (numVar < 0)</p><p>return ;</p><p>return sumToTen(numVar + 1);</p><p>} ;</p>",
1429
+ "describe": "<p>const sumToTen = numVar =&gt; {</p><p>if (numVar &lt; 0)</p><p>return ;</p><p>return sumToTen(numVar + 1);</p><p>} ;</p>",
1430
1430
  "isRight": false
1431
1431
  }
1432
1432
  ],
@@ -1484,7 +1484,7 @@
1484
1484
  "hashCode": 834722722
1485
1485
  },
1486
1486
  {
1487
- "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>",
1487
+ "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 =&gt; '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>",
1488
1488
  "answerOptions": [
1489
1489
  {
1490
1490
  "describe": "<p>John Developer</p>",
@@ -1507,7 +1507,7 @@
1507
1507
  "hashCode": -379898079
1508
1508
  },
1509
1509
  {
1510
- "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>",
1510
+ "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 &gt; 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>",
1511
1511
  "answerOptions": [
1512
1512
  {
1513
1513
  "describe": "<p>25</p>",
@@ -1556,19 +1556,19 @@
1556
1556
  "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>",
1557
1557
  "answerOptions": [
1558
1558
  {
1559
- "describe": "<p>let arr1 = arr.filter((val) => val < 10).map((num) => num * 1.25);</p>",
1559
+ "describe": "<p>let arr1 = arr.filter((val) =&gt; val &lt; 10).map((num) =&gt; num * 1.25);</p>",
1560
1560
  "isRight": false
1561
1561
  },
1562
1562
  {
1563
- "describe": "<p>let arr1 = arr.mapArray((val) => { val < 10} ).map((num) => {num * 1.25} );</p>",
1563
+ "describe": "<p>let arr1 = arr.mapArray((val) =&gt; { val &lt; 10} ).map((num) =&gt; {num * 1.25} );</p>",
1564
1564
  "isRight": false
1565
1565
  },
1566
1566
  {
1567
- "describe": "<p>let arr1 = arr.map( (num) => { return num * 1.25 } ).filter( (val) =>{ return val < 10} );</p>",
1567
+ "describe": "<p>let arr1 = arr.map( (num) =&gt; { return num * 1.25 } ).filter( (val) =&gt;{ return val &lt; 10} );</p>",
1568
1568
  "isRight": false
1569
1569
  },
1570
1570
  {
1571
- "describe": "<p>let arr1 = arr.filterBy( ( val) => val < 10). mapBy ((num) => num * 1.25);</p>",
1571
+ "describe": "<p>let arr1 = arr.filterBy( ( val) =&gt; val &lt; 10). mapBy ((num) =&gt; num * 1.25);</p>",
1572
1572
  "isRight": true
1573
1573
  }
1574
1574
  ],
@@ -1625,19 +1625,19 @@
1625
1625
  "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>",
1626
1626
  "answerOptions": [
1627
1627
  {
1628
- "describe": "<p>> Undefined</p>",
1628
+ "describe": "<p>&gt; Undefined</p>",
1629
1629
  "isRight": false
1630
1630
  },
1631
1631
  {
1632
- "describe": "<p>> Puppy is making a sound.</p>",
1632
+ "describe": "<p>&gt; Puppy is making a sound.</p>",
1633
1633
  "isRight": false
1634
1634
  },
1635
1635
  {
1636
- "describe": "<p>> Puppy is barking.</p>",
1636
+ "describe": "<p>&gt; Puppy is barking.</p>",
1637
1637
  "isRight": true
1638
1638
  },
1639
1639
  {
1640
- "describe": "<p>> Uncaught ReferenceError</p>",
1640
+ "describe": "<p>&gt; Uncaught ReferenceError</p>",
1641
1641
  "isRight": false
1642
1642
  }
1643
1643
  ],
@@ -1694,7 +1694,7 @@
1694
1694
  "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>",
1695
1695
  "answerOptions": [
1696
1696
  {
1697
- "describe": "<p>myArray.reduce((prev, curr) => prev.concat(curr), [ ]);</p>",
1697
+ "describe": "<p>myArray.reduce((prev, curr) =&gt; prev.concat(curr), [ ]);</p>",
1698
1698
  "isRight": false
1699
1699
  },
1700
1700
  {
@@ -1737,7 +1737,7 @@
1737
1737
  "hashCode": 162330172
1738
1738
  },
1739
1739
  {
1740
- "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>",
1740
+ "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 = ( ) =&gt; {</p><p>console.log( 'another flag') ;</p><p>}</p><p>anotherFlag( );</p><p>What is result of the code block?</p><p></p>",
1741
1741
  "answerOptions": [
1742
1742
  {
1743
1743
  "describe": "<p>An error is thrown.</p>",
@@ -1760,7 +1760,7 @@
1760
1760
  "hashCode": 1425998350
1761
1761
  },
1762
1762
  {
1763
- "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>",
1763
+ "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 = () =&gt; '${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>",
1764
1764
  "answerOptions": [
1765
1765
  {
1766
1766
  "describe": "<p>dan.name</p>",
@@ -3,7 +3,7 @@
3
3
  "category": "JS-1",
4
4
  "questions": [
5
5
  {
6
- "describe": "<p>Given the code below:</p><p>const delay = async delay => {</p><p>return new Promise ( ( resolve, reject ) =></p><p>{</p><p>setTimeout ( resolve, delay );</p><p>});</p><p>};</p><p>const callDelay = async ( ) => {</p><p>const yup = await delay(1000);</p><p>console.log(1);</p><p>};</p><p>console.log(2);</p><p>callDelay( );</p><p>console.log(3);</p><p>What is logged to the console?</p>",
6
+ "describe": "<p>Given the code below:</p><p>const delay = async delay =&gt; {</p><p>return new Promise ( ( resolve, reject ) =&gt;</p><p>{</p><p>setTimeout ( resolve, delay );</p><p>});</p><p>};</p><p>const callDelay = async ( ) =&gt; {</p><p>const yup = await delay(1000);</p><p>console.log(1);</p><p>};</p><p>console.log(2);</p><p>callDelay( );</p><p>console.log(3);</p><p>What is logged to the console?</p>",
7
7
  "answerOptions": [
8
8
  {
9
9
  "describe": "<p>1 2 3</p>",
@@ -26,22 +26,22 @@
26
26
  "hashCode": 2050585304
27
27
  },
28
28
  {
29
- "describe": "<p>Refer to the code below:</p><p>01 let requestPromise = client.getRequest;</p><p>02</p><p>03 requestPromise ( ) . then( (response) => {</p><p>04 handleResponse (response) ;</p><p>05 });</p><p>A developer uses a client that makes a GET request that uses a Promise to handle the request.getRequest returns a Promise.Which code modification can the developer make to gracefully handle an error?</p>",
29
+ "describe": "<p>Refer to the code below:</p><p>01 let requestPromise = client.getRequest;</p><p>02</p><p>03 requestPromise ( ) . then( (response) =&gt; {</p><p>04 handleResponse (response) ;</p><p>05 });</p><p>A developer uses a client that makes a GET request that uses a Promise to handle the request.getRequest returns a Promise.Which code modification can the developer make to gracefully handle an error?</p>",
30
30
  "answerOptions": [
31
31
  {
32
- "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 try {</p><p>04 requestPromise( ) .then((response) => {</p><p>05 handleResponse (response) ;</p><p>06 }) .then((error) => {</p><p>07 throw new Error(error.name);</p><p>08 });</p><p>09 } catch(error) {</p><p>10 handleError(error);</p><p>11 }</p>",
32
+ "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 try {</p><p>04 requestPromise( ) .then((response) =&gt; {</p><p>05 handleResponse (response) ;</p><p>06 }) .then((error) =&gt; {</p><p>07 throw new Error(error.name);</p><p>08 });</p><p>09 } catch(error) {</p><p>10 handleError(error);</p><p>11 }</p>",
33
33
  "isRight": false
34
34
  },
35
35
  {
36
- "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 try {</p><p>04 requestPromise( ) .then((response) => {</p><p>05 handleResponse (response) ;</p><p>06 }) ;</p><p>07 } catch(error) {</p><p>08 handleError(error);</p><p>09 }</p>",
36
+ "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 try {</p><p>04 requestPromise( ) .then((response) =&gt; {</p><p>05 handleResponse (response) ;</p><p>06 }) ;</p><p>07 } catch(error) {</p><p>08 handleError(error);</p><p>09 }</p>",
37
37
  "isRight": false
38
38
  },
39
39
  {
40
- "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 requestPromise( ) .then((response) => {</p><p>04 handleResponse (response) ;</p><p>05 }) .catch((error) => {</p><p>06 handleError(error);</p><p>07 });</p>",
40
+ "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 requestPromise( ) .then((response) =&gt; {</p><p>04 handleResponse (response) ;</p><p>05 }) .catch((error) =&gt; {</p><p>06 handleError(error);</p><p>07 });</p>",
41
41
  "isRight": true
42
42
  },
43
43
  {
44
- "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 requestPromise( ) .then((response) => {</p><p>04 handleResponse (response) ;</p><p>05 }) .finally((error) => {</p><p>06 handleError(error);</p><p>07 });</p>",
44
+ "describe": "<p>01 let requestPromise = client. getRequest;</p><p>02</p><p>03 requestPromise( ) .then((response) =&gt; {</p><p>04 handleResponse (response) ;</p><p>05 }) .finally((error) =&gt; {</p><p>06 handleError(error);</p><p>07 });</p>",
45
45
  "isRight": false
46
46
  }
47
47
  ],
@@ -49,7 +49,7 @@
49
49
  "hashCode": -1190035552
50
50
  },
51
51
  {
52
- "describe": "<p>Refer to the code below:</p><p>01 const exec = (item, delay) =></p><p>02 new Promise (resolve => setTimeout(( ) => resolve(item), delay)) ;</p><p>03</p><p>04 async function runParallel( ) {</p><p>05 const [result1, result2, result3] = await Promise.all(</p><p>06 [exec('x', '100'), exec('y', '500'), exec('z' ,'100') ]</p><p>07 );</p><p>08 return `parallel is done: ${result1}$ {}result2}${result3}` ;</p><p>09 }</p><p>Which two statements correctly execute the runParallel ( ) function? Choose 2 answers</p>",
52
+ "describe": "<p>Refer to the code below:</p><p>01 const exec = (item, delay) =&gt;</p><p>02 new Promise (resolve =&gt; setTimeout(( ) =&gt; resolve(item), delay)) ;</p><p>03</p><p>04 async function runParallel( ) {</p><p>05 const [result1, result2, result3] = await Promise.all(</p><p>06 [exec('x', '100'), exec('y', '500'), exec('z' ,'100') ]</p><p>07 );</p><p>08 return `parallel is done: ${result1}$ {}result2}${result3}` ;</p><p>09 }</p><p>Which two statements correctly execute the runParallel ( ) function? Choose 2 answers</p>",
53
53
  "answerOptions": [
54
54
  {
55
55
  "describe": "<p>runParallel( ) .then (function(data) {</p><p>return data;</p><p>});</p>",
@@ -72,7 +72,7 @@
72
72
  "hashCode": -2045125581
73
73
  },
74
74
  {
75
- "describe": "<p>Given the following code:</p><p>01 counter = 0;</p><p>02 const logCounter = ( ) => {</p><p>03 console.log (counter) ;</p><p>04 };</p><p>05 logCounter( ) ;</p><p>06 setTimeout (logCounter, 1100) ;</p><p>07 setInterval(( ) => {</p><p>08 counter++ ;</p><p>09 logCounter( ) ;</p><p>10 }, 1000) ;</p><p>What is logged by the first four log statements?</p>",
75
+ "describe": "<p>Given the following code:</p><p>01 counter = 0;</p><p>02 const logCounter = ( ) =&gt; {</p><p>03 console.log (counter) ;</p><p>04 };</p><p>05 logCounter( ) ;</p><p>06 setTimeout (logCounter, 1100) ;</p><p>07 setInterval(( ) =&gt; {</p><p>08 counter++ ;</p><p>09 logCounter( ) ;</p><p>10 }, 1000) ;</p><p>What is logged by the first four log statements?</p>",
76
76
  "answerOptions": [
77
77
  {
78
78
  "describe": "<p>0 0 1 2</p>",
@@ -144,27 +144,27 @@
144
144
  "describe": "<p>Which of the following code snippets will show alert box? Choose 3 answers.</p>",
145
145
  "answerOptions": [
146
146
  {
147
- "describe": "<p>new Promise((resolve, reject) => {</p><p>throw new Error(\"Whoops!\");</p><p>}).catch(alert);</p>",
147
+ "describe": "<p>new Promise((resolve, reject) =&gt; {</p><p>throw new Error(\"Whoops!\");</p><p>}).catch(alert);</p>",
148
148
  "isRight": true
149
149
  },
150
150
  {
151
- "describe": "<p>new Promise(function(resolve, reject) {</p><p>setTimeout(() => {</p><p>throw new Error(\"Whoops!\");</p><p>}, 1000);</p><p>}).catch(alert);</p>",
151
+ "describe": "<p>new Promise(function(resolve, reject) {</p><p>setTimeout(() =&gt; {</p><p>throw new Error(\"Whoops!\");</p><p>}, 1000);</p><p>}).catch(alert);</p>",
152
152
  "isRight": false
153
153
  },
154
154
  {
155
- "describe": "<p>new Promise((resolve, reject) => {</p><p>resolve(\"ok\");</p><p>}).then((result) => {</p><p>throw new Error(\"Whoops!\");</p><p>}).catch(alert);</p>",
155
+ "describe": "<p>new Promise((resolve, reject) =&gt; {</p><p>resolve(\"ok\");</p><p>}).then((result) =&gt; {</p><p>throw new Error(\"Whoops!\");</p><p>}).catch(alert);</p>",
156
156
  "isRight": true
157
157
  },
158
158
  {
159
- "describe": "<p>new Promise((resolve, reject) => {</p><p>reject(new Error(\"Whoops!\"));</p><p>}).catch(alert);</p>",
159
+ "describe": "<p>new Promise((resolve, reject) =&gt; {</p><p>reject(new Error(\"Whoops!\"));</p><p>}).catch(alert);</p>",
160
160
  "isRight": true
161
161
  }
162
162
  ],
163
- "analysis": "<p>When an exception happens, it gets caught and treated as a rejection.</p><p>new Promise(function(resolve, reject) {</p><p>setTimeout(() => {</p><p>throw new Error(\"Whoops!\");</p><p>}, 1000);</p><p>}).catch(alert); // will not catch error</p><p>Copy</p><p>The code snippet above will not show alert box even though the error is thrown in within Promise code block. Reason being, the error is generated not while the executor is running, but later in another task. Hence, the promise cannot catch the error.</p>",
163
+ "analysis": "<p>When an exception happens, it gets caught and treated as a rejection.</p><p>new Promise(function(resolve, reject) {</p><p>setTimeout(() =&gt; {</p><p>throw new Error(\"Whoops!\");</p><p>}, 1000);</p><p>}).catch(alert); // will not catch error</p><p>Copy</p><p>The code snippet above will not show alert box even though the error is thrown in within Promise code block. Reason being, the error is generated not while the executor is running, but later in another task. Hence, the promise cannot catch the error.</p>",
164
164
  "hashCode": -106788969
165
165
  },
166
166
  {
167
- "describe": "<p>const getId = new Promise((resolve, reject) => {</p><p>setTimeout(() => resolve(15), 1500);</p><p>});</p><p>const getBook = bookId => new Promise((resolve, reject) => {</p><p>setTimeout(() => resolve('${bookId}:JavaScript Algorithms'), 1500);</p><p>});</p><p>getId.then(id => getBook(id)).then(data => data);</p><p>What is the correct code to replace the last line with an async/await function?</p>",
167
+ "describe": "<p>const getId = new Promise((resolve, reject) =&gt; {</p><p>setTimeout(() =&gt; resolve(15), 1500);</p><p>});</p><p>const getBook = bookId =&gt; new Promise((resolve, reject) =&gt; {</p><p>setTimeout(() =&gt; resolve('${bookId}:JavaScript Algorithms'), 1500);</p><p>});</p><p>getId.then(id =&gt; getBook(id)).then(data =&gt; data);</p><p>What is the correct code to replace the last line with an async/await function?</p>",
168
168
  "answerOptions": [
169
169
  {
170
170
  "describe": "<p>async function getBookInfo() {</p><p>const Id = await getId;</p><p>const result = await getBook(id);</p><p>}</p><p>await getBookInfo();</p>",
@@ -187,7 +187,7 @@
187
187
  "hashCode": 1465758323
188
188
  },
189
189
  {
190
- "describe": "<p>Give the code as below:</p><p>let promise = new Promise(function(resolve, reject) {</p><p>resolve(1);</p><p>setTimeout(() => resolve(2), 1000);</p><p>setTimeout(() => resolve(3), 2000);</p><p>});</p><p>promise.then((res) => console.log(res));</p><p>What would be the output of this code?</p>",
190
+ "describe": "<p>Give the code as below:</p><p>let promise = new Promise(function(resolve, reject) {</p><p>resolve(1);</p><p>setTimeout(() =&gt; resolve(2), 1000);</p><p>setTimeout(() =&gt; resolve(3), 2000);</p><p>});</p><p>promise.then((res) =&gt; console.log(res));</p><p>What would be the output of this code?</p>",
191
191
  "answerOptions": [
192
192
  {
193
193
  "describe": "<p>1</p>",
@@ -210,10 +210,10 @@
210
210
  "hashCode": -1047881134
211
211
  },
212
212
  {
213
- "describe": "<p>Refer to this code:</p><p>const p1 = new Promise((resolve, reject) => {</p><p>setTimeout(() => {</p><p>resolve('P1 Resolved');</p><p>}, 1500);</p><p>});</p><p>const p2 = (data) => new Promise((resolve, reject) => {</p><p>setTimeout(() => resolve('${data}, P2 Resolved'), 1500, data);</p><p>});</p><p>Which of the following correctly execute p1 and p2? Choose 2 answers.</p><p></p>",
213
+ "describe": "<p>Refer to this code:</p><p>const p1 = new Promise((resolve, reject) =&gt; {</p><p>setTimeout(() =&gt; {</p><p>resolve('P1 Resolved');</p><p>}, 1500);</p><p>});</p><p>const p2 = (data) =&gt; new Promise((resolve, reject) =&gt; {</p><p>setTimeout(() =&gt; resolve('${data}, P2 Resolved'), 1500, data);</p><p>});</p><p>Which of the following correctly execute p1 and p2? Choose 2 answers.</p><p></p>",
214
214
  "answerOptions": [
215
215
  {
216
- "describe": "<p>p1</p><p>.then((data) => p2(data))</p><p>.then(result => result);</p>",
216
+ "describe": "<p>p1</p><p>.then((data) =&gt; p2(data))</p><p>.then(result =&gt; result);</p>",
217
217
  "isRight": true
218
218
  },
219
219
  {
@@ -229,11 +229,11 @@
229
229
  "isRight": false
230
230
  }
231
231
  ],
232
- "analysis": "<p>p1</p><p>.then((data) => p2(data))</p><p>.then(result => result);</p><p>This is correct. The method promise.then() is used to associate further action with a promise that becomes settled.</p><p>async function getResult() {</p><p>const data = await p1;</p><p>return await p2(data);</p><p>}</p><p>getResult();</p><p>This is correct. Using await inside the function causes both to execute.</p><p>p1().then(function() {</p><p>p2().then(function(result) {</p><p>return result;</p><p>});</p><p>});</p><p>This is incorrect. The syntax is wrong for calling p1 and p2.</p><p>async function getResult() {</p><p>const data = p1;</p><p>const result = p2(data);</p><p>}</p><p>await getResult();</p><p>This is incorrect. The await is outside the function calling the data.</p>",
232
+ "analysis": "<p>p1</p><p>.then((data) =&gt; p2(data))</p><p>.then(result =&gt; result);</p><p>This is correct. The method promise.then() is used to associate further action with a promise that becomes settled.</p><p>async function getResult() {</p><p>const data = await p1;</p><p>return await p2(data);</p><p>}</p><p>getResult();</p><p>This is correct. Using await inside the function causes both to execute.</p><p>p1().then(function() {</p><p>p2().then(function(result) {</p><p>return result;</p><p>});</p><p>});</p><p>This is incorrect. The syntax is wrong for calling p1 and p2.</p><p>async function getResult() {</p><p>const data = p1;</p><p>const result = p2(data);</p><p>}</p><p>await getResult();</p><p>This is incorrect. The await is outside the function calling the data.</p>",
233
233
  "hashCode": 588378204
234
234
  },
235
235
  {
236
- "describe": "<p>Given the following code, which one would be the correct order when executed?</p><p>setTimeout(() => console.log(\"timeout\"));</p><p>Promise.resolve().then(() => console.log(\"promise\"));</p><p>console.log(\"code\");</p><p></p>",
236
+ "describe": "<p>Given the following code, which one would be the correct order when executed?</p><p>setTimeout(() =&gt; console.log(\"timeout\"));</p><p>Promise.resolve().then(() =&gt; console.log(\"promise\"));</p><p>console.log(\"code\");</p><p></p>",
237
237
  "answerOptions": [
238
238
  {
239
239
  "describe": "<p>timeout — promise — code</p>",
@@ -293,19 +293,19 @@
293
293
  "describe": "<p>A developer is wondering whether to use, Promise.then or Promise.catch, especially when a promise throws an error.Which two promises are rejected? Choose 2 answers</p><p></p>",
294
294
  "answerOptions": [
295
295
  {
296
- "describe": "<p>Promise.reject('Cool error here').catch(error => console. error(error));</p>",
296
+ "describe": "<p>Promise.reject('Cool error here').catch(error =&gt; console. error(error));</p>",
297
297
  "isRight": true
298
298
  },
299
299
  {
300
- "describe": "<p>Promise.reject('Cool error here').then(error => console. error(error));</p>",
300
+ "describe": "<p>Promise.reject('Cool error here').then(error =&gt; console. error(error));</p>",
301
301
  "isRight": false
302
302
  },
303
303
  {
304
- "describe": "<p>new Promise((resolve, reject) => {throw 'Cool error here'}). catch(error=> console.error(error));</p>",
304
+ "describe": "<p>new Promise((resolve, reject) =&gt; {throw 'Cool error here'}). catch(error=&gt; console.error(error));</p>",
305
305
  "isRight": true
306
306
  },
307
307
  {
308
- "describe": "<p>new Promise(( ) => {throw 'Cool error here'}).then((null, error => console.error(error)));</p>",
308
+ "describe": "<p>new Promise(( ) =&gt; {throw 'Cool error here'}).then((null, error =&gt; console.error(error)));</p>",
309
309
  "isRight": false
310
310
  }
311
311
  ],
@@ -336,7 +336,7 @@
336
336
  "hashCode": 1594305024
337
337
  },
338
338
  {
339
- "describe": "<p>Refer to the code below:</p><p>01 let sayHello = ( ) => {</p><p>02 console. log('Hello, World!') ;</p><p>03 } ;</p><p>Which code executes sayHello once, two minutes from now?</p><p></p>",
339
+ "describe": "<p>Refer to the code below:</p><p>01 let sayHello = ( ) =&gt; {</p><p>02 console. log('Hello, World!') ;</p><p>03 } ;</p><p>Which code executes sayHello once, two minutes from now?</p><p></p>",
340
340
  "answerOptions": [
341
341
  {
342
342
  "describe": "<p>setInterval(sayHello, 120000) ;</p>",
@@ -359,7 +359,7 @@
359
359
  "hashCode": -1522893912
360
360
  },
361
361
  {
362
- "describe": "<p>Refer to the code below:</p><p>01 new Promise((resolve, reject) => {</p><p>02 const fraction = Math. random( ) ;</p><p>03 if (fraction > 0.5) reject( 'fraction > 0.5, ' + fraction) ;</p><p>04 resolve(fraction) ;</p><p>05 })</p><p>06 .then(( ) => console.log( 'resolved' ))</p><p>07 .catch((error) => console. error(error))</p><p>08 .finally(( ) => console.log 'when am I called?' )) ;</p><p>When does Promise . finally on line 08 get called?</p><p></p>",
362
+ "describe": "<p>Refer to the code below:</p><p>01 new Promise((resolve, reject) =&gt; {</p><p>02 const fraction = Math. random( ) ;</p><p>03 if (fraction &gt; 0.5) reject( 'fraction &gt; 0.5, ' + fraction) ;</p><p>04 resolve(fraction) ;</p><p>05 })</p><p>06 .then(( ) =&gt; console.log( 'resolved' ))</p><p>07 .catch((error) =&gt; console. error(error))</p><p>08 .finally(( ) =&gt; console.log 'when am I called?' )) ;</p><p>When does Promise . finally on line 08 get called?</p><p></p>",
363
363
  "answerOptions": [
364
364
  {
365
365
  "describe": "<p>When rejected</p>",
@@ -405,7 +405,7 @@
405
405
  "hashCode": 1601200398
406
406
  },
407
407
  {
408
- "describe": "<p>Refer to the code below:</p><p>01 let car1 = new Promise((_ , reject) =></p><p>02 setTimeout(reject, 2000, \"Car 1 crashed in\")) ;</p><p>03 let car2 = new Promise (resolve => setTimeout(resolve, 1500, \"Car 2 completed\")) ;</p><p>04 let car3 = new Promise (resolve => setTimeout(resolve, 3000, \"Car 3 completed\")) ;05</p><p>06 Promise. race([car1, car2, car3])</p><p>07 . then (value => {</p><p>08 let result = `${value} the race. `;</p><p>09 }) ;</p><p>10 . catch(err =>{</p><p>11 console.log(\"Race is cancelled.\", err);</p><p>12 }) ;</p><p>What is the value of result when Promise.race executes?</p><p></p>",
408
+ "describe": "<p>Refer to the code below:</p><p>01 let car1 = new Promise((_ , reject) =&gt;</p><p>02 setTimeout(reject, 2000, \"Car 1 crashed in\")) ;</p><p>03 let car2 = new Promise (resolve =&gt; setTimeout(resolve, 1500, \"Car 2 completed\")) ;</p><p>04 let car3 = new Promise (resolve =&gt; setTimeout(resolve, 3000, \"Car 3 completed\")) ;05</p><p>06 Promise. race([car1, car2, car3])</p><p>07 . then (value =&gt; {</p><p>08 let result = `${value} the race. `;</p><p>09 }) ;</p><p>10 . catch(err =&gt;{</p><p>11 console.log(\"Race is cancelled.\", err);</p><p>12 }) ;</p><p>What is the value of result when Promise.race executes?</p><p></p>",
409
409
  "answerOptions": [
410
410
  {
411
411
  "describe": "<p>Race is cancelled.</p>",
@@ -428,7 +428,7 @@
428
428
  "hashCode": 419951496
429
429
  },
430
430
  {
431
- "describe": "<p>Refer to the code below:</p><p>01 let timedFunction = ( ) => {</p><p>02 console. log( 'Timer called.' ) ;</p><p>03 } ;</p><p>04</p><p>05 let timerId = setTimeout (timedFunction, 1000) ;</p><p>Which statement allows a developer to cancel the scheduled timedfunction?</p><p></p>",
431
+ "describe": "<p>Refer to the code below:</p><p>01 let timedFunction = ( ) =&gt; {</p><p>02 console. log( 'Timer called.' ) ;</p><p>03 } ;</p><p>04</p><p>05 let timerId = setTimeout (timedFunction, 1000) ;</p><p>Which statement allows a developer to cancel the scheduled timedfunction?</p><p></p>",
432
432
  "answerOptions": [
433
433
  {
434
434
  "describe": "<p>removeTimeout (timedFunction) ;</p>",
@@ -474,7 +474,7 @@
474
474
  "hashCode": 1079957535
475
475
  },
476
476
  {
477
- "describe": "<p>Refer to the code below:</p><p>01 let sayHello = ( ) => {</p><p>02 console.log('Hello, World!');</p><p>03 };</p><p>Which option executes sayHello once every two minutes?</p><p></p>",
477
+ "describe": "<p>Refer to the code below:</p><p>01 let sayHello = ( ) =&gt; {</p><p>02 console.log('Hello, World!');</p><p>03 };</p><p>Which option executes sayHello once every two minutes?</p><p></p>",
478
478
  "answerOptions": [
479
479
  {
480
480
  "describe": "<p>delay(sayHello, 120000);</p>",
@@ -497,7 +497,7 @@
497
497
  "hashCode": -1935794449
498
498
  },
499
499
  {
500
- "describe": "<p>Given the code below:</p><p>const delay = async delay => {</p><p>return new Promise ( ( resolve, reject ) =></p><p>{</p><p>console.log(1);</p><p>setTimeout ( resolve, delay );</p><p>});</p><p>};</p><p>const callDelay = async ( ) => {</p><p>console.log(2);</p><p>const yup = await delay(1000);</p><p>console.log(3);</p><p>};</p><p>console.log(4);</p><p>callDelay( );</p><p>console.log(5);</p><p>What is logged to the console?</p><p></p>",
500
+ "describe": "<p>Given the code below:</p><p>const delay = async delay =&gt; {</p><p>return new Promise ( ( resolve, reject ) =&gt;</p><p>{</p><p>console.log(1);</p><p>setTimeout ( resolve, delay );</p><p>});</p><p>};</p><p>const callDelay = async ( ) =&gt; {</p><p>console.log(2);</p><p>const yup = await delay(1000);</p><p>console.log(3);</p><p>};</p><p>console.log(4);</p><p>callDelay( );</p><p>console.log(5);</p><p>What is logged to the console?</p><p></p>",
501
501
  "answerOptions": [
502
502
  {
503
503
  "describe": "<p>1 4 2 3 5</p>",
@@ -520,7 +520,7 @@
520
520
  "hashCode": -333748107
521
521
  },
522
522
  {
523
- "describe": "<p>Refer to the code below:</p><p>01 let total = 10;</p><p>02 const interval = setInterval ( ( ) => {</p><p>03 total++;</p><p>04 clearInterval(interval);</p><p>05 total++;</p><p>06 }, 0);</p><p>07 total++;</p><p>08 console.log(total);</p><p>Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?</p><p></p>",
523
+ "describe": "<p>Refer to the code below:</p><p>01 let total = 10;</p><p>02 const interval = setInterval ( ( ) =&gt; {</p><p>03 total++;</p><p>04 clearInterval(interval);</p><p>05 total++;</p><p>06 }, 0);</p><p>07 total++;</p><p>08 console.log(total);</p><p>Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?</p><p></p>",
524
524
  "answerOptions": [
525
525
  {
526
526
  "describe": "<p>10</p>",