Replacing substrings in a string to a common string

Replacing substrings in a string to a common string

I have a string that contains few substrings separated with spaces.
I want to replcae all spaces with a two character string: " -" (space with hyphen).
example:
original string : "aaaaa    bbbbbb abc"
required string: "aaaaa -bbbbbb -abc"
I tried javascript replcae but it doesn't work.
Can someone help please?
I. Sher