Above answer can be considered to be confusing a little. String methods are not modifying original object. They return new object. It must be:
var str = "Sonic Free Games";
str = str.replace(/\s+/g, '-').toLowerCase(); //new object assigned to var str