password generator getting "RangeError: Maximum call stack size exceeded"

  html, javascript, jquery, node.js, random

I am working on a password generator but I keep getting RangeError: Maximum call stack size exceeded

What does this mean? Here is the code that gives this error…

The code is supposed to get the value of the text box when the "Get" button is clicked and use it as the "allowed charaters" when generating the random characters or random password then console.log it.

function makeid(length) {
  var result = [];
  console.log(makeid(5));
  
  var chars = document.getElementById("myInput").value;
  var characters = chars; //fix this
  var charactersLength = characters.length;
  for (var i = 0; i < length; i++) {
    result.push(characters.charAt(Math.floor(Math.random() *
      charactersLength)));
  }
  return result.join('');
}
<input type="text" placeholder="Type something..." id="myInput">
<button type="button" onclick="makeid();">Get</button>

Source: Ask Javascript Questions

LEAVE A COMMENT