# indexOf last letters

**URL:** <https://forum.kirupa.com/t/indexof-last-letters/278617>\
**Category:** flash\
**Created:** [January 2, 2009, 6:57pm UTC](https://forum.kirupa.com/t/indexof-last-letters/278617 "2009-01-02T18:57:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gencoglu](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@gencoglu](https://forum.kirupa.com/u/gencoglu)\
**Post date:** [January 2, 2009, 6:57pm UTC](https://forum.kirupa.com/t/indexof-last-letters/278617/1 "2009-01-02T18:57:01Z")

</div>

I have two textboxes ,first one creates random words everytime I click on a button  
and the second box which is a dynamic tells if the created word is "plural "or “singular” according to the last letters (if a word ends in “s” or “es” it is plural else it is singular)  
but the following code does not work properly !!  
thanks for any help…

```php

on(press) {
var dizi=new Array("cats","buses","dog","she","pencils","I", "they","me and you","boxes");
var say=Math.floor(Math.random()*dizi.length);
 
 
var textStr:String = _root.firstbox.text;
var isplural:Number = 0;
 
if (textStr.indexOf("es", textStr.length - 2) > 0) {
_root.secondbox.text = "It's plural";
isplural = 1;
}
 
if ((textStr.indexOf("s", textStr.length - 2) > 0)&&(isplural==0)) {
_root.secondbox.text = "It's singular";
}}

```
