Q:

How to add letters / words / characters to a special word in a string in javascript?

Let us consider we have a string str and a function addify() and we can do something like this with it :
 var str = "I am @java";
 console.log(addify(str, "script");
 //=> I am @javascript

So, you may understand what happened ! The addify() finds all the words with the special character @ and then adds our desired words or letter or any character to it. Another example :
  var str = "I wrote a @s in @javas";
  console.log(addify(str, " cript");
  //=> I wrote a @script in @javascript

So, can anyone teach me how to make the addify() function ?
Thanks in advance

A:

Find substring in Javascript and prepend/append some characters
StackOverflow to the rescue!
At the provided link you can find a regex example on how you can identify a special character within a provided string and then edit the result using the string .replace() method...
Quick breakdown of the regex: find the (\w+) word after the string @ which is then represented as $1 as the second parameter in the string .replace() method where you can modify the string into a new format. 
Bonus points: this will only find instances where the string being searched is connected to another word.  If you targeted identifier (@) exists alone, then it will not update a blank space.

function addify( str, ending ){
  return str.replace(/@(\w+)/g, `@$1${ending}`);
}

console.log( addify( 'i like @cheese', 'burgers' ) );
console.log( addify( 'party @ my place', 'not!' ) );

