From b5ed2619eb09cd9c0f18fc6ab59f46e5fd1cc79e Mon Sep 17 00:00:00 2001 From: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Date: Thu, 25 Mar 2021 15:07:48 -0600 Subject: [PATCH] fix: replace inline code blocks (#41576) --- .../add-new-properties-to-a-javascript-object.md | 8 ++++++-- .../assignment-with-a-returned-value.md | 4 +++- .../compound-assignment-with-augmented-addition.md | 4 +++- .../compound-assignment-with-augmented-division.md | 8 ++++++-- ...pound-assignment-with-augmented-multiplication.md | 8 ++++++-- ...compound-assignment-with-augmented-subtraction.md | 8 ++++++-- .../basic-javascript/counting-cards.md | 4 +--- .../basic-javascript/declare-string-variables.md | 4 +++- .../decrement-a-number-with-javascript.md | 8 ++++++-- .../delete-properties-from-a-javascript-object.md | 4 +++- .../escaping-literal-quotes-in-strings.md | 12 +++++++++--- .../generate-random-whole-numbers-with-javascript.md | 4 +++- .../generate-random-whole-numbers-within-a-range.md | 4 +++- .../increment-a-number-with-javascript.md | 8 ++++++-- ...alizing-variables-with-the-assignment-operator.md | 4 +++- .../basic-javascript/shopping-list.md | 4 +++- ...values-in-one-variable-using-javascript-arrays.md | 4 +++- .../storing-values-with-the-assignment-operator.md | 4 +++- .../use-the-parseint-function-with-a-radix.md | 8 ++++++-- .../basic-javascript/use-the-parseint-function.md | 4 +++- ...cript-console-to-check-the-value-of-a-variable.md | 4 +++- .../learn-about-functional-programming.md | 4 +++- .../arguments-optional.md | 4 +++- .../part-018.md | 8 ++++++-- .../make-code-more-reusable-with-the-this-keyword.md | 4 +++- 25 files changed, 103 insertions(+), 37 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md index ffc41589ead..ea1975009c3 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md @@ -13,11 +13,15 @@ You can add new properties to existing JavaScript objects the same way you would Here's how we would add a `bark` property to `ourDog`: -`ourDog.bark = "bow-wow";` +```js +ourDog.bark = "bow-wow"; +``` or -`ourDog["bark"] = "bow-wow";` +```js +ourDog["bark"] = "bow-wow"; +``` Now when we evaluate `ourDog.bark`, we'll get his bark, `bow-wow`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md index 15a61d6e5d3..cfdf53c228d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md @@ -13,7 +13,9 @@ If you'll recall from our discussion of [Storing Values with the Assignment Oper Assume we have pre-defined a function `sum` which adds two numbers together, then: -`ourSum = sum(5, 12);` +```js +ourSum = sum(5, 12); +``` will call `sum` function, which returns a value of `17` and assigns it to `ourSum` variable. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md index 7bc5f65127f..ca307a3375c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md @@ -11,7 +11,9 @@ dashedName: compound-assignment-with-augmented-addition In programming, it is common to use assignments to modify the contents of a variable. Remember that everything to the right of the equals sign is evaluated first, so we can say: -`myVar = myVar + 5;` +```js +myVar = myVar + 5; +``` to add `5` to `myVar`. Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md index 92b7d49cb42..aa630acf60a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md @@ -11,11 +11,15 @@ dashedName: compound-assignment-with-augmented-division The `/=` operator divides a variable by another number. -`myVar = myVar / 5;` +```js +myVar = myVar / 5; +``` Will divide `myVar` by `5`. This can be rewritten as: -`myVar /= 5;` +```js +myVar /= 5; +``` # --instructions-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md index c05680ba89d..a12d59ef42c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md @@ -11,11 +11,15 @@ dashedName: compound-assignment-with-augmented-multiplication The `*=` operator multiplies a variable by a number. -`myVar = myVar * 5;` +```js +myVar = myVar * 5; +``` will multiply `myVar` by `5`. This can be rewritten as: -`myVar *= 5;` +```js +myVar *= 5; +``` # --instructions-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md index add12120cee..ae6388ad045 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md @@ -11,11 +11,15 @@ dashedName: compound-assignment-with-augmented-subtraction Like the `+=` operator, `-=` subtracts a number from a variable. -`myVar = myVar - 5;` +```js +myVar = myVar - 5; +``` will subtract `5` from `myVar`. This can be rewritten as: -`myVar -= 5;` +```js +myVar -= 5; +``` # --instructions-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md index 39e0530fdc2..fda982efbd3 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md @@ -17,9 +17,7 @@ Having more high cards remaining in the deck favors the player. Each card is ass You will write a card counting function. It will receive a `card` parameter, which can be a number or a string, and increment or decrement the global `count` variable according to the card's value (see table). The function will then return a string with the current count and the string `Bet` if the count is positive, or `Hold` if the count is zero or negative. The current count and the player's decision (`Bet` or `Hold`) should be separated by a single space. -**Example Output** -`-3 Hold` -`5 Bet` +**Example Outputs:** `-3 Hold` or `5 Bet` **Hint** Do NOT reset `count` to 0 when value is 7, 8, or 9. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-string-variables.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-string-variables.md index e4a4b7dc172..21bd4c62f07 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-string-variables.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-string-variables.md @@ -11,7 +11,9 @@ dashedName: declare-string-variables Previously we have used the code -`var myName = "your name";` +```js +var myName = "your name"; +``` `"your name"` is called a string literal. It is a string because it is a series of zero or more characters enclosed in single or double quotes. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md index 9a2f557a57f..f80f5658d92 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md @@ -11,11 +11,15 @@ dashedName: decrement-a-number-with-javascript You can easily decrement or decrease a variable by one with the `--` operator. -`i--;` +```js +i--; +``` is the equivalent of -`i = i - 1;` +```js +i = i - 1; +``` **Note:** The entire line becomes `i--;`, eliminating the need for the equal sign. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md index d77477d3f0c..eff38c75a42 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md @@ -11,7 +11,9 @@ dashedName: delete-properties-from-a-javascript-object We can also delete properties from objects like this: -`delete ourDog.bark;` +```js +delete ourDog.bark; +``` Example: diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md index 9fb92af9b5c..41160925024 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md @@ -13,17 +13,23 @@ When you are defining a string you must start and end with a single or double qu In JavaScript, you can escape a quote from considering it as an end of string quote by placing a backslash (`\`) in front of the quote. -`var sampleStr = "Alan said, \"Peter is learning JavaScript\".";` +```js +var sampleStr = "Alan said, \"Peter is learning JavaScript\"."; +``` This signals to JavaScript that the following quote is not the end of the string, but should instead appear inside the string. So if you were to print this to the console, you would get: -`Alan said, "Peter is learning JavaScript".` +```js +Alan said, "Peter is learning JavaScript". +``` # --instructions-- Use backslashes to assign a string to the `myStr` variable so that if you were to print it to the console, you would see: -`I am a "double quoted" string inside "double quotes".` +```js +I am a "double quoted" string inside "double quotes". +``` # --hints-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md index 42f91172df6..6795eb05641 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md @@ -17,7 +17,9 @@ Remember that `Math.random()` can never quite return a `1` and, because we're ro Putting everything together, this is what our code looks like: -`Math.floor(Math.random() * 20);` +```js +Math.floor(Math.random() * 20); +``` We are calling `Math.random()`, multiplying the result by 20, then passing the value to `Math.floor()` function to round the value down to the nearest whole number. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md index a78f88bc641..d8e528a91a8 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md @@ -15,7 +15,9 @@ To do this, we'll define a minimum number `min` and a maximum number `max`. Here's the formula we'll use. Take a moment to read it and try to understand what this code is doing: -`Math.floor(Math.random() * (max - min + 1)) + min` +```js +Math.floor(Math.random() * (max - min + 1)) + min +``` # --instructions-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md index 704e46fbbda..7de50c056ea 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md @@ -11,11 +11,15 @@ dashedName: increment-a-number-with-javascript You can easily increment or add one to a variable with the `++` operator. -`i++;` +```js +i++; +``` is the equivalent of -`i = i + 1;` +```js +i = i + 1; +``` **Note:** The entire line becomes `i++;`, eliminating the need for the equal sign. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md index f16319caca5..83b498c3b2d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md @@ -11,7 +11,9 @@ dashedName: initializing-variables-with-the-assignment-operator It is common to initialize a variable to an initial value in the same line as it is declared. -`var myVar = 0;` +```js +var myVar = 0; +``` Creates a new variable called `myVar` and assigns it an initial value of `0`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/shopping-list.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/shopping-list.md index 84f22f2b423..3652235f7a2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/shopping-list.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/shopping-list.md @@ -13,7 +13,9 @@ Create a shopping list in the variable `myList`. The list should be a multi-dime The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e. -`["Chocolate Bar", 15]` +```js +["Chocolate Bar", 15] +``` There should be at least 5 sub-arrays in the list. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/store-multiple-values-in-one-variable-using-javascript-arrays.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/store-multiple-values-in-one-variable-using-javascript-arrays.md index d68e86e4925..7a2c41ddb5a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/store-multiple-values-in-one-variable-using-javascript-arrays.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/store-multiple-values-in-one-variable-using-javascript-arrays.md @@ -13,7 +13,9 @@ With JavaScript `array` variables, we can store several pieces of data in one pl You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this: -`var sandwich = ["peanut butter", "jelly", "bread"]` +```js +var sandwich = ["peanut butter", "jelly", "bread"] +``` # --instructions-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md index b60c20c2750..8c946f1c2d2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md @@ -11,7 +11,9 @@ dashedName: storing-values-with-the-assignment-operator In JavaScript, you can store a value in a variable with the assignment operator (`=`). -`myVariable = 5;` +```js +myVariable = 5; +``` This assigns the `Number` value `5` to `myVariable`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md index a106c813c37..6bcf64b6c0a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md @@ -13,11 +13,15 @@ The `parseInt()` function parses a string and returns an integer. It takes a sec The function call looks like: -`parseInt(string, radix);` +```js +parseInt(string, radix); +``` And here's an example: -`var a = parseInt("11", 2);` +```js +var a = parseInt("11", 2); +``` The radix variable says that `11` is in the binary system, or base 2. This example converts the string `11` to an integer `3`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md index edab86583b3..901019fa34f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md @@ -11,7 +11,9 @@ dashedName: use-the-parseint-function The `parseInt()` function parses a string and returns an integer. Here's an example: -`var a = parseInt("007");` +```js +var a = parseInt("007"); +``` The above function converts the string `007` to the integer `7`. If the first character in the string can't be converted into a number, then it returns `NaN`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md index 63d36f81a5f..4e212c27230 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md @@ -16,7 +16,9 @@ The `console.log()` method, which "prints" the output of what's within its paren Here's an example to print the string `Hello world!` to the console: -`console.log('Hello world!');` +```js +console.log('Hello world!'); +``` # --instructions-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md index a009b9bef22..424604da29b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md @@ -10,7 +10,9 @@ dashedName: learn-about-functional-programming Functional programming is a style of programming where solutions are simple, isolated functions, without any side effects outside of the function scope. -`INPUT -> PROCESS -> OUTPUT` +```js +INPUT -> PROCESS -> OUTPUT +``` Functional programming is about: diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md index df10073c551..b1aaabd91e8 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md @@ -14,7 +14,9 @@ For example, `addTogether(2, 3)` should return `5`, and `addTogether(2)` should Calling this returned function with a single argument will then return the sum: -`var sumTwoAnd = addTogether(2);` +```js +var sumTwoAnd = addTogether(2); +``` `sumTwoAnd(3)` returns `5`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-javascript-calorie-counter/part-018.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-javascript-calorie-counter/part-018.md index d536760a873..5231d42570a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-javascript-calorie-counter/part-018.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-javascript-calorie-counter/part-018.md @@ -9,11 +9,15 @@ dashedName: part-18 The `reduce()` method takes a callback function with at least two arguments, an accumulator and a current value: -`function(accumulator, currentValue) { /* code to run */ }` +```js +function(accumulator, currentValue) { /* code to run */ } +``` or using arrow functions: -`(accumulator, currentValue) => { /* code to run */ }` +```js +(accumulator, currentValue) => { /* code to run */ } +``` Insert the above callback function as an argument in the `.reduce()` method. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md index fc3324f4797..b0c80c8ee4c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md @@ -10,7 +10,9 @@ dashedName: make-code-more-reusable-with-the-this-keyword The last challenge introduced a method to the `duck` object. It used `duck.name` dot notation to access the value for the `name` property within the return statement: -`sayName: function() {return "The name of this duck is " + duck.name + ".";}` +```js +sayName: function() {return "The name of this duck is " + duck.name + ".";} +``` While this is a valid way to access the object's property, there is a pitfall here. If the variable name changes, any code referencing the original name would need to be updated as well. In a short object definition, it isn't a problem, but if an object has many references to its properties there is a greater chance for error.