actually I want to display the users from my db in a table..I have a password that I want to display points instead of it..anyone could help me doing this? this how I display the password
<td> <Lock size={14} color=" #273746 " /> {item.password}</td>
I would be very thankful if anyone of you can help mee
CodePudding user response:
You can use Javascript string replace function. You can find it here : https://www.w3schools.com/jsref/jsref_replace.asp
{item.password.replace({item.password}, "**********")}
CodePudding user response:
If you want to generate a string of asterisks with the same length as the original string (e.g. item.password
), then you can utilize the String.prototype.repeat
method:
"*".repeat("mysecretpassword".length); // "****************"
However, I would advise showing a constant number of asterisks not related to the passwords because it is significantly easier to hack a password if a malicious person knew the number of characters was in it by counting the asterisks if they had, for example, taken a picture of the hidden passwords list. Therefore, I think you're best bet would be to just hard code a certain number of asterisks and show it for all of the passwords:
"**********"