Categories
JavaScript Answers

How to replace all “%20” with a space with JavaScript?

Spread the love

Sometimes, we want to replace all "%20" with a space with JavaScript.

In this article, we’ll look at how to replace all "%20" with a space with JavaScript.

How to replace all "%20" with a space with JavaScript?

To replace all "%20" with a space with JavaScript, we call the decodeURI function.

For instance, we write

const s = decodeURI(str);

to call decodeURI with str to return a string with all '%20' substrings removed from it.

Conclusion

To replace all "%20" with a space with JavaScript, we call the decodeURI function.

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 *