Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to return true or false based on condition by looping arrayin react

var array = [{ name: 'paul', age:20 }, { name: 'john', age:30 }, { name: 'albert', age:40 }],
    find = function(array, name) {
        return array.some(function(object) {
            return object.name === name;
        });
    };

console.log(find(array, 'paul'));  // true
console.log(find(array, 'maria')); // false
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #true #false #based #condition #looping #arrayin #react
ADD COMMENT
Topic
Name
1+9 =