Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7b7e367417b2b2512b23 Use the parseInt Function 1 301183 use-the-parseint-function

--description--

The parseInt() function parses a string and returns an integer. Here's an example:

const a = parseInt("007");

The above function converts the string 007 to the integer 7. If the first character in the string can't be converted into a number, then it returns NaN.

--instructions--

Use parseInt() in the convertToInteger function so it converts the input string str into an integer, and returns it.

--hints--

convertToInteger should use the parseInt() function

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

convertToInteger("56") should return a number

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

convertToInteger("56") should return 56

assert(convertToInteger('56') === 56);

convertToInteger("77") should return 77

assert(convertToInteger('77') === 77);

convertToInteger("JamesBond") should return NaN

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

--seed--

--seed-contents--

function convertToInteger(str) {

}

convertToInteger("56");

--solutions--

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