Update palindrome.js

Line 12 fixed code so all spaces will be replaced and not just the first one.

Line 19 and 20 fixed to include newString variable to prevent stack level getting too deep.