I am trying to remove the last characters of an element in an array only if they meet a condition. For example: if they end in s, then I remove the s. If not, the element should remain the same. This is how I'm trying to do it:
let myList = []
for (let i = 0; i < arrays.length; i++){
if (arrays[i].substring(arrays[i].length - 1) == 's'){
item = arrays[i].slice(0,-1);
myList.push(item);
}else{
myList.push(arrays[i]);
}
It's not working though, and idea why?