From 99f4b9f1ff120c5cbfaae3961d3cffa2e872913a Mon Sep 17 00:00:00 2001 From: John Kennedy Date: Fri, 20 Jul 2018 00:17:26 +0100 Subject: [PATCH] fix(challenges): improve template literal challenge instructions --- .../es6.json | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/challenges/02-javascript-algorithms-and-data-structures/es6.json b/challenges/02-javascript-algorithms-and-data-structures/es6.json index 693745ac67b..008fd3e8529 100644 --- a/challenges/02-javascript-algorithms-and-data-structures/es6.json +++ b/challenges/02-javascript-algorithms-and-data-structures/es6.json @@ -990,12 +990,14 @@ "id": "587d7b8a367417b2b2512b4e", "title": "Create Strings using Template Literals", "description": [ - "A new feature of ES6 is the template literal. This is a special type of string that allows you to use string interpolation features to create strings.", + "A new feature of ES6 is the template literal. This is a special type of string that makes creating complex strings easier.", + "Template literals allow you to create multi-line strings and to use string interpolation features to create strings.", "Consider the code below:", - "
const person = {
  name: \"Zodiac Hasbro\",
  age: 56
};

// string interpolation
const greeting = `Hello, my name is ${person.name}!
I am ${person.age} years old.`;

console.log(greeting); // prints
// Hello, my name is Zodiac Hasbro!
// I am 56 years old.
", + "
const person = {
  name: \"Zodiac Hasbro\",
  age: 56
};

// Template literal with multi-line and string interpolation
const greeting = `Hello, my name is ${person.name}!
I am ${person.age} years old.`;

console.log(greeting); // prints
// Hello, my name is Zodiac Hasbro!
// I am 56 years old.
", "A lot of things happened there.", - "Firstly, the ${variable} syntax used above is a place holder. Basically, you won't have to use concatenation with the + operator anymore. To add variables to strings, you just drop the variable in a template string and wrap it with ${ and }.", - "Secondly, the example uses backticks (`), not quotes (' or \"), to wrap the string. Notice that the string is multi-line.", + "Firstly, the example uses backticks (`), not quotes (' or \"), to wrap the string.", + "Secondly, notice that the string is multi-line, both in the code and the output. This saves inserting \n within strings.", + "The ${variable} syntax used above is a placeholder. Basically, you won't have to use concatenation with the + operator anymore. To add variables to strings, you just drop the variable in a template string and wrap it with ${ and }. Similarly, you can include other expressions in your string literal, for example ${a + b}.", "This new way of creating strings gives you more flexibility to create robust strings.", "
", "Use template literal syntax with backticks to display each entry of the result object's failure array. Each entry should be wrapped inside an li element with the class attribute text-warning, and listed within the resultDisplayArray." @@ -1003,7 +1005,7 @@ "tests": [ { "text": - "resultDisplayArray is a list containing result failure messages.", + "resultDisplayArray is an array containing result failure messages.", "testString": "assert(typeof makeList(result.failure) === 'object' && resultDisplayArray.length === 3, 'resultDisplayArray is a list containing result failure messages.');" }, @@ -1043,9 +1045,9 @@ "}", "/**", " * makeList(result.failure) should return:", - " * [
  • no-var
  • ,", - " *
  • var-on-top
  • , ", - " *
  • linebreak
  • ]", + " * [ `
  • no-var
  • `,", + " * `
  • var-on-top
  • `, ", + " * `
  • linebreak
  • ` ]", " **/", "const resultDisplayArray = makeList(result.failure);" ],