Skip to content

Instantly share code, notes, and snippets.

@robotnealan
Created October 20, 2016 09:49
Show Gist options
  • Save robotnealan/9d5443d10a2978a411f6200cb63c7976 to your computer and use it in GitHub Desktop.
Save robotnealan/9d5443d10a2978a411f6200cb63c7976 to your computer and use it in GitHub Desktop.
A simple function to check the version of Android devices.
// whichAndroid()
//
// Checks the userAgent to see if it's an Android device and returns the version
// number if true. Returns false on all other browsers/devices.
let whichAndroid = function() {
var userAgent = navigator.userAgent.toLowerCase();
var check = userAgent.match(/android\s([0-9\.]*)/);
return check ? check[1] : false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment