|
@@ -92,16 +92,15 @@ return previousValue
|
|
|
color: "black",
|
|
|
};
|
|
|
|
|
|
-function filter (object , name ,value) {
|
|
|
- let result = {}
|
|
|
- for (key in object) {
|
|
|
- if (name == key || object[key] == value){
|
|
|
- result[key] = object [key]
|
|
|
+function filter(object, someF) {
|
|
|
+ for(let key in object){
|
|
|
+ if(!someF(key, object[key])) {
|
|
|
+ delete object[key]
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- return result
|
|
|
}
|
|
|
-console.log (filter(phone,'color',2))
|
|
|
+filter(phone,(key,value) => key == "color" || value == 2);
|
|
|
+console.log(phone)
|
|
|
|
|
|
//object map
|
|
|
let obj = map({name: "Иван", age: 17},function(key,value){
|