I just tried your suggestion and same outcome...
Code:
{assign var= "testB" value= false }
<script language="JavaScript" type="text/JavaScript">
{literal}
let randNum = Math.round(Math.random());
if(randNum == 1){
{/literal} "{assign var='testB' value=true}" {literal}
} else {
{/literal} "{assign var='testB' value=false}" {literal}
}
console.log( randNum );
console.log( {/literal} "{$testB}" {literal} );
{/literal}
</script>
This code will always - still - return the assigned "testB" from inside the else.
Even if I remove the initial assign - outside the js - I still get the same result.