As a beginner in the JS universe, I am encountering an issue while attempting to create a concise script. Despite my efforts, it seems like I am unable to achieve this goal. Is there a way to make it work as intended? If not, could you explain why?
var xhr;
if (window.XMLHttpRequest) ? xhr= new XMLHttpRequest(): xhr=new window.ActiveXObject();