diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 89eef7bb9d7..df6b4d109c5 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -3397,6 +3397,12 @@ "In this lab, you will design a sum all numbers algorithm. This algorithm takes an array of two numbers and returns the sum of those two numbers plus the sum of all the numbers between them." ] }, + "lab-html-entitiy-converter": { + "title": "Implement an HTML Entity Converter", + "intro": [ + "In this lab, you will convert special characters in a string to their corresponding HTML entities." + ] + }, "review-javascript-fundamentals": { "title": "JavaScript Fundamentals Review", "intro": [ diff --git a/client/src/pages/learn/full-stack-developer/lab-html-entitiy-converter/index.md b/client/src/pages/learn/full-stack-developer/lab-html-entitiy-converter/index.md new file mode 100644 index 00000000000..8a9d6008bc5 --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-html-entitiy-converter/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to Implement an HTML Entity Converter +block: lab-html-entitiy-converter +superBlock: full-stack-developer +--- + +## Introduction to Implement an HTML Entity Converter + +In this lab, you will convert special characters in a string to their corresponding HTML entities. diff --git a/curriculum/challenges/_meta/lab-html-entitiy-converter/meta.json b/curriculum/challenges/_meta/lab-html-entitiy-converter/meta.json new file mode 100644 index 00000000000..5f5f8b17014 --- /dev/null +++ b/curriculum/challenges/_meta/lab-html-entitiy-converter/meta.json @@ -0,0 +1,16 @@ +{ + "name": "Implement an HTML Entity Converter", + "isUpcomingChange": false, + "dashedName": "lab-html-entitiy-converter", + "superBlock": "full-stack-developer", + "helpCategory": "JavaScript", + "challengeOrder": [ + { + "id": "a6b0bb188d873cb2c8729495", + "title": "Implement an HTML Entity Converter" + } + ], + "usesMultifileEditor": true, + "blockType": "lab", + "blockLayout": "link" +} diff --git a/curriculum/challenges/english/25-front-end-development/lab-html-entitiy-converter/a6b0bb188d873cb2c8729495.md b/curriculum/challenges/english/25-front-end-development/lab-html-entitiy-converter/a6b0bb188d873cb2c8729495.md new file mode 100644 index 00000000000..d00a5185649 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/lab-html-entitiy-converter/a6b0bb188d873cb2c8729495.md @@ -0,0 +1,105 @@ +--- +id: a6b0bb188d873cb2c8729495 +title: Implement an HTML Entity Converter +challengeType: 26 +dashedName: implement-an-html-entity-converter +--- + +# --description-- + +This lab is about converting special characters in a string with their corresponding HTML entities. + +**Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. You should have a `convertHTML` function that accepts a string as an argument. +1. The `convertHTML` function should return a new string by converting special characters in the argument string to their corresponding HTML entities. + + - `&` should be converted to `&`. + - `<` should be converted to `<`. + - `>` should be converted to `>`. + - `"` should be converted to `"`. + - `'` should be converted to `'`. + +# --hints-- + +You should have a `convertHTML` function. + +```js +assert.isFunction(convertHTML); +``` + +`convertHTML("Dolce & Gabbana")` should return the string `Dolce & Gabbana`. + +```js +assert.match(convertHTML('Dolce & Gabbana'), /Dolce & Gabbana/); +``` + +`convertHTML("Hamburgers < Pizza < Tacos")` should return the string `Hamburgers < Pizza < Tacos`. + +```js +assert.match( + convertHTML('Hamburgers < Pizza < Tacos'), + /Hamburgers < Pizza < Tacos/ +); +``` + +`convertHTML("Sixty > twelve")` should return the string `Sixty > twelve`. + +```js +assert.match(convertHTML('Sixty > twelve'), /Sixty > twelve/); +``` + +`convertHTML('Stuff in "quotation marks"')` should return the string `Stuff in "quotation marks"`. + +```js +assert.match( + convertHTML('Stuff in "quotation marks"'), + /Stuff in "quotation marks"/ +); +``` + +`convertHTML("Schindler's List")` should return the string `Schindler's List`. + +```js +assert.match(convertHTML("Schindler's List"), /Schindler's List/); +``` + +`convertHTML("<>")` should return the string `<>`. + +```js +assert.match(convertHTML('<>'), /<>/); +``` + +`convertHTML("abc")` should return the string `abc`. + +```js +assert.strictEqual(convertHTML('abc'), 'abc'); +``` + +# --seed-- + +## --seed-contents-- + +```js + +``` + +# --solutions-- + +```js +const map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; + +function convertHTML(str) { + return str.replace(/[&<>"']/g, function(char) { + return map[char]; + }); +} +``` diff --git a/curriculum/superblock-structure/full-stack.json b/curriculum/superblock-structure/full-stack.json index 39f630c78ee..248d2bc8acd 100644 --- a/curriculum/superblock-structure/full-stack.json +++ b/curriculum/superblock-structure/full-stack.json @@ -788,6 +788,9 @@ { "dashedName": "lab-sum-all-numbers-algorithm" }, + { + "dashedName": "lab-html-entitiy-converter" + }, { "dashedName": "review-javascript-fundamentals" },