Javascript If array element contains a period -


i want search through array i've made string, if has period @ end of element, randomly (50% chance) add "arr!" before next sentence. problem is, don't quite know how check if there period @ end of given array element. i'm guessing regular expressions best, i'm terrible them... able provide insight??

var things = output2.value.split(" "); (var = 0; < things.length; i++) {   things[i] += " ";   if (things[i]==".") {     var randnumb = math.floor((math.random() * 2) + 1)     if (randnumb == 1) {       things[i] += " arr!"     };   }  }; 

regex inefficient.

var stringtocheck = 'something'; var period = '.';  //check if string ends period (.) if (stringtocheck.indexof(period, this.length - period.length) !== -1) {     //your code here } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -