2.7 KiB
2.7 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244b5 | Escaping Literal Quotes in Strings | 1 | الهروب من الأسعار الحرفيه في الاوتار |
Description
"
أو '
داخل السلسلة الخاصة بك؟ في JavaScript ، يمكنك الهروب من اقتباس من اعتباره كنهاية لسلسلة الاقتباس عن طريق وضع خط مائل عكسي ( \
) أمام الاقتباس. var sampleStr = "Alan said, \"Peter is learning JavaScript\".";
يشير هذا إلى جافا سكريبت بأن الاقتباس التالي ليس نهاية السلسلة ، بل يجب أن يظهر داخل السلسلة بدلاً من ذلك. لذلك إذا كنت ستطبعه إلى وحدة التحكم ، ستحصل على: Alan said, "Peter is learning JavaScript".
Instructions
myStr
المائلة العكسية لتعيين سلسلة إلى متغير myStr
بحيث إذا كنت myStr
إلى وحدة التحكم ، سترى: I am a "double quoted" string inside "double quotes".
Tests
tests:
- text: يجب عليك استخدام علامتي اقتباس مزدوجتين ( <code>"</code> ) وأربعة علامات اقتباس مزدوجة ( <code>\"</code> ).
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>"</code>) and four escaped double quotes (<code>\"</code>).");'
- text: 'يجب أن يحتوي myStr المتغير على السلسلة: <code>I am a "double quoted" string inside "double quotes".</code>'
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>");'
Challenge Seed
var myStr = ""; // Change this line
After Test
console.info('after the test');
Solution
// solution required