diff --git a/curriculum/challenges/english/25-front-end-development/lecture-working-with-loops/6732c04638420641dcca2e6e.md b/curriculum/challenges/english/25-front-end-development/lecture-working-with-loops/6732c04638420641dcca2e6e.md index 4f6e763e6d3..545072e64fd 100644 --- a/curriculum/challenges/english/25-front-end-development/lecture-working-with-loops/6732c04638420641dcca2e6e.md +++ b/curriculum/challenges/english/25-front-end-development/lecture-working-with-loops/6732c04638420641dcca2e6e.md @@ -26,7 +26,7 @@ for (const color of colors) { ## --answers-- -```js +```md red green blue @@ -34,7 +34,7 @@ blue --- -```js +```md red red red @@ -46,7 +46,7 @@ Think about what the `color` variable represents in the loop. --- -```js +```md color color color @@ -58,7 +58,7 @@ Think about what the `color` variable represents in the loop. --- -```js +```md blue blue red @@ -125,7 +125,7 @@ for (let fruit of fruits) { ## --answers-- -```js +```md APPLE APPLE APPLE @@ -137,7 +137,7 @@ Think about what the fruit variable represents in the loop and how the `toUpperC --- -```js +```md apple banana cherry @@ -149,7 +149,7 @@ Think about what the fruit variable represents in the loop and how the `toUpperC --- -```js +```md APPLE BANANA CHERRY @@ -157,7 +157,7 @@ CHERRY --- -```js +```md FRUIT FRUIT FRUIT diff --git a/curriculum/challenges/english/25-front-end-development/quiz-javascript-loops/66edcd49e73385dd4df54ac7.md b/curriculum/challenges/english/25-front-end-development/quiz-javascript-loops/66edcd49e73385dd4df54ac7.md index c76929783de..31c573b1b06 100644 --- a/curriculum/challenges/english/25-front-end-development/quiz-javascript-loops/66edcd49e73385dd4df54ac7.md +++ b/curriculum/challenges/english/25-front-end-development/quiz-javascript-loops/66edcd49e73385dd4df54ac7.md @@ -33,7 +33,7 @@ It is the process of sending signals between components to establish a connectio #### --answer-- -It is the process of repeating a set of instructions multiple times until a condition is met. +It is the process of repeating a set of instructions multiple times. ### --question-- @@ -61,23 +61,23 @@ Looping #### --text-- -Which of the following is not an iterable object? +Which of the following is an iterable object? #### --distractors-- -Map +Undefined --- -String +Number --- -Array +Boolean #### --answer-- -Math object. +String ### --question-- @@ -110,29 +110,33 @@ What is the correct order of the `for` loop declaration? #### --distractors-- ```javascript -for (condition; increment/decrement; initialization) +for (condition; increment/decrement; initialization) { statement; +} ``` --- ```javascript -for (increment/decrement; condition; initialization) +for (increment/decrement; condition; initialization) { statement; +} ``` --- ```javascript -for (initialization; increment/decrement; condition) +for (initialization; increment/decrement; condition) { statement; +} ``` #### --answer-- ```javascript -for (initialization; condition; increment/decrement) +for (initialization; condition; increment/decrement) { statement; +} ``` ### --question-- @@ -161,7 +165,7 @@ Which loop executes the code block once, before checking if the condition is tru #### --text-- -Which loop loops over the values of an iterable object? +Which of the following will loop over the values of an iterable object? #### --distractors-- @@ -199,29 +203,35 @@ A loop that automatically stops after a fixed number of iterations. #### --answer-- -A loop that continues to run indefinitely because the termination condition is never met or is absent. +A loop whose termination condition is never met or is absent. ### --question-- #### --text-- -For iterating over an array, which loop is not the best? +How many times will the following loop run? + +```js +for (let i = 2; i < 10; i+=2) { + console.log(i); +} +``` #### --distractors-- -`for` loop. +5 --- -`for...of` loop. +9 --- -`for...in` loop. +10 #### --answer-- -`while` loop. +4 ### --question-- @@ -271,7 +281,7 @@ What is the difference between the `for...in` loop and the `for...of` loop? #### --text-- -To prevent an infinite loop from occurring, all but one of these are expected to be part of the loop used. +Which of these would cause an infinite loop? #### --distractors-- @@ -337,29 +347,41 @@ The `continue` statement. #### --text-- -It is generally recommended to avoid using the `for...in` loop in JavaScript. What is the reason for that? +What is printed to the console with the following code? + +```js +for (let i = 0; i < 25; i += 2) { + if (i % 5 === 0) { + continue; + } + if (i % 13 === 0) { + break; + } + console.log(i); +} +``` #### --distractors-- -It only works with arrays and not with objects. +`0`, `2`, `4`, `6`, `8`, `12`, `14`, `16`, `18`, `22`, `24` --- -It is the best way to iterate over large objects. +`0`, `2`, `4`, `6`, `8`, `12` --- -It guarantees the order of property enumeration. +`2`, `4`, `6`, `8`, `12` #### --answer-- -It could enumerate over inherited properties of an object. +`2`, `4`, `6`, `8`, `12`, `14`, `16`, `18`, `22`, `24` ### --question-- #### --text-- -What will be the output of the code below? +What would the following code print to the console?? ```javascript for (let i = 1; i < 6; i++) { @@ -370,33 +392,25 @@ for (let i = 1; i < 6; i++) { #### --distractors-- -```javascript -1,2,3,4,5,6 -``` +`1`, `2`, `3`, `4`, `5`, `6` --- -```javascript -1,2,3,4,5 -``` +`1`, `2`, `3`, `4`, `5` --- -```javascript -1,2,3,4 -``` +`1`, `2`, `3`, `4` #### --answer-- -```javascript -1,2,3 -``` +`1`, `2`, `3` ### --question-- #### --text-- -What will be the output of the code below? +What will be printed to the console with the code below? ```javascript const shoppingList = { tomatoes: 4, apples: 10 }; @@ -407,33 +421,25 @@ for (const item in shoppingList) { #### --distractors-- -```javascript -tomatoes - 4, apples - 10 -``` +`tomatoes - 4`, `apples - 10` --- -```javascript -4, 10 -``` +`4`, `10` --- -```javascript -tomatoes:4, apples:10 -``` +`tomatoes:4`, `apples:10` #### --answer-- -```javascript -tomatoes, apples -``` +`tomatoes`, `apples` ### --question-- #### --text-- -What will be the output of the code below? +What will be the console output of the code below? ```javascript for (let i = 2; i <= 13; i++) { @@ -444,64 +450,48 @@ for (let i = 2; i <= 13; i++) { #### --distractors-- -```javascript -2,4,6,8,10,12 -``` +`2`, `4`, `6`, `8`, `10`, `12` --- -```javascript -1,3,5,7,9,11,13 -``` +`1`, `3`, `5`, `7`, `9`, `11`, `13` --- -```javascript -1,3,5,7,9,11 -``` +`1`, `3`, `5`, `7`, `9`, `11` #### --answer-- -```javascript -3,5,7,9,11,13 -``` +`3`, `5`, `7`, `9`, `11`, `13` ### --question-- #### --text-- -What would be the output of the code below? +What would be printed to the console with the code below? ```javascript const fruits = ["Mango", "Pineapple", "Oranges"]; -for (const fruit in fruits) { +for (const fruit of fruits) { console.log(fruit); } ``` #### --distractors-- -```javascript -Mango, Pineapple -``` +`0`, `1`, `2` --- -```javascript -Pineapple, Oranges, Mango -``` +`Pineapple`, `Oranges`, `Mango` --- -```javascript -Oranges, Pineapple, Mango -``` +`Oranges`, `Pineapple`, `Mango` #### --answer-- -```javascript -Mango, Pineapple, Oranges -``` +`Mango`, `Pineapple`, `Oranges` ### --question-- @@ -518,17 +508,17 @@ while (x < 5) { #### --distractors-- -3 times. +3 times --- -4 times. +4 times --- -5 times. +5 times #### --answer-- -Infinite. +Infinite times