1.5 KiB
1.5 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 587d7b7e367417b2b2512b23 | parseInt 関数を使用する | 1 | https://scrimba.com/c/cm83LSW | 301183 | use-the-parseint-function |
--description--
parseInt() 関数は文字列を解析し、整数を返します。 例:
const a = parseInt("007");
上記の関数は文字列 007 を整数 7 に変換します。 文字列の最初の文字を数値に変換できない場合は NaN を返します。
--instructions--
convertToInteger 関数で parseInt() を使用して、入力文字列 str を整数に変換し、それを返してください。
--hints--
convertToInteger では parseInt() 関数を使用する必要があります。
assert(/parseInt/g.test(code));
convertToInteger("56") は数値を返す必要があります。
assert(typeof convertToInteger('56') === 'number');
convertToInteger("56") は 56 を返す必要があります。
assert(convertToInteger('56') === 56);
convertToInteger("77") は 77 を返す必要があります。
assert(convertToInteger('77') === 77);
convertToInteger("JamesBond") は NaN を返す必要があります。
assert.isNaN(convertToInteger('JamesBond'));
--seed--
--seed-contents--
function convertToInteger(str) {
}
convertToInteger("56");
--solutions--
function convertToInteger(str) {
return parseInt(str);
}