Possible to check if word ends with an "s"?

Is it possible to run a check to see if a word input by the player ends with the letter “s”? This way the game can know whether or not to add an “s” after an apostrophe when referring to the name input by the player.

I know most people will just say to add an “s” anyway, but I’m a bit of a grammar Nazi. I would prefer writing an entire page of code to determine that conditional s, over seeing “Walters’s.”

1 Like

Looks like the right trick is there on https://www.choiceofgames.com/make-your-own-games/choicescript-advanced/


Characters: You can extract the characters (letters/numerals) out of a variable, like this:
  *temp word "xyzzy"
  *temp first_letter word#1
  *temp second_letter word#2
  The first letter of the word "${word}" is ${first_letter} and the second letter of the word is ${second_letter}.

Counting characters: You can count the number of characters in a word like this:
  *temp word "plough"
  *temp word_length length(word)
  *temp last_letter word#word_length
  The word "${word}" is ${word_length} letters long, and so its last letter is ${last_letter}.

So if you copy the word_length and last_letter bits, you can then check *if last_letter = “s”

Though I should note that whether you stick ’ or 's after a name in the singular for a possessive depends on which style guide you’re using, so depending on what you’re going for, you may wish to check out the Choice of Games Style guide (https://docs.google.com/document/d/1Uo3kXWi_v8PG6dZeeUFKAUq50-tBDqYVmKMz5fM2fmo/edit), which goes with

Apostrophe: Singular possessive uses “'s”, even for singular terms ending in “s”, e.g. “Jones’s” is correct.
Plural: “sailors’ rum”


In literature, the use of an “s” to express ownership in singular possessive form varies by author. In my opinion, it looks nicer to have only one “s”. Reading the Style Guide you linked it sounds as if authors aren’t given much of a choice. Is this something they enforce strictly or a suggestion?


Oh, certainly :slight_smile: I wouldn’t argue with stylistic choice.

I’m afraid I’m not really the right person to answer this. What I can say is that they released a bunch of guides right when the contest started up, so if you’re writing something for that, it’d be good to abide by. They go for a more unified style for official games. However, if you’re writing something to be a hosted game, I expect there would be more flexibility, as those already vary a great deal. But don’t take this as confirmed, just my impression.

1 Like