From 4e519fa05830284a903b10b5a719dc9f85cb388e Mon Sep 17 00:00:00 2001 From: "Krzysztof G." <60067306+gikf@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:38:27 +0100 Subject: [PATCH] fix(curriculum): Recipe Tracker improvements (#57694) Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com> Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> Co-authored-by: Naomi --- .../66fbcf750a62784cf11f5630.md | 62 ++++++++++++++++--- .../66fbcf750a62784cf11f5631.md | 26 +++----- .../66fbcf750a62784cf11f5632.md | 26 +++----- .../66fbcf750a62784cf11f5633.md | 14 ++--- .../66fbcf750a62784cf11f5635.md | 22 +++---- .../66fbcf750a62784cf11f5636.md | 18 +++--- .../670e4f45f7116c0f216a5177.md | 32 +++++----- 7 files changed, 114 insertions(+), 86 deletions(-) diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5630.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5630.md index a010c6c140c..408895d618d 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5630.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5630.md @@ -13,30 +13,76 @@ You should now push the three objects into the `recipes` array. To do thus, you Use the `push()` method to push all the recipe objects into the `recipes` array. Make sure to push `recipe1`, `recipe2`, and `recipe3` in that order. +Also delete the `recipe1Name`, `recipe2Name`, `recipe1CookingTime`, and `recipe2CookingTime` variables, and the `console.log` statements which log those variables. + # --hints-- -You should remove `recipe1Name` and its console log. +You should remove the `recipe1Name` variable. ```js -assert.notMatch(code, /const\s*recipe1Name\s*=\s*recipe1\.name;?\s*console\.log\(recipe1Name\);?/) +try { + recipe1Name; + assert.fail('Variable is defined/declared'); +} catch (e) { + assert.include(e?.message, 'recipe1Name is not defined'); +} ``` -You should remove `recipe2Name` and its console log. +You should remove the `console.log(recipe1Name);` statement. ```js -assert.notMatch(code, /const\s*recipe2Name\s*=\s*recipe2\.name;?\s*console\.log\(recipe2Name\);?/) +assert.notMatch(__helpers.removeJSComments(code), /console\s*\.\s*log\s*\(\s*recipe1Name\s*\)\s*;?/); ``` -You should remove `recipe1CookingTime` and its console log. +You should remove the `recipe2Name` variable. ```js -assert.notMatch(code, /const\s*recipe1CookingTime\s*=\s*recipe1\.cookingTime;?\s*console\.log\(recipe1CookingTime\);?/) +try { + recipe2Name; + assert.fail('Variable is defined/declared'); +} catch (e) { + assert.include(e?.message, 'recipe2Name is not defined'); +} ``` -You should remove `recipe2CookingTime` and its console log. +You should remove the `console.log(recipe2Name);` statement. ```js -assert.notMatch(code, /const\s*recipe2CookingTime\s*=\s*recipe2\.cookingTime;?\s*console\.log\(recipe2CookingTime\);?/) +assert.notMatch(__helpers.removeJSComments(code), /console\s*\.\s*log\s*\(\s*recipe2Name\s*\)\s*;?/); +``` + +You should remove the `recipe1CookingTime` variable. + +```js +try { + recipe1CookingTime; + assert.fail('Variable is defined/declared'); +} catch (e) { + assert.include(e?.message, 'recipe1CookingTime is not defined'); +} +``` + +You should remove the `console.log(recipe1CookingTime);` statement. + +```js +assert.notMatch(__helpers.removeJSComments(code), /console\s*\.\s*log\s*\(\s*recipe1CookingTime\s*\)\s*;?/); +``` + +You should remove the `recipe2CookingTime` variable. + +```js +try { + recipe2CookingTime; + assert.fail('Variable is defined/declared'); +} catch (e) { + assert.include(e?.message, 'recipe2CookingTime is not defined'); +} +``` + +You should remove the `console.log(recipe2CookingTime);` statement. + +```js +assert.notMatch(__helpers.removeJSComments(code), /console\s*\.\s*log\s*\(\s*recipe2CookingTime\s*\)\s*;?/); ``` You should push all the recipes objects into the `recipes` array. Make sure to push them in the order they are declared. diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5631.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5631.md index 292feedbae0..6ca14f2a2a4 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5631.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5631.md @@ -9,7 +9,7 @@ dashedName: step-7 Now, you should work on calculating the `averageRating`, `totalIngredients`, and the `difficultyLevel` for each recipe in the `recipes` array. -Start by creating a `getAverageRating` function that takes a `ratings` parameter. Inside the function, calculate the average rating using the items in the `ratings` property of each recipe. +Start by creating a `getAverageRating` function that takes a single argument, which is an array with ratings. Inside the function, calculate the average rating from the array passed to the function. Your `getAverageRating` function must return a number. @@ -21,10 +21,10 @@ You should create a `getAverageRating` function. assert.isFunction(getAverageRating) ``` -Your `getAverageRating` function should have a `ratings` parameter. +Your `getAverageRating` function should have a single parameter. ```js -assert.match(getAverageRating.toString(), /ratings/); +assert.lengthOf(getAverageRating, 1); ``` Your `getAverageRating` function should return a number. @@ -33,30 +33,22 @@ Your `getAverageRating` function should return a number. assert.isNumber(getAverageRating(recipe1.ratings)) ``` -You `getAverageRating` function should return a number when the average rating is `4.00`. +`getAverageRating(recipe1.ratings)` should return `4.5`. ```js -assert.isNumber(getAverageRating(recipe2.ratings)) +assert.strictEqual(getAverageRating(recipe1.ratings), 4.5) ``` -You `getAverageRating` function should return a number when the average rating is `4.75`. +`getAverageRating(recipe2.ratings)` should return `4.75`. ```js -assert.isNumber(getAverageRating(recipe2.ratings)) +assert.strictEqual(getAverageRating(recipe2.ratings), 4.75) ``` -You `getAverageRating` function should return a number when the average rating is `4.50`. +`getAverageRating(recipe3.ratings)` should return `4`. ```js -assert.isNumber(getAverageRating(recipe1.ratings)) -``` - -Your `getAverageRating` function should return the correct rating. - -```js -assert.equal(getAverageRating(recipe1.ratings), 4.50) -assert.equal(getAverageRating(recipe2.ratings), 4.75) -assert.equal(getAverageRating(recipe3.ratings), 4.00) +assert.strictEqual(getAverageRating(recipe3.ratings), 4) ``` # --seed-- diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5632.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5632.md index ace358ab7f5..6d190332d16 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5632.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5632.md @@ -7,7 +7,7 @@ dashedName: step-8 # --description-- -Create a `getTotalIngredients` function that takes an `ingredients` parameter. This function should return the number of ingredients for each recipe by returning the length of the `ingredients` array. +Create a `getTotalIngredients` function that takes a single argument, representing an array with ingredients, and returns the number of ingredients from the array passed to the function. # --hints-- @@ -17,10 +17,10 @@ You should create a `getTotalIngredients` function. assert.isFunction(getTotalIngredients) ``` -You `getTotalIngredients` function should have an `ingredients` parameter. +Your `getTotalIngredients` function should have a single parameter. ```js -assert.match(getTotalIngredients.toString(), /ingredients/); +assert.lengthOf(getTotalIngredients, 1); ``` Your `getTotalIngredients` function should return a number. @@ -29,30 +29,22 @@ Your `getTotalIngredients` function should return a number. assert.isNumber(getTotalIngredients(recipe1.ingredients)) ``` -Your `getTotalIngredients` function should return a number when the total ingrendients is `5`. +`getTotalIngredients(recipe1.ingredients)` should return `4`. ```js -assert.isNumber(getTotalIngredients(recipe2.ingredients)) +assert.strictEqual(getTotalIngredients(recipe1.ingredients), 4); ``` -Your `getTotalIngredients` function should return a number when the total ingrendients is `3`. +`getTotalIngredients(recipe2.ingredients)` should return `5`. ```js -assert.isNumber(getTotalIngredients(recipe3.ingredients)) +assert.strictEqual(getTotalIngredients(recipe2.ingredients), 5); ``` -Your `getTotalIngredients` function should return a number when the total ingrendients is `4`. +`getTotalIngredients(recipe3.ingredients)` should return `3`. ```js -assert.isNumber(getTotalIngredients(recipe1.ingredients)) -``` - -Your `getTotalIngredients` function should return the correct number of ingredients. - -```js -assert.equal(getTotalIngredients(recipe1.ingredients), 4) -assert.equal(getTotalIngredients(recipe2.ingredients), 5) -assert.equal(getTotalIngredients(recipe3.ingredients), 3) +assert.strictEqual(getTotalIngredients(recipe3.ingredients), 3); ``` # --seed-- diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5633.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5633.md index 0db6de8ca50..7056df9e9ba 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5633.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5633.md @@ -7,9 +7,9 @@ dashedName: step-9 # --description-- -Create a `getDifficultyLevel` function that takes `cookingTime` as a parameter. +Create a `getDifficultyLevel` function that takes a number indicating the cooking time as a parameter. -If `cookingTime` is less than or equal to `30`, the function should return `"easy"`. If it is less than or equal to `60`, the function should return `"medium"`. Otherwise, the function should return `"hard"`. +If the cooking time is less than or equal to `30`, the function should return `"easy"`. If it is less than or equal to `60`, the function should return `"medium"`. Otherwise, the function should return `"hard"`. # --hints-- @@ -19,13 +19,13 @@ You should create a `getDifficultyLevel` function. assert.isFunction(getDifficultyLevel) ``` -You `getDifficultyLevel` function should have a `cookingTime` parameter. +Your `getDifficultyLevel` function should have a single parameter. ```js -assert.match(getDifficultyLevel.toString(), /cookingTime/); +assert.lengthOf(getDifficultyLevel, 1); ``` -Your `getDifficultyLevel` function should return `"easy"` when the `cookingTime` is less than or equal to `30`. +Your `getDifficultyLevel` function should return `"easy"` when the cooking time is less than or equal to `30`. ```js assert.strictEqual(getDifficultyLevel(10), "easy") @@ -34,7 +34,7 @@ assert.strictEqual(getDifficultyLevel(29), "easy") assert.strictEqual(getDifficultyLevel(30), "easy") ``` -Your `getDifficultyLevel` function should return `"medium"` when the `cookingTime` is greater than `31` and less than `60`. +Your `getDifficultyLevel` function should return `"medium"` when the cooking time is greater than `31` and less than or equal to `60`. ```js assert.strictEqual(getDifficultyLevel(31), "medium") @@ -43,7 +43,7 @@ assert.strictEqual(getDifficultyLevel(50), "medium") assert.strictEqual(getDifficultyLevel(60), "medium") ``` -Your `getDifficultyLevel` function should return `"hard"` when the `cookingTime` is greater than `60`. +Your `getDifficultyLevel` function should return `"hard"` when the cooking time is greater than `60`. ```js assert.strictEqual(getDifficultyLevel(61), "hard") diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5635.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5635.md index 3a34c4658f5..48de8959671 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5635.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5635.md @@ -9,46 +9,44 @@ dashedName: step-11 You can now fill in each item of the `recipes` array with values for the `averageRating`, `totalIngredients`, and `difficultyLevel` properties. -To do this, access the `averageRating`, `totalIngredients`, and `difficultyLevel` properties of each recipe object and assign them the results of the corresponding function calls with the appropriate arguments. - -For now, access the `averageRating`, `totalIngredients`, and `difficultyLevel` of `recipe1` and set them to the appropriate function calls and arguments. +For now, access the `averageRating`, `totalIngredients`, and `difficultyLevel` of `recipe1` and set them to the appropriate results of function calls and arguments. # --hints-- You should access the `averageRating` property of `recipe1`. ```js -assert.match(code, /recipe1\.averageRating/) +assert.isNotNull(recipe1.averageRating); ``` -You should set the `averageRating` of `recipe1` you accessed to the calling of `getAverageRating` with `recipe1.ratings` as its parameter. +You should assign the result of calling `getAverageRating` with `recipe1.ratings` to the `averageRating` property of `recipe1`. ```js -assert.match(code, /recipe1\.averageRating\s*=\s*getAverageRating\(recipe1\.ratings\);?/) +assert.strictEqual(recipe1.averageRating, getAverageRating(recipe1.ratings)); ``` You should access the `totalIngredients` property of `recipe1`. ```js -assert.match(code, /recipe1\.totalIngredients/) +assert.isNotNull(recipe1.totalIngredients); ``` -You should set the `totalIngredients` of `recipe1` you accessed to the calling of `getTotalIngredients` with `recipe1.ingredients` as its parameter. +You should assign the result of calling `getTotalIngredients` with `recipe1.ingredients` to the `totalIngredients` property of `recipe1`. ```js -assert.match(code, /recipe1\.totalIngredients\s*=\s*getTotalIngredients\(recipe1\.ingredients\);?/) +assert.strictEqual(recipe1.totalIngredients, getTotalIngredients(recipe1.ingredients)); ``` You should access the `difficultyLevel` property of `recipe1`. ```js -assert.match(code, /recipe1\.difficultyLevel/) +assert.isNotEmpty(recipe1.difficultyLevel); ``` -You should set the `difficultyLevel` of `recipe1` you accessed to the calling of `getDifficultyLevel` with `recipe1.cookingTime` as its parameter. +You should assign the result of calling `getDifficultyLevel` with `recipe1.cookingTime` to the `cookingTime` property of `recipe1`. ```js -assert.match(code, /recipe1\.difficultyLevel\s*=\s*getDifficultyLevel\(recipe1\.cookingTime\);?/) +assert.strictEqual(recipe1.difficultyLevel, getDifficultyLevel(recipe1.cookingTime)); ``` # --seed-- diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5636.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5636.md index bd9aceddf5f..8f45a98cbd6 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5636.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/66fbcf750a62784cf11f5636.md @@ -14,37 +14,37 @@ Repeat the process for the `averageRating`, `totalIngredients`, and `difficultyL You should access the `averageRating` property of `recipe2`. ```js -assert.match(code, /recipe2\.averageRating/) +assert.isNotNull(recipe2.averageRating); ``` -You should set the `averageRating` of `recipe2` you accessed to the calling of `getAverageRating` with `recipe1.ratings` as its parameter. +You should assign the result of calling `getAverageRating` with `recipe2.ratings` to the `averageRating` property of `recipe2`. ```js -assert.match(code, /recipe2\.averageRating\s*=\s*getAverageRating\(recipe2\.ratings\);?/) +assert.strictEqual(recipe2.averageRating, getAverageRating(recipe2.ratings)); ``` You should access the `totalIngredients` property of `recipe2`. ```js -assert.match(code, /recipe2\.totalIngredients/) +assert.isNotNull(recipe2.totalIngredients); ``` -You should set the `totalIngredients` of `recipe2` you accessed to the calling of `getTotalIngredients` with `recipe2.ingredients` as its parameter. +You should assign the result of calling `getTotalIngredients` with `recipe2.ingredients` to the `totalIngredients` property of `recipe2`. ```js -assert.match(code, /recipe2\.totalIngredients\s*=\s*getTotalIngredients\(recipe2\.ingredients\);?/) +assert.strictEqual(recipe2.totalIngredients, getTotalIngredients(recipe2.ingredients)); ``` You should access the `difficultyLevel` property of `recipe2`. ```js -assert.match(code, /recipe2\.difficultyLevel/) +assert.isNotEmpty(recipe2.difficultyLevel); ``` -You should set the `difficultyLevel` of `recipe2` you accessed to the calling of `getDifficultyLevel` with `recipe2.cookingTime` as its parameter. +You should assign the result of calling `getDifficultyLevel` with `recipe2.cookingTime` to the `difficultyLevel` property of `recipe2`. ```js -assert.match(code, /recipe2\.difficultyLevel\s*=\s*getDifficultyLevel\(recipe2\.cookingTime\);?/) +assert.strictEqual(recipe2.difficultyLevel, getDifficultyLevel(recipe2.cookingTime)); ``` # --seed-- diff --git a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/670e4f45f7116c0f216a5177.md b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/670e4f45f7116c0f216a5177.md index dc26e12dbee..5577460076e 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/670e4f45f7116c0f216a5177.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-recipe-tracker/670e4f45f7116c0f216a5177.md @@ -33,73 +33,73 @@ Make sure all the variables you created are logged to the console. You should create a `recipe1Name` variable. ```js -assert.isNotNull(recipe1Name) +assert.isDefined(recipe1Name); ``` -You should set your `recipe1Name` variable to the accessment of the `name` property of `recipe1`. +You should assign the value of the `name` property of `recipe1` to your `recipe1name` variable. ```js -assert.match(code, /recipe1\.name|recipe1\[("|'|`)name("|'|`)\]/) +assert.strictEqual(recipe1Name, recipe1.name); ``` You should log `recipe1Name` to the console. ```js -assert.match(code, /console\.log\(recipe1Name\)/) +assert.match(code, /console\.log\(\s*recipe1Name\s*\)/); ``` You should create a `recipe2Name` variable. ```js -assert.isNotNull(recipe2Name) +assert.isDefined(recipe2Name); ``` -You should set your `recipe2Name` variable to the accessment of the `name` property of `recipe2`. +You should assign the value of the `name` property of `recipe2` to your `recipe2name` variable. ```js -assert.match(code, /recipe2\.name|recipe2\[("|'|`)name("|'|`)\]/) +assert.strictEqual(recipe2Name, recipe2.name); ``` You should log `recipe2Name` to the console. ```js -assert.match(code, /console\.log\(recipe2Name\)/) +assert.match(code, /console\.log\(recipe2Name\)/); ``` You should create a `recipe1CookingTime` variable. ```js -assert.isNotNull(recipe1CookingTime) +assert.isDefined(recipe1CookingTime); ``` -You should set your `recipe1CookingTime` variable to the accessment of the `cookingTime` property of `recipe1`. +You should assign the value of the `cookingTime` property of `recipe1` to your `recipe1CookingTime` variable. ```js -assert.match(code, /recipe1\.cookingTime|recipe1\[("|'|`)cookingTime("|'|`)\]/) +assert.strictEqual(recipe1CookingTime, recipe1.cookingTime); ``` You should log `recipe1CookingTime` to the console. ```js -assert.match(code, /console\.log\(recipe1CookingTime\)/) +assert.match(code, /console\.log\(recipe1CookingTime\)/); ``` You should create a `recipe2CookingTime` variable. ```js -assert.isNotNull(recipe2CookingTime) +assert.isDefined(recipe2CookingTime); ``` -You should set your `recipe2CookingTime` variable to the accessment of the `cookingTime` property of `recipe2`. +You should assign the value of the `cookingTime` property of `recipe2` to your `recipe2CookingTime` variable. ```js -assert.match(code, /recipe2\.cookingTime|recipe2\[("|'|`)cookingTime("|'|`)\]/) +assert.strictEqual(recipe2CookingTime, recipe2.cookingTime); ``` You should log `recipe2CookingTime` to the console. ```js -assert.match(code, /console\.log\(recipe2CookingTime\)/) +assert.match(code, /console\.log\(recipe2CookingTime\)/); ``` # --seed--