8000 GitHub - Fine-Alon/JS-5th-Lesson: filtering an array of objects by property value.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fine-Alon/JS-5th-Lesson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

JS-5th-Lesson

task:filtering an array of objects by property value.

Task ...
Write a filter function that filters an array of objects by property value. The array, property name, and value must be passed as arguments.

my decision:
let objects = [
___ { name: 'Rick', surname: 'Graenet' },
___ { name: 'Djudit', surname: 'Stark' },
___ { name: 'Peter', surname: 'Pen' }
];

function filter(array, property, value) {
___ let newArray = [];
___ for (let el in array) {
_____ if (array[el][property] === value) {
_______ newArray.push(array[el]);
_______ return newArray;
_____ }
___ };
};

console.log(filter(objects, 'name', 'Rick'));

About

filtering an array of objects by property value.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0