Using parseInt in a function to return an integer or not

this function uses the parseInt function to return a proper integer or an error code if it can't. So this demo should return NaN for the Not an Int (x1235) and The int for the 00001235. I think that NaN stands for Not a Number (but i could be wrong... )
function using_parseint(maybe_an_int) {
  var result_html = document.getElementById("result");
  var parseint_result = parseInt(maybe_an_int);
  result_html.innerHTML = parseint_result;
  return parseint_result;
}

HTML

<div id='result' class='mb-3 alert alert-primary'>..</div>
<button onclick='using_parseint("x1235");' class='btn btn-primary mb-1'>Not an Int (x1235)</button>
<button onclick='using_parseint("00001235");' class='btn btn-primary mb-1'>This is an int, once converted. (00001235)</button>

Result

..

External Link for Using parseInt in a function to return an integer or not

Other Items in javascript
Page Views

This page has been viewed 320 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
In this case my anchor this week becomes driving almost 2hrs outside of Atlanta to one of my favorite hard core gyms in the world.. MetroFlex aka The Dungeon. The gym owners turn the heat way up so it becomes a fun sweat box and the gym members just watch from afar and leave me alone. I happily drive myself long distances to find MY ANCHOR. Our anchor allows us to have balance, focus and be as productive as possible. And if you're in the middle of a heavy set and your headphones start to fall off your head, like mine did here.. well.. f*ck the headphones. Let em break and fall. You can always get a new pair, but the iron ain't ever gonna lift itself.
Unknown