1.6 KiB
1.6 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
がコンソールに表示されます。
たとえば、変数 const firstName = "Ada"
を作成した場合、firstName.length
プロパティを使用して文字列 Ada
の長さを取得できます。
--instructions--
.length
プロパティを使用して、lastName
変数の文字数をカウントし、それを lastNameLength
に代入してください。
--hints--
// Setup
セクションの変数宣言を変更しないでください。
assert(
code.match(/let lastNameLength = 0;/) &&
code.match(/const lastName = "Lovelace";/)
);
lastNameLength
は 8 になる必要があります。
assert(typeof lastNameLength !== 'undefined' && lastNameLength === 8);
lastName.length
のように、.length
を使用して lastName
の長さを取得する必要があります。
assert(code.match(/=\s*lastName\.length/g) && !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;