I have been getting syntax error. Missing exponent everytime I run my Javascript.
<script type="text/javascript">
function randomendtime(len) {
var chars = ["10.202", "11.121", "12.101", "13.111", "14.121", "15.097", "18.142", "20.926"];
return chars[ Math.floor(Math.random() * chars.length)];
}
var 2et = randomendtime(1);
document.write('<script type="text/javascript" src="http://www.example.com/' + 2et + '"><\/script>');
</script>
Your variable name 2et
is invalid; JavaScript variables names can contain numbers, but may not start with them.
The reason you are getting an error about exponents is because JavaScript number literals may be written in scientific notation (e.g. 2e3, or 2000). Whichever JavaScript engine was running this code parsed the variable name as a malformed number literal, hence the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With