I want to convert these strings:
fooBar FooBar
into:
foo-bar -foo-bar
How would I do this in JavaScript the m
You can use
const makeItDashed = camelCased => { let dashed = `` camelCased.split(``).map(ch => {{dashed += ch.toUpperCase() == ch ? `-${ch.toLowerCase()}` : ch}}) return dashed } console.log(makeItDashed(`fooBar`)) console.log(makeItDashed(`FooBar`))