Files
freeCodeCamp/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string.md
freeCodeCamp's Camper Bot e6b05ee25d chore(i18n,learn): processed translations (#54537)
Co-authored-by: Naomi <nhcarrigan@gmail.com>
2024-04-26 12:26:37 +07:00

1.8 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bd7123c9c448eddfaeb5bdef 文字列の長さの取得 1 https://scrimba.com/c/cvmqEAd 18182 find-the-length-of-a-string

--description--

文字列変数または文字列リテラルの後に .length と記述することで、String 値の長さを取得することができます。

console.log("Alan Peter".length);

コンソールに 10 の値が表示されます。 なお、"Alan" と "Peter" の間のスペースも文字としてカウントされます。

たとえば、変数 const firstName = "Ada" を作成した場合、firstName.length プロパティを使用して文字列 Ada の長さを取得できます。

--instructions--

.length プロパティを使って、lastNameLengthlastName の文字数を設定します。

--hints--

// Setup セクションの変数宣言を変更しないでください。

assert(
  __helpers.removeJSComments(code).match(/let lastNameLength = 0;/) &&
    __helpers.removeJSComments(code).match(/const lastName = "Lovelace";/)
);

lastNameLength は 8 になる必要があります。

assert(typeof lastNameLength !== 'undefined' && lastNameLength === 8);

lastName.length のように、.length を使用して lastName の長さを取得する必要があります。

assert(__helpers.removeJSComments(code).match(/=\s*lastName\.length/g) && !__helpers.removeJSComments(code).match(/lastName\s*=\s*8/));

--seed--

--seed-contents--

// Setup
let lastNameLength = 0;
const lastName = "Lovelace";

// Only change code below this line
lastNameLength = lastName;

--solutions--

let lastNameLength = 0;
const lastName = "Lovelace";
lastNameLength = lastName.length;