Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

1.8 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7b7e367417b2b2512b22 Use the parseInt Function with a Radix 1 将parseInt函数与Radix一起使用

Description

parseInt()函数解析字符串并返回一个整数。它需要一个基数的第二个参数它指定字符串中数字的基数。基数可以是2到36之间的整数。函数调用如下 parseInt(string, radix);这是一个例子: var a = parseInt("11", 2);基数变量表示“11”在二进制系统或基数2中。此示例将字符串“11”转换为整数3。

Instructions

convertToInteger函数中使用parseInt() ,以便将二进制数转换为整数并返回它。

Tests

tests:
  - text: <code>convertToInteger</code>应该使用<code>parseInt()</code>函数
    testString: assert(/parseInt/g.test(code));
  - text: <code>convertToInteger(&quot;10011&quot;)</code>应该返回一个数字
    testString: assert(typeof(convertToInteger("10011")) === "number");
  - text: <code>convertToInteger(&quot;10011&quot;)</code>应该返回19
    testString: assert(convertToInteger("10011") === 19);
  - text: <code>convertToInteger(&quot;111001&quot;)</code>应该返回57
    testString: assert(convertToInteger("111001") === 57);
  - text: <code>convertToInteger(&quot;JamesBond&quot;)</code>应该返回NaN
    testString: assert.isNaN(convertToInteger("JamesBond"));

Challenge Seed

function convertToInteger(str) {

}

convertToInteger("10011");

Solution

// solution required