Javascript 意外代币';(';关于多表达式语句
正在尝试执行如上所示的多表达式if语句,但我的浏览器似乎抛出了一个错误Javascript 意外代币';(';关于多表达式语句,javascript,jquery,if-statement,Javascript,Jquery,If Statement,正在尝试执行如上所示的多表达式if语句,但我的浏览器似乎抛出了一个错误Uncaught SyntaxError:Unexpected token(第二个if语句就是有问题的:if(newbalance>0 | | newincome>0)|(newbalance>0&&newincome>0){ 全功能 // Start inverval function ticker(p) { var newbalance = 0; var newincome
Uncaught SyntaxError:Unexpected token(
第二个if语句就是有问题的:if(newbalance>0 | | newincome>0)|(newbalance>0&&newincome>0){
全功能
// Start inverval
function ticker(p) {
var newbalance = 0;
var newincome = 0;
if ( p == true ) {
if ( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 ) {
newbalance = ( newbalance + 1 );
} else {
newbalance = ( rmoney.balance + 1 );
}
$('.balancec').html('$' + formatMoney(newbalance, 2));
} else {
if ( btrigger.taxhike ) {
var ticker = setTimeout(function(){
if ( newbalance > 0 && newincome > 0 ) {
newbalance = ( newbalance + boosts.taxhike ),
newincome = ( newincome + boosts.taxhike );
} else {
newbalance = ( newbalance + boosts.taxhike ),
newincome = ( newincome + boosts.taxhike );
}
$('.balancec').html('$' + formatMoney(newbalance, 2));
$('.incomec').html('+$' + formatMoney(newincome, 2) + '/ps');
});
}
if ( btrigger.raisepay ) {
var ticker = setTimeout(function(){
if ( newbalance > 0 && newincome > 0 ) {
newbalance = ( newbalance + boosts.raisepay ),
newincome = ( newincome + boosts.raisepay );
} else {
newbalance = ( newbalance + boosts.raisepay ),
newincome = ( newincome + boosts.raisepay );
}
$('.balancec').html('$' + formatMoney(newbalance, 2));
$('.incomec').html('+$' + formatMoney(newincome, 2) + '/ps');
});
}
}
}
如果语句中没有
(
和)的开头和结尾(
)括号,则如果(())外部集丢失,则使用if()
而不是
改变
if ( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 ) {
if ( (newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 )) {
到
如果语句中没有(
和)的开头和结尾(
)
括号,则如果(())外部集丢失,则使用if()
而不是
改变
if ( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 ) {
if ( (newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 )) {
到
这里缺少括号
if (( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 )){
---^ ------------------------------------------------------------------------^
if语句的基本语法是
if(condition){
code block
}
但是你使用了一种类似于
if condition {
code block
}
这里缺少括号
if (( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 )){
---^ ------------------------------------------------------------------------^
if语句的基本语法是
if(condition){
code block
}
但是你使用了一种类似于
if condition {
code block
}
缺少开括号和闭括号
缺少开括号和闭括号
在您的代码中使用您错过的“(”
“在代码中,似乎您的函数是正确的,但如果条件允许,您将结束
if ( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 ) {
}
您需要将您的if条件更改为
if (( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 )){
}
如何使用逻辑运算器
例如
假设x=6和y=3,下表说明了逻辑运算符:
Operator Description Example
&& and (x < 10 && y > 1) is true
|| or (x==5 || y==5) is false
! not !(x==y) is true
操作员描述示例
&&(x<10&&y>1)是真的
||或(x==5 | | y==5)为假
!not!(x==y)为真
您的功能似乎是正确的,但如果条件允许,您将结束
if ( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 ) {
}
您需要将您的if条件更改为
if (( newbalance > 0 || newincome > 0 ) || ( newbalance > 0 && newincome > 0 )){
}
如何使用逻辑运算器
例如
假设x=6和y=3,下表说明了逻辑运算符:
Operator Description Example
&& and (x < 10 && y > 1) is true
|| or (x==5 || y==5) is false
! not !(x==y) is true
操作员描述示例
&&(x<10&&y>1)是真的
||或(x==5 | | y==5)为假
!not!(x==y)为真
Lol-drat!这就是我在思考PHP之前的经历。谢谢!@JordanThompson这发生在每个人身上,当我们处理多个编程语言时…:)很乐意帮助。!Lol-drat!这就是我在思考PHP之前的经历。谢谢!@JordanThompson这发生在每个人身上,当我们处理多个编程语言时…)很乐意帮助。!