diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.english.md index 0d357af135..c0a45af601 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.english.md @@ -20,6 +20,7 @@ This new way of creating strings gives you more flexibility to create robust str ## Instructions
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. +Use an iterator method (any kind of loop) to get the desired output.
## Tests @@ -31,9 +32,10 @@ tests: testString: assert(typeof makeList(result.failure) === 'object' && resultDisplayArray.length === 3, 'resultDisplayArray is a list containing result failure messages.'); - text: resultDisplayArray is the desired output. testString: assert(makeList(result.failure).every((v, i) => v === `
  • ${result.failure[i]}
  • ` || v === `
  • ${result.failure[i]}
  • `), 'resultDisplayArray is the desired output.'); - - text: Template strings were used - testString: getUserInput => assert(getUserInput('index').match(/`.*`/g), 'Template strings were not used'); - + - text: Template strings and expression interpolation should be used + testString: getUserInput => assert(getUserInput('index').match(/(`.*\${.*}.*`)/), 'Template strings and expression interpolation should be used'); + - text: An iterator should be used + testString: getUserInput => assert(getUserInput('index').match(/for|map|reduce|forEach|while/), 'An iterator should be used'); ``` @@ -77,6 +79,24 @@ const resultDisplayArray = makeList(result.failure);
    ```js -// solution required +const result = { + success: ["max-length", "no-amd", "prefer-arrow-functions"], + failure: ["no-var", "var-on-top", "linebreak"], + skipped: ["id-blacklist", "no-dup-keys"] +}; +function makeList(arr) { + "use strict"; + + const resultDisplayArray = arr.map(val => `
  • ${val}
  • `); + + return resultDisplayArray; +} +/** + * makeList(result.failure) should return: + * [ `
  • no-var
  • `, + * `
  • var-on-top
  • `, + * `
  • linebreak
  • ` ] + **/ +const resultDisplayArray = makeList(result.failure); ```