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 replace() with regex. Then use toLowerCase()
replace()
toLowerCase()
let camel = (s) => s.replace(/[A-Z]/g, '-$&').toLowerCase() console.log(camel('fooBar')) console.log(camel('FooBar'))
`