将设置值添加到预定义变量中

问题描述 投票:-1回答:1

因此,我有一个变量expireint,该变量已在以前的函数中使用,并且值为20200210。在新功能中,我尝试通过adding 300编辑此变量。输入正确的值。我目前的代码是:expireint + = 300;当我调试它时,我的expireint变量等于20200402为什么加上192而不是300?

var expireint; // declared globally
expireint = 20200210  //This isn't how it's created but it's how it ends up

if(code == "13HG65"){ // if code = 3 months
  expireint += 0300;
javascript variables addition
1个回答
-1
投票

很奇怪。

我的测试:

var expireint = 20200210;
expireint += 300;
document.write(expireint);

对我来说,执行此操作(在html标记中)将20200510写入文档。

© www.soinside.com 2019 - 2024. All rights reserved.