--- id: 587d7b7e367417b2b2512b23 title: Use the parseInt Function challengeType: 1 videoUrl: '' localeTitle: Use a função parseInt --- ## Description
A função parseInt() analisa uma string e retorna um inteiro. Aqui está um exemplo: var a = parseInt("007"); A função acima converte a string "007" em um inteiro 7. Se o primeiro caractere da string não puder ser convertido em um número, ele retornará NaN .
## Instructions
Use parseInt() na função convertToInteger para converter a string de entrada str em um inteiro e retorná-lo.
## Tests
```yml tests: - text: convertToInteger deve usar a função parseInt() testString: 'assert(/parseInt/g.test(code), "convertToInteger should use the parseInt() function");' - text: convertToInteger("56") deve retornar um número testString: 'assert(typeof(convertToInteger("56")) === "number", "convertToInteger("56") should return a number");' - text: convertToInteger("56") deve retornar 56 testString: 'assert(convertToInteger("56") === 56, "convertToInteger("56") should return 56");' - text: convertToInteger("77") deve retornar 77 testString: 'assert(convertToInteger("77") === 77, "convertToInteger("77") should return 77");' - text: convertToInteger("JamesBond") deve retornar NaN testString: 'assert.isNaN(convertToInteger("JamesBond"), "convertToInteger("JamesBond") should return NaN");' ```
## Challenge Seed
```js function convertToInteger(str) { } convertToInteger("56"); ```
## Solution
```js // solution required ```