Perhaps, you could 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:
As found in this anwser:
jQuery/Javascript to detect OS without a plugin?