I am currently using the below code to check what version of iOS the user is running however it has a small problem, if there is a 3rd digit to the version it doesn't add a period to it, so when I check it on a device running iOS 9.0.1 it returns 9.01, I haven't been able to figure out how to fix the below to add a period between the second and third digit. any help is appreciated :)
<body>
<button onclick="myFunction()">Detect</button>
<p id="demo"></p>
<script>
function myFunction(){
var iOS = parseFloat(
('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1])
.replace('undefined', '3_2').replace('_', '.').replace('_', '')
) || false;
alert(iOS)
}
</script>
</body>