5👍
✅
1👍
The trim method only removes spaces at the beginning of the string. What you need is replacing the spaces with nothing with the replace method using regex:
category.replace(/\s/g, "").toLowerCase();
Source:stackexchange.com
5👍
1👍
The trim method only removes spaces at the beginning of the string. What you need is replacing the spaces with nothing with the replace method using regex:
category.replace(/\s/g, "").toLowerCase();