JSFiddle - React, Tailwind, and code Playground
HTML
<p id="test_repeat">Here goes the char length asterisk repeat</p>
<p id="test_replace">Here goes the integer to asterisk replacement</p>
JavaScript
//FOR REPEAT
//adapted from http://stackoverflow.com/questions/202605/repeat-string-javascript
String.prototype.repeat = function( num )
{
return new Array( num + 1 ).join( this );
}
var x = prompt('Give it some numbers!');
//REPEAT - All characters
document.getElementById('test_repeat').innerHTML = "*".repeat(x.length);
//REPLACE - Only digits
document.getElementById('test_replace').innerHTML = x.replace(/\d/g, "*");
//TRY WITH just digits and then a mix of chars, so you can see the difference.