Files

31 lines
588 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Use the parseInt Function
---
# Use the parseInt Function
---
## Problem Explanation
2019-01-15 14:54:07 -08:00
The ```parseInt()``` function will take any ```string``` parameter representing a number and return its integer value.
2018-10-12 15:37:13 -04:00
---
## Hints
### Hint 1
2019-01-15 14:54:07 -08:00
```parseInt()``` should be used inside your function and return whatever ```str``` is, assuming that ```str``` is a string representing some number.
2018-10-12 15:37:13 -04:00
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2019-01-15 14:54:07 -08:00
```javascript
function convertToInteger(str) {
return parseInt(str);
2019-01-15 14:54:07 -08:00
}
2018-10-12 15:37:13 -04:00
2019-01-15 14:54:07 -08:00
convertToInteger("56");
```
</details>