I have the following array variable, I want to return the given array where each of element's last character to be in Uppercase using javascript, I have tried like below, but I am getting undefined unfortunately, Could you please anyone help me to get the desired output like below. Thanks in advance.
Desired Output: [onE, twO, threE, fouR]
var arr = ['one', 'two', 'three', 'four'];
var res = arr.map((item) => {
item.substr(arr.length) + item.charAt(arr.length -1).toUpperCase();
});
console.log(res);//[undefined, undefined, undefined, undefined]