MV Append Letter to Hero Name

Hey everyone!

I've been searching all over and can't seem to find any post or plugin that has anything to do with this. It might sound like a weird question, but it has a purpose:

In a game I'm making there's a hero that has no name when he joins your party. As you play through his storyline though you get letters to name him. So like one of the quests has 3 different endings: One adds an "a" to his name, another adds an "e" and the last adds an "i"; so basically as you play, you can play the missions in any order you want and you never really know what ending you'll get, so the name kind of randomly builds itself. I was going to use a bunch of variables, switches and IF/ELSE statements, but I wondered—is it possible to append a letter to a hero name?

Basically, say the player named a hero "Zor" and as the game creator, you needed to add a "k" to the end of that heroes name to make the heroes name be "Zork", but you can't just do a name change on the character to add the "k", because what if the player named the hero "Cor" or "Por"? So, not sure if this would require a plug-in or if there's possible some type of script call/JavaScript logic that could be applied to get this result. Any and all help would be greatly appreciated!
Using a script call:
$gameActors.actor(actorId).setName(n) changes the name of Actor #actorId to n, a variable that would've been named as such. This doesn't count as an actual lowercase n because it's not between quotation marks.
$gameActors.actor(actorId).name() returns the name of Actor #actorId.

If the additional letter doesn't depend on the original name, write this script call:
JavaScript:
actorToChange = 1; //the actor ID of the character whose name is changing
letterToAppend = "k"; //the letter to append, don't remove the quotation marks
//nothing to change in what's below
actorNameChange = $gameActors.actor(actorToChange);
actorNameChange.setName(actorNameChange.name() + letterToAppend);
The command will get the actor's current name, and append a k at the end.
Sorry it took me so long to respond, it was a while until I had time to test this. But this is exactly what I needed! Now I just need to find a way to check the length of an actor's name to make sure it doesn't exceed x amount of characters

Thank you!
The .length property is the number of characters. So you can make a conditional with
Code:
if ($gameActors.actor(actorId).name().length < x)
Moved to: Plugin Requests
Sorry @Shaz , this wasn't necessarily a plug in request but rather just some needed help on some script calls for basic RPG Maker functions which is why I didn't want to throw it into plug in requests.

Thanks @CHKNRAVE and @ATT_Turan for the script call help! They both worked perfectly!

Original thread: https://forums.rpgmakerweb.com/threads/append-letter-to-hero-name.134302/