Steps:
1. Based on '.' as a delimiter, split the variable into array
2. Check the 2nd value if you are sure that variable will always be of format xxx.yyy
3. If array length is more than one, based on the defined format, variable contains extension.
Refer:
JavaScript split() Method[
^]
Try out.