8
For example, I have the following if
:
if(!condicao1 || !condicao2 || !condicao3){
retorno erro com a condiçao que nao existe
}
When he gets into that if
i wonder which of the parameters is missing to return an error.
8
For example, I have the following if
:
if(!condicao1 || !condicao2 || !condicao3){
retorno erro com a condiçao que nao existe
}
When he gets into that if
i wonder which of the parameters is missing to return an error.
12
It’s simple, if you want to know individually have to do individually:
if (!condicao1) {
//Faça o que precisa aqui
}
if (!condicao2) {
//Faça o que precisa aqui
}
if (!condicao3) {
//Faça o que precisa aqui
}
Eventually you can do something general too:
if (!condicao1 || !condicao2 || !condicao3) {
//faz algo geral aqui
if (!condicao1) {
//Faça o que precisa aqui
}
if (!condicao2) {
//Faça o que precisa aqui
}
if (!condicao3) {
//Faça o que precisa aqui
}
}
+1 because it also works. :)
4
It seemed to me a conflict of title with the text of the question: missing =
false
? I took into account the title because it is more clear that you want to know which one is givingtrue
.
If you want to know 1 of the parameters is true
, can do so:
condicao1 = false;
condicao2 = true;
condicao3 = false;
if(!condicao1 || !condicao2 || condicao3){
if(condicao1 || condicao2){
if(condicao1){
alert("condicao1 é true");
}else{
alert("condicao2 é true");
}
}else{
alert("condicao3 é true");
}
}
Or you can do it straight:
condicao1 = false;
condicao2 = true;
condicao3 = false;
if(condicao1 || condicao2){
if(condicao1){
alert("condicao1 é true");
}else{
alert("condicao2 é true");
}
}else{
alert("condicao3 é true");
}
Browser other questions tagged javascript node.js typescript
You are not signed in. Login or sign up in order to post.
To know which, they need to be separated under different conditions.
– Valdeir Psr
If it is more than one you want to return all or the first only?
– Randrade
It is important to mark the answer that helped you the most.
– Sam
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero
Gives a
console.log
in each of them ;)– CypherPotato