If I have the following string: table.row.columns.values.many. I am looking to add character * after values.
So expected output would be: table.row.columns.values*.many .
If there is no "values" in string then string should stay the same.
2 Answers
I think this works nice for you, really simple, and easy way
var str = "table.row.columns.values.many";
str = str.replace("values", "values*")
console.log(str)
2 Comments
Mihai T
this doesn't work.
replace returns another string. If you want to change the original string you need to assign the 'replace' string to the initial string. str = str.replace(....)Ghost Ops
Yeah, now i've did some changes on the code, but nevermind, the right answer is on the top...
replace? It’s unclear what the specific issue is since this should be easy to search for.