It works fine for me - if I feed your code into an online
Javascript Tester[
^] :
function snakeToCamel(str) {
let answer = str.split("_").map(function(word) {
return word[0].toUpperCase() + word.slice(1,word.length);
})
return answer.join("");
}
snakeToCamel("hello_world");
I get what I would expect:
"HelloWorld"
Check your calling code and see exactly what you are passing to the function.