A Pen by Lyle Reed

Thumbnail
This awesome code was written by Ticolyle, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Ticolyle ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  Lyle Reed</title>
  
  
  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/Ticolyle/a-pen-by-lyle-reed-VrmERQ */
function add2digits(num) {
  var ans = num.toString().split('');
  if (ans.length != 2) {
    return 'Not a valid input';
  } else {
    return parseInt(ans[0]) + parseInt(ans[1]);
  }
}

add2digits(21);
add2digits(400);

Comments