Files
freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string.md
2022-10-20 09:13:17 -07:00

1.7 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bd7123c9c451eddfaeb5bdef استخدم رمز آلأقواس (Bracket Notation) للعثور على آخر حرف في سلسلة (String) 1 https://scrimba.com/c/cBZQGcv 18342 use-bracket-notation-to-find-the-last-character-in-a-string

--description--

للحصول على آخر حرف من سلسلة (String)، يمكنك طرح واحد من طول السلسلة (String).

على سبيل المثال، إذا const firstName = "Ada"، يمكنك الحصول على قيمة الحرف الأخير من السلسلة باستخدام firstName[firstName.length - 1].

مثال:

const firstName = "Ada";
const lastLetter = firstName[firstName.length - 1];

lastLetter سيكون لها قيمة تساوي السلسلة a.

--instructions--

استخدم رمز الأقواس للعثور على الحرف الأخير في المتغير lastName.

تلميح: حاول النظر إلى المثال أعلاه إذا كنت عالق.

--hints--

lastLetterOfLastName يجب أن يكون الحرف e.

assert(lastLetterOfLastName === 'e');

يجب عليك استخدام .length للحصول على آخر حرف.

assert(code.match(/\.length/g).length > 0);

--seed--

--after-user-code--

(function(v){return v;})(lastLetterOfLastName);

--seed-contents--

// Setup
const lastName = "Lovelace";

// Only change code below this line
const lastLetterOfLastName = lastName; // Change this line

--solutions--

const lastName = "Lovelace";
const lastLetterOfLastName = lastName[lastName.length - 1];