Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.4 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
587d7b7e367417b2b2512b22 使用 parseInt 函数并传入一个基数 1 https://scrimba.com/c/c6K4Kh3 301182 use-the-parseint-function-with-a-radix

--description--

parseInt()函数解析一个字符串并返回一个整数。它同时可接受第二个参数一个介于2和36之间的整数表示字符串的基数。

函数调用如下所示:

parseInt(string, radix);

示例:

var a = parseInt("11", 2);

参数 2 表示 "11" 使用二进制数值系统。此示例将字符串 "11" 转换为整数 3。

--instructions--

convertToIntegerparseInt()函数把二进制数转换成十进制并返回。

--hints--

convertToInteger中应该使用parseInt()函数。

assert(/parseInt/g.test(code));

convertToInteger("10011")应该返回一个数字。

assert(typeof convertToInteger('10011') === 'number');

convertToInteger("10011")应该返回 19。

assert(convertToInteger('10011') === 19);

convertToInteger("111001")应该返回 57。

assert(convertToInteger('111001') === 57);

convertToInteger("JamesBond")应该返回 NaN。

assert.isNaN(convertToInteger('JamesBond'));

--seed--

--seed-contents--

function convertToInteger(str) {

}

convertToInteger("10011");

--solutions--

function convertToInteger(str) {
  return parseInt(str, 2);
}