feat: add html entities lab to full stack curriculum (#61716)

Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com>
This commit is contained in:
Ilenia
2025-08-08 21:22:36 +02:00
committed by GitHub
parent 03bbdbe584
commit 7217d60f5c
5 changed files with 139 additions and 0 deletions
+6
View File
@@ -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": [
@@ -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.
@@ -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"
}
@@ -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 `&amp;`.
- `<` should be converted to `&lt;`.
- `>` should be converted to `&gt;`.
- `"` should be converted to `&quot;`.
- `'` should be converted to `&apos;`.
# --hints--
You should have a `convertHTML` function.
```js
assert.isFunction(convertHTML);
```
`convertHTML("Dolce & Gabbana")` should return the string `Dolce &amp; Gabbana`.
```js
assert.match(convertHTML('Dolce & Gabbana'), /Dolce &amp; Gabbana/);
```
`convertHTML("Hamburgers < Pizza < Tacos")` should return the string `Hamburgers &lt; Pizza &lt; Tacos`.
```js
assert.match(
convertHTML('Hamburgers < Pizza < Tacos'),
/Hamburgers &lt; Pizza &lt; Tacos/
);
```
`convertHTML("Sixty > twelve")` should return the string `Sixty &gt; twelve`.
```js
assert.match(convertHTML('Sixty > twelve'), /Sixty &gt; twelve/);
```
`convertHTML('Stuff in "quotation marks"')` should return the string `Stuff in &quot;quotation marks&quot;`.
```js
assert.match(
convertHTML('Stuff in "quotation marks"'),
/Stuff in &quot;quotation marks&quot;/
);
```
`convertHTML("Schindler's List")` should return the string `Schindler&apos;s List`.
```js
assert.match(convertHTML("Schindler's List"), /Schindler&apos;s List/);
```
`convertHTML("<>")` should return the string `&lt;&gt;`.
```js
assert.match(convertHTML('<>'), /&lt;&gt;/);
```
`convertHTML("abc")` should return the string `abc`.
```js
assert.strictEqual(convertHTML('abc'), 'abc');
```
# --seed--
## --seed-contents--
```js
```
# --solutions--
```js
const map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&apos;'
};
function convertHTML(str) {
return str.replace(/[&<>"']/g, function(char) {
return map[char];
});
}
```
@@ -788,6 +788,9 @@
{
"dashedName": "lab-sum-all-numbers-algorithm"
},
{
"dashedName": "lab-html-entitiy-converter"
},
{
"dashedName": "review-javascript-fundamentals"
},