Categories
JavaScript Answers

How to fix .toLowerCase not working with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *