HI,
Can anyone please explain how val is being used?
map() is using an anonymous function expression with val as its parameter. I see val also referenced inside the function. I don’t quite understand how val is being used as there is no argument being passed to the parameter val.
function titleCase(str) {
var convertToArray = str.toLowerCase().split(" ");
var result = convertToArray.map(function(val){
return val.replace(val.charAt(0), val.charAt(0).toUpperCase());
});
return result.join(" ");
}
titleCase("I'm a little tea pot");