Sometimes, we want to fix .toLowerCase not working with JavaScript.
In this article, we’ll look at how to fix .toLowerCase not working with JavaScript.
How to fix .toLowerCase not working with JavaScript?
To fix .toLowerCase not working with JavaScript, we should convert the value to a string before calling toLowerCase.
For instance, we write
const ans = 334;
const temp = ans.toString().toLowerCase();
alert(temp);
to call ans.toString to convert it to a string.
And then we call toLowerCase to return the string in lower case.
Conclusion
To fix .toLowerCase not working with JavaScript, we should convert the value to a string before calling toLowerCase.
