Created
August 5, 2019 13:28
-
-
Save sinsunsan/bc176b1d845d5f7dc14d63e946b1278d to your computer and use it in GitHub Desktop.
alternative switch not evaluating the value of switched variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lines.forEach((line, index) => { | |
switch (true) { | |
// the this.isACondition return true and will be evaluated o not otherwise won't be | |
case this.isACondition(line): | |
doSomething++; | |
break; | |
case this.isAnOtherCondition(line): | |
doElseThing++; | |
break; | |
case this.somethingElseThatReturnTrueOrFalse(line, index): | |
doAnotherthing++; | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment