There is a variable that outputs the result of validation in ReactJS as an array:
console.log(this.state.check); // [account: false, name: true, email: true]
Verification required:
- if all values in this variable are true - return true
- if one or more values are not equal to true - return false and one of the elements with the value false
I am new to ReactJS and my code is throwing an error
var check = this.state.check.map(item => item).some(item => item === true) ? true : false;
console.log(check); // error
I will be very grateful for the correct solution.
[account: false, name: true, email: true]isn't an array and is invalid. Did you mean{ account: false, name: true, email: true }?let arr = []; arr.account = false; arr.name = true; arr.email = true; console.log(arr);. However, this means the code producing the "array" is severely borked already.