mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-28 00:01:13 -05:00
1.7 KiB
1.7 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| bd7123c9c450eddfaeb5bdef | استخدم علامات الأقواس للعثور على حرف معين في مقطع | 1 | https://scrimba.com/c/cWPVJua | 18343 | use-bracket-notation-to-find-the-nth-character-in-a-string |
--description--
يمكنك أيضًا استخدام علامات الأقواس للحصول على حرف في مواقع أخرى داخل مقطع.
تذكر أن أجهزة الكمبيوتر تبدأ في العد من 0، لذا فإن الحرف الأول هو في الواقع الحرف الصفر.
مثال:
const firstName = "Ada";
const secondLetterOfFirstName = firstName[1];
سيحتوي secondLetterOfFirstName على قيمة مقطع d.
--instructions--
دعونا نحاول تعيين thirdLetterOfLastName مساوية للحرف الثالث من متغير lastName باستخدام علامات الأقواس.
تلميح: حاول النظر إلى المثال أعلاه إذا كنت عالق.
--hints--
يجب أن يحتوي متغير thirdLetterOfLastName على قيمة v.
assert(thirdLetterOfLastName === 'v');
يجب عليك استخدام علامات الأقواس.
assert(code.match(/thirdLetterOfLastName\s*=\s*lastName\s*\[\s*\d\s*\]/));
--seed--
--after-user-code--
(function(v){return v;})(thirdLetterOfLastName);
--seed-contents--
// Setup
const lastName = "Lovelace";
// Only change code below this line
const thirdLetterOfLastName = lastName; // Change this line
--solutions--
const lastName = "Lovelace";
const thirdLetterOfLastName = lastName[2];