--- id: a6b0bb188d873cb2c8729495 title: Convert HTML Entities isRequired: true challengeType: 5 videoUrl: '' localeTitle: 转换HTML实体 --- ## Description
将字符串中的字符&<>" (双引号)和' (撇号)转换为相应的HTML实体。如果卡住,请记住使用Read-Search-Ask 。尝试配对程序。写下你的自己的代码。
## Instructions
## Tests
```yml tests: - text: convertHTML("Dolce & Gabbana")应该返回Dolce &​amp; Gabbana 。 testString: assert.match(convertHTML("Dolce & Gabbana"), /Dolce & Gabbana/); - text: convertHTML("Hamburgers < Pizza < Tacos")应该返回Hamburgers &​lt; Pizza &​lt; Tacos 。 testString: assert.match(convertHTML("Hamburgers < Pizza < Tacos"), /Hamburgers < Pizza < Tacos/); - text: convertHTML("Sixty > twelve")应返回Sixty &​gt; twelve 。 testString: assert.match(convertHTML("Sixty > twelve"), /Sixty > twelve/); - text: 'convertHTML('Stuff in "quotation marks"')应该convertHTML('Stuff in "quotation marks"')返回Stuff in &​quot;quotation marks&​quot; 。' testString: assert.match(convertHTML('Stuff in "quotation marks"'), /Stuff in "quotation marks"/); - text: 'convertHTML("Schindler's List")应该返回Schindler&​apos;s List 。' testString: assert.match(convertHTML("Schindler's List"), /Schindler's List/); - text: convertHTML("<>")应返回&​lt;&​gt; 。 testString: assert.match(convertHTML('<>'), /<>/); - text: convertHTML("abc")应该返回abc 。 testString: assert.strictEqual(convertHTML('abc'), 'abc'); ```
## Challenge Seed
```js function convertHTML(str) { // :) return str; } convertHTML("Dolce & Gabbana"); ```
## Solution
```js // solution required ```