How to replace spaces with dashes in JavaScript

Strings
By Jad Joubran · 
Last updated Dec 16, 2017
const text = "codetogo saved me tons of time";

text.replace(/ /g, "-");
codetogo-saved-me-tons-of-time
Learn JavaScript step by step

Consider Learn Programming which is tailored for absolute beginners.