diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 22cc53f298d..5d4a7373e87 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -3123,6 +3123,13 @@ "In these lessons you will learn about operator precedence, the increment and decrement operators, and compound assignment operators." ] }, + "lab-debug-increment-and-decrement-operator-errors": { + "title": "Debug Increment and Decrement Operator Errors in a Buggy App", + "intro": [ + "In this lab, you'll debug an application that has several errors related to the increment and decrement operators.", + "Your task is to identify and fix the errors so that the application works as intended." + ] + }, "lecture-working-with-comparison-and-boolean-operators": { "title": "Working with Comparison and Boolean Operators", "intro": [ @@ -8648,14 +8655,8 @@ "title": "Nasal Finals", "intro": ["", ""] }, - "zh-a1-review-pinyin": { - "title": "Pinyin Review", - "intro": ["", ""] - }, - "zh-a1-quiz-pinyin": { - "title": "Pinyin Quiz", - "intro": ["", ""] - }, + "zh-a1-review-pinyin": { "title": "Pinyin Review", "intro": ["", ""] }, + "zh-a1-quiz-pinyin": { "title": "Pinyin Quiz", "intro": ["", ""] }, "zh-a1-warm-up-greeting-new-colleagues": { "title": "Greeting New Colleagues", "intro": ["", ""] diff --git a/client/src/pages/learn/full-stack-developer/lab-debug-increment-and-decrement-operator-errors/index.md b/client/src/pages/learn/full-stack-developer/lab-debug-increment-and-decrement-operator-errors/index.md new file mode 100644 index 00000000000..3f32682c78b --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-debug-increment-and-decrement-operator-errors/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Debug Increment and Decrement Operator Errors in a Buggy App +block: lab-debug-increment-and-decrement-operator-errors +superBlock: full-stack-developer +--- + +## Introduction to the Debug Increment and Decrement Operator Errors in a Buggy App + +In this lab, you will be working with a buggy app that contains several increment and decrement operator errors. Your task is to identify and fix these errors to ensure the application functions correctly. diff --git a/curriculum/challenges/english/blocks/lab-debug-increment-and-decrement-operator-errors/69008059d43d6751385883c1.md b/curriculum/challenges/english/blocks/lab-debug-increment-and-decrement-operator-errors/69008059d43d6751385883c1.md new file mode 100644 index 00000000000..88eba47bd7e --- /dev/null +++ b/curriculum/challenges/english/blocks/lab-debug-increment-and-decrement-operator-errors/69008059d43d6751385883c1.md @@ -0,0 +1,133 @@ +--- +id: 69008059d43d6751385883c1 +title: Debug Increment and Decrement Operator Errors in a Buggy App +challengeType: 26 +dashedName: debug-increment-and-decrement-operator-errors-in-a-buggy-app +--- + +# --description-- + +Your friend has asked you to help them debug their code. They are practicing increment and decrement operators but are getting unexpected results in the console. + +Your task is to help them identify the mistakes and update the code so that the console outputs match the expected results. + +You can refer back to the prior lessons on increment and decrement operators as well as prefix and postfix notation. + +**User Stories:** + +1. You should have a variable named `updatedCounter` that correctly produces the value `11` by using the increment operator. Update the expression to use the correct prefix or postfix notation instead of hardcoding the value. +2. You should have a variable named `finalScore` that correctly produces the value `8` by using the increment operator. Update the expression to use the correct prefix or postfix notation instead of hardcoding the value. +3. You should have a variable named `updatedCoins` that correctly produces the value `2` by using the decrement operator. Update the expression to use the correct prefix or postfix notation instead of hardcoding the value. +4. You should have a variable named `newHealth` that correctly produces the value `7` by using the decrement operator. Update the expression to use the correct prefix or postfix notation instead of hardcoding the value. + +# --hints-- + +You should have a variable named `updatedCounter` that uses prefix increment notation (`++counter`). + +```js +assert.match(code, /updatedCounter\s*=\s*\+\+counter\s*;/); +assert.strictEqual(typeof updatedCounter, 'number'); +``` + +`updatedCounter` should equal to `11`. + +```js +assert.strictEqual(updatedCounter, 11); +``` + +You should have a variable named `finalScore` that uses postfix increment notation (`score++`). + +```js +assert.match(code, /finalScore\s*=\s*score\+\+\s*;/); +assert.strictEqual(typeof finalScore, 'number'); +``` + +`finalScore` should equal to `8`. + +```js +assert.strictEqual(finalScore, 8); +``` + +You should have a variable named `updatedCoins` that uses prefix decrement notation (`--coins`). + +```js +assert.match(code, /updatedCoins\s*=\s*--coins\s*;/); +assert.strictEqual(typeof updatedCoins, 'number'); +``` + +`updatedCoins` should equal to `2`. + +```js +assert.strictEqual(updatedCoins, 2); +``` + +You should have a variable named `newHealth` that uses postfix decrement notation (`health--`). + +```js +assert.match(code, /newHealth\s*=\s*health--\s*;/); +assert.strictEqual(typeof newHealth, 'number'); +``` + +`newHealth` should equal to `7`. + +```js +assert.strictEqual(newHealth, 7); +``` + +# --seed-- + +## --seed-contents-- + +```js +let counter = 10; +console.log(`Counter is currently ${counter}`); + +let updatedCounter = counter++; +console.log(`Counter is now ${updatedCounter}`); + +let score = 8; +console.log(`Score is currently ${score}`); + +let finalScore = ++score; +console.log(`Score is still ${finalScore}`); + +let coins = 3; +console.log(`Coins is currently ${coins}`); + +let updatedCoins = coins--; +console.log(`Coins is now ${updatedCoins}`); + +let health = 7; +console.log(`Health is currently ${health}`); + +let newHealth = --health; +console.log(`Health is still ${newHealth}`); +``` + +# --solutions-- + +```js +let counter = 10; +console.log(`Counter is currently ${counter}`); + +let updatedCounter = ++counter; +console.log(`Counter is now ${updatedCounter}`); + +let score = 8; +console.log(`Score is currently ${score}`); + +let finalScore = score++; +console.log(`Score is still ${finalScore}`); + +let coins = 3; +console.log(`Coins is currently ${coins}`); + +let updatedCoins = --coins; +console.log(`Coins is now ${updatedCoins}`); + +let health = 7; +console.log(`Health is currently ${health}`); + +let newHealth = health--; +console.log(`Health is still ${newHealth}`); +``` diff --git a/curriculum/structure/blocks/lab-debug-increment-and-decrement-operator-errors.json b/curriculum/structure/blocks/lab-debug-increment-and-decrement-operator-errors.json new file mode 100644 index 00000000000..03731406ca9 --- /dev/null +++ b/curriculum/structure/blocks/lab-debug-increment-and-decrement-operator-errors.json @@ -0,0 +1,15 @@ +{ + "name": "Debug Increment and Decrement Operator Errors in a Buggy App", + "isUpcomingChange": false, + "dashedName": "lab-debug-increment-and-decrement-operator-errors", + "helpCategory": "JavaScript", + "blockLayout": "link", + "blockLabel": "lab", + "usesMultifileEditor": true, + "challengeOrder": [ + { + "id": "69008059d43d6751385883c1", + "title": "Debug Increment and Decrement Operator Errors in a Buggy App" + } + ] +} diff --git a/curriculum/structure/superblocks/full-stack-developer.json b/curriculum/structure/superblocks/full-stack-developer.json index c9524173260..13d9b8392ce 100644 --- a/curriculum/structure/superblocks/full-stack-developer.json +++ b/curriculum/structure/superblocks/full-stack-developer.json @@ -310,6 +310,7 @@ "lecture-working-with-numbers-and-arithmetic-operators", "lab-debug-type-coercion-errors", "lecture-working-with-operator-behavior", + "lab-debug-increment-and-decrement-operator-errors", "lecture-working-with-comparison-and-boolean-operators", "lecture-working-with-unary-and-bitwise-operators", "lecture-working-with-conditional-logic-and-math-methods",