Wondering if anyone can spot where I am going wrong in my code. (It is part of a larger function)
split.map((x, i) => {
if(x.match(/[A-Z]/)){
let result = res.toString()
final = (result[i].toUpperCase() + res.slice(1)).replace(/,/g, '')
} else {
final = res.join('')
}
})
The first half works fine when there is no else statement after it (or before it) but doesn’t work when there is the else statement. Basically it just always runs the else statement… ?
Is it a true or a false value? Because you’re using it in an if statement, and you want the test you’re doing on the string to return true or false depending on what x is. Does match do this?