Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Created January 13, 2020 14:24
Show Gist options
  • Select an option

  • Save cesarkohl/614cfb2c739a3aa07b5f8055ff9b8bd1 to your computer and use it in GitHub Desktop.

Select an option

Save cesarkohl/614cfb2c739a3aa07b5f8055ff9b8bd1 to your computer and use it in GitHub Desktop.
var students = [
 {name: 'adam'},
 {name: 'brian'},
 {name: 'charles'}
];
var student;
for (var i = 0; i <students.length; i ++) {
 if (students [i] .name === 'brian') {
 student = students [i];
 break; // avoid scrolling through the rest of the list
 }
}
console.log (student); // {"name": "brian"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment