Files
freeCodeCamp/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-character-in-a-string.md
2022-03-23 15:22:04 +01:00

1.6 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bd7123c9c450eddfaeb5bdef ブラケット記法を使用して文字列の N 番目の文字を取得する 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--

ブラケット記法を使用して、lastName 変数の 3 番目の文字と等しくなるように、thirdLetterOfLastName を設定してみましょう。

ヒント: 解答できない場合は上記の例を参考にしてください。

--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];