Home > front end >  If statement why is not the same
If statement why is not the same

Time:11-11

Problems recently wrote code is very confused, upset my understanding of the language,
1. I used to think judgment is
If (element [I]=="compititor") {do STH}
But now must write in this way can we run:
If (element [I]="compititor") {do STH}
2. I used to think two judgment conditions to write:
If (element [I]=="compititor" & amp; & Element [I + 1)=="court") {do STH}
But now only need to meet one condition can run,
3. At noon today have more magical things
Write the if () {} else if () {} don't run, but it can remove the else,
The confusion and the really big for me, this two days is on alert to verify that this or that write the right

CodePudding user response:

1 element [I]="compititor" this is the assignment, not to judge,
2 the element element [I] [I + 1] alert out and see what is value

CodePudding user response:

Is not upset you know, your code logic has a problem,
You are in accordance with the if the else conditions in order to click? Element data increased when the click, but I did not change, so the element element is always [0], [I] element [0]==first click the value of the object, so later you click another object, you think the if element [I] will meet other click the value of the object, but the element [I] actually did not change (I've been is 0), so you think you know overturned, in plain English is you give yourself to dig pits, bug yourself not to come out,

CodePudding user response:

refer to the second floor qybao response:
is not upset you know, is your code logic has a problem,
You are in accordance with the if the else conditions in order to click? Element data increased when the click, but I did not change, so the element element is always [0], [I] element [0]==first click the value of the object, so later you click another object, you think the if element [I] will meet other click the value of the object, but the element [I] actually did not change (I've been is 0), so you think you know overturned, in plain English is you give yourself to dig pits, bug yourself not to come out,

Morning to write really logic has a problem, the code is written to determine conditions while writing two equals sign not to send, I=I + 2 hasn't been written

CodePudding user response:

reference 1st floor hookee response:
element 1 [I]="compititor" this is the assignment, not to judge,
2 the element element [I] [I + 1] alert to come out and see what value is

Write HTML element that's right, night found competitor to write wrong, correct or to write an equals sign can, ten to understand
  • Related