I haven't been able to find the keywords to find this question, because this has obviously been already answered, so I can only ask it again:
Can I assign a value to a variable like this? How could I express it to keep the one-line structure?
let found = false
if (1) console.log('hi') && (found = true)
console.log(found) // it is still false
The real code is something like that
array.map(e =>
condition_is_meet_with_e &&
put_variables_in_a_complex_structure &&
flag_that_the_condition_has_been_fulfilled <<== found = true
)
Apparently it works, but somehow
console.logreturns a false?So, in this specific example, this is what works
And anything else should work as expected