a real thinker

Posted Nov 4, 2021, 3:56 PM UTC

Posted Nov 4, 2021, 3:56 PM UTC
I think this would be the simplification?
return this.disabled = chargesCheck || noteCheck
Though I'm a bit concerned by the names on those variables -- what other horrors lurk further up the file?
Edit: I screwed it up, and the original author probably did too, but I'll stay faithful to the truth table: the value of this.isLoading doesn't matter because || binds tighter than ?:, and it gets or'd with true.
That simplification may change the data type of this.disabled from the OP code, as you are doing simple truthy or falsey checks rather than explicity returning a boolean.
True, I was operating under the assumption that those were booleans.
Still:
return this.disabled = !!(chargesCheck || noteCheck)
Image Transcription: Code
return this.disabled = !chargesCheck ? !noteCheck ? false : true : true || this.isLoading ? true : false ;
^^I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
Written to the tune of the leekspin song
Do I miss something or will the part after the OR never be evaluated?
true || this.isLoading ? true : false ;
It will get evaluated if chargesCheck and noteCheck are false
(!chargesCheck ? (!noteCheck ? false : true) : true) || (this.isLoading ? true : false)
nevermind.
This hurts my brain