Syntax Error: Missing Exponent in Javascript - Stack Overflow

I have been getting syntax error. Missing exponent everytime I run my Javascript.<script type="

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="/' + 2et + '"><\/script>');

</script>

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./' + 2et + '"><\/script>');

</script>
Share Improve this question edited Nov 8, 2019 at 11:59 Mosè Raguzzini 15.9k1 gold badge34 silver badges45 bronze badges asked Oct 16, 2013 at 4:59 user2885003user2885003 531 silver badge3 bronze badges 1
  • why is your variable starting with 2... – HIRA THAKUR Commented Oct 16, 2013 at 5:00
Add a ment  | 

2 Answers 2

Reset to default 10

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.

change the variable name which you have given "2et" and give string as a variable name it will work....

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743748362a4500433.html

相关推荐

  • Syntax Error: Missing Exponent in Javascript - Stack Overflow

    I have been getting syntax error. Missing exponent everytime I run my Javascript.<script type="

    6天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信