Skip to content
Advertisement

How to replace only the last character in a string but not earlier occurrences of the same character?

I want to find which word’s last character is ‘e’ and I would like to replace ‘e’ with ‘ing’. After this process want to append these in the array such as new words

JavaScript

output

JavaScript

I want to get the output like this

JavaScript

Advertisement

Answer

Try this:

JavaScript

Or if you want a 1 liner:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement