const alertOnlineStatus = () => { window.alert(navigator.onLine ? 'online' : 'offline') } window.addEventListener('online', alertOnlineStatus) window.addEventListener('offline', alertOnlineStatus) alertOnlineStatus()