If you are writing XSLT then you are writing an XML document and your XSLT code needs to be well-formed XML. So either escape the ampersands as && or use a CDATA section
<script><![CDATA[
if (input1 == "" && input2 == "") {
alert("test");
}
]]></script>
If you are trying to create HTML or SVG with script elements in your XSLT then of course a third option is to make use of external scripts e.g. to put your Javascript code into a .js file and to reference it as <script src="file.js"></script>, that way you don't have to take any efforts to escape script code according to XML rules.
&:input1=="" && input2=="".