2
Code:
var i = 0, finished = false;
while( (i < acentos.length) && !finished){
Question:
I have a variable bool receiving false, and in my while I am denying her.
If I’m denying a false variable, it flips true, correct?
There I am saying, while i is smaller than vector size E !finished for true, continue?
or
While i is smaller than vector size E !finished for false continue?
when I put a variable bool within a while, it ignores the value that was given to it? And defines how true?.
Complete code below:
var i = 0, finished = false; // <-- *IMPORTANTE
while( (i < acentos.length) && !finished){ // <-- *IMPORTANTE
if (acentos[i] && acentos[i+1] && acentos[i+2]) {
selSeat = i;
//Codigo..
var accept = confirm("Reserva da cadeira "+ (i + 1) +" ~ "+(i + 3)+" está disponível, aceitar?.");
if (accept) {
finished = true; // <-- *IMPORTANTE
}else{
//Codigo..
}
}
i++;
}
Man while this way in the beginning
while(false && true)
when I accept the "accents" and finished receives true, then my denial operator denies him, so he gets like false, woe mine while gets like this
while( false && false)
as the two conditions are equal he leaves the loop? I may be traveling, but I’m trying to think how logic works.
Start with https://answall.com/questions/37971/operador-not . Not inverts the value, ! finished => while not finished => while finished is fake
– Isac
Possible duplicate of Operator NOT (!)
– Leonardo Pessoa
my doubt was not about the operator not itself, I know he "reverses" the values,but I think the bigown answered my question.
– Nicolas Guilherme Matheus