freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../basic-javascript/escaping-literal-quotes-in-...

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>&quot;</code> ) وأربعة علامات اقتباس مزدوجة ( <code>\&quot;</code> ).
    testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>&quot;</code>) and four escaped double quotes (<code>&#92;&quot;</code>).");'
  - 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\".", "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