2.2 KiB
2.2 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7b84367417b2b2512b37 | Catch Mixed Usage of Single and Double Quotes | 1 | 抓住单引号和双引号的混合使用 |
Description
//这些是正确的:当然,只使用一种报价样式是可以的。您可以使用反斜杠(\)转义字符来转义字符串中的引号:
const grouchoContraction =“我度过了一个美好的夜晚,但事实并非如此。”;
const quoteInString =“Groucho Marx曾经说过'引用我的话说我被误引了'。”;
//这是不正确的:
const uhOhGroucho ='我度过了一个美妙的夜晚,但这不是它。';
//正确使用相同的引号:
const allSameQuotes ='我度过了一个非常精彩的夜晚,但这不是它。';
Instructions
href
值使用不同的引号,或者转义现有的引号。在整个字符串周围保留双引号。 Tests
tests:
- text: '您的代码应该通过更改或转义它们来修复<code>href</code>值“#Home”周围的引号。'
testString: 'assert(code.match(/<a href=\s*?("|\\")#Home\1\s*?>/g), "Your code should fix the quotes around the <code>href</code> value "#Home" by either changing or escaping them.");'
- text: 您的代码应该在整个字符串周围保留双引号。
testString: 'assert(code.match(/"<p>.*?<\/p>";/g), "Your code should keep the double quotes around the entire string.");'
Challenge Seed
let innerHtml = "<p>Click here to <a href="#Home">return home</a></p>";
console.log(innerHtml);
Solution
// solution required