Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

1.9 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244b5 Escaping Literal Quotes in Strings 1 逃避字符串中的字面引用

Description

在定义字符串时,必须以单引号或双引号开头和结尾。当你需要一个文字报价会发生什么: "还是' 你的字符串里面在JavaScript中你可以放置一个反斜杠 (从考虑到它作为字符串报价的最终逃脱报价\在引号前)。 var sampleStr = "Alan said, \"Peter is learning JavaScript\".";这告诉JavaScript以下引用不是字符串的结尾而是应该出现在字符串中。所以如果要将它打印到控制台你会得到 Alan said, "Peter is learning JavaScript".

Instructions

使用反斜杠将字符串分配给myStr变量,这样如果要将其打印到控制台,您会看到: I am a "double quoted" string inside "double quotes".

Tests

tests:
  - text: 您应该使用两个双引号( <code>&quot;</code> )和四个转义双引号( <code>\&quot;</code> )。
    testString: assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2);
  - text: 变量myStr应该包含字符串 <code>I am a &quot;double quoted&quot; string inside &quot;double quotes&quot;.</code>
    testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".");'

Challenge Seed

var myStr = ""; // Change this line

After Test

console.info('after the test');

Solution

// solution required