Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native avoid keyboard when multiline 
Javascript :: nodejs split array into chunks 
Javascript :: jquery to javascript converter online free 
Javascript :: angularfire 
Javascript :: javascript loop through array backwords 
Javascript :: addeve 
Javascript :: Obtener url base 
Javascript :: updating a random variable in a function 
Javascript :: how to fetch devto api 
Javascript :: javascript coding problems 
Javascript :: express-roteamento 
Javascript :: find symmetrical difference of arrays 
Javascript :: onclick a hyperlink and display the id of clicked hyperlink js 
Javascript :: how to check my javascript code 
Javascript :: how to change text of paragraph on click in java scriopt 
Javascript :: Plumsail To change the modal popup window size you can try injecting the CSS to the SharePoint list view page 
Javascript :: react onwheel preventDefault 
Javascript :: docker containerize node app 
Javascript :: How to lock thread in javascript energy efficient 
Javascript :: -1 in js 
Javascript :: angularjs How to pass option value and label created with ng-repeat triggered by ng-change 
Javascript :: angularjs How to sort a specific value in a map 
Javascript :: Can’t connect Express.js server to the Angular frontend 
Javascript :: react-native installation error with npx react-native 
Javascript :: debugJSON 
Javascript :: error first callback in node js 
Javascript :: TypeError: (intermediate value).addBooks is not a function in js 
Javascript :: how to set socket io into global express 
Javascript :: Using <template in Javascript to create a form 
Javascript :: Make Floating label TextInput with password show/hide in react native 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =