JSFiddle - React, Tailwind, and code Playground

JavaScript

// Split on ;, ( or ), removing the white-space at either side 
var parts = navigator.userAgent.split(/\s*[;)(]\s*/);
console.log(parts);
var result;
if (/^Linux/.test(parts[3]))
    result = parts[6].split("/").pop(); // "8.10" (Ubuntu)
else
    result = parts[1].split(" ").pop(); // "6.1" (Win 7)

$(document.body).text("OS version detected: "+result);