function splitCamelCase(string) {
return string.split(/([A-Z])/g)
.map(function(x,i) {
if (x === x.toUpperCase()) {
x[i+1] = x + x[i+1]
x = " "
}
})
.join('')
}
This code is supposed to split camel case text at each uppercase letter, but it just turns every item of the array to undefined As far as I understand nothing here is changing the values to something they shouldnt be
Tried changing "x[i+1] = x + x[i+1]" to " = ${x}${x[i+1]}
, nothing happened
Tried specifying the array in the map function parameters, notthing changed