<div className="mt-2 font-sidebar capitalize">
{item.title}
</div>
item.title
can be any string (from backend) for example "all products", "most liked", "featured items", etc.
I want a way to replace the space in item.title
with
so that when rendered in HTML it still has a space - This is for a specific use case.
I would really appreciate your help.
CodePudding user response:
You can do like this:
{item.title.replaceAll(' ', '\u00a0')};
you can use replace()
if you are sure there is only 1 space, so i suggest to use replaceAll()
Instead of using the you can use the Unicode character which
refers to (U 00A0):