Try:
var os = navigator.platform;
Then handle the os variable accordingly for your result.
You can also loop through each object of the navigator
object to help get you more familiarized with the objects:
<script type="text/javascript">
for(var i in navigator){
console.log(i+"="+navigator[i]+'<br>');
}
</script>