From 05f568ae0d0cea793815936c3f71ec22d6652ab6 Mon Sep 17 00:00:00 2001 From: Soorena Date: Tue, 26 Dec 2017 14:29:51 +0330 Subject: [PATCH] Update cleanObj.md I changed comma operator because it confuses the reader. --- snippets/cleanObj.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snippets/cleanObj.md b/snippets/cleanObj.md index 2b74d6743..099b607ab 100644 --- a/snippets/cleanObj.md +++ b/snippets/cleanObj.md @@ -7,13 +7,14 @@ Also if you give it a special key (`childIndicator`) it will search deeply insid ```js const cleanObj = (obj, keysToKeep = [], childIndicator) => { - return Object.keys(obj).forEach(key => { + Object.keys(obj).forEach(key => { if (key === childIndicator) { cleanObj(obj[key], keysToKeep, childIndicator); } else if (!keysToKeep.includes(key)) { delete obj[key]; } -  }), obj +  }) + return obj } /* const testObj = {a: 1, b: 2, children: {a: 1, b: 2}}