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.6 KiB

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7b7e367417b2b2512b23 Use the parseInt Function 1 使用parseInt函数

Description

parseInt()函数解析字符串并返回一个整数。这是一个例子: var a = parseInt("007");上面的函数将字符串“007”转换为整数7.如果字符串中的第一个字符无法转换为数字,则返回NaN

Instructions

convertToInteger函数中使用parseInt() ,以便将输入字符串str转换为整数,然后返回它。

Tests

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

Challenge Seed

function convertToInteger(str) {

}

convertToInteger("56");

Solution

// solution required