Connecting Tech Pros Worldwide Help | Site Map

Check the end of an integer/float variable

Member
 
Join Date: Jul 2007
Location: UK
Posts: 56
#1: Sep 16 '09
Is it possible to get JavaScript to check the end of the a integer/float variable for a certain number e.g. 5, if so how do you do it?

Thanks in advance
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#2: Sep 16 '09

re: Check the end of an integer/float variable


you might use a regExp for that ... like in the following example:

Expand|Select|Wrap|Line Numbers
  1. var n = 4.63435;
  2.  
  3. /5$/.test(n)
kind regards
dheerajjoshim's Avatar
Familiar Sight
 
Join Date: Jul 2009
Location: Bangalore, INDIA
Posts: 248
#3: Sep 16 '09

re: Check the end of an integer/float variable


GITS is right... Use regular expressions... You can get the regular expressions in the Internet or you can write your own...

See this Link RegEx

Regards
Dheeraj Joshi
Member
 
Join Date: Jul 2007
Location: UK
Posts: 56
#4: Sep 17 '09

re: Check the end of an integer/float variable


Thank you, it is working brilliantly :)
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#5: Sep 17 '09

re: Check the end of an integer/float variable


of course :) ... just kidding ... glad to hear that your problem is solved ... just post back to the forum in case you have more questions ...

kind regards
Reply


Similar JavaScript / Ajax / DHTML bytes