// Immediately Invoked Function Expression (IIFE) to detect the browser and version const browser = (function() { // Get user agent string from navigator const userAgent = navigator.userAgent; // Regular expression to match browser name and version const match = userAgent.match(/(chrome|firefox|safari|opera|edge|msie)\/(\d+(\.\d+)?)/i); // Return the detected browser information or 'Unknown' if not matched return match ? { name: match[1], version: match[2] } : 'Unknown'; })(); // Logging the detected browser information console.log('Browser:', browser);