Problem

code image

Javascript- how to replace all spaces with dashes

In this very short article, we will learn how to replace spaces with dashes using the .replace method in JS. And that is all! Very simple regex In case you want to create URL paths then you may want to consider also using .toLowerCase() And that is all! God speed!