Write a JavaScript program that convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.
Code:
function convertToSpinalCase(str) {
return str.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase().replace(/\s+|_+/g, '-');
}
var result = convertToSpinalCase("hello world")
console.log(result);