{"size": 881, "ext": "js", "max_stars_repo_path": "CodeWars/JavaScript/String to integer conversion.js", "max_stars_repo_name": "nirgn975/CodeWars", "max_stars_repo_stars_event_min_datetime": "2017-01-13T11:00:21.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-03T11:51:47.000Z", "max_issues_repo_path": "CodeWars/JavaScript/String to integer conversion.js", "max_issues_repo_name": "nirgn975/CodeWars", "max_issues_repo_issues_event_min_datetime": "2017-08-02T07:06:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-04T21:12:41.000Z", "max_forks_repo_path": "CodeWars/JavaScript/String to integer conversion.js", "max_forks_repo_name": "nirgn975/CodeWars", "max_forks_repo_forks_event_min_datetime": "2017-08-02T16:47:00.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-31T17:26:04.000Z"}
{"max_stars_count": 28, "max_issues_count": 3, "max_forks_count": 15, "avg_line_length": 31.4642857143, "max_line_length": 159, "alphanum_fraction": 0.6923950057}
/**
JavaScript provides a built-in parseInt method.

It can be used like this:
* `parseInt("10")` returns `10`
* `parseInt("10 apples")` also returns `10`

We would like it to return `"NaN"` (as a string) for the second case because the input string is not a valid number.

You are asked to write a `myParseInt` method with the following rules:
* It should make the conversion if the given string only contains a single integer value (and eventually spaces - including tabs, line feeds... - at both ends)
* For all other strings (including the ones representing float values), it should return NaN
* It should assume that all numbers are not signed and written in base 10
**/

function myParseInt(str) {
  if(str.match(/[a-z.~!@#$]/i)) {
    return "NaN";
  }

  if (parseInt(str) === parseInt(str.replace(/ /g,''))) {
    return parseInt(str);
  } else {
    return "NaN";
  }

}
