From e58b397b47b0f7e31e82b36c2fc96b8605a31872 Mon Sep 17 00:00:00 2001 From: lvzhenbang Date: Mon, 25 Dec 2017 13:41:45 +0800 Subject: [PATCH] Fix the same format as other methods I think the consistency of the format is good and necessary. --- snippets/cleanObj.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/snippets/cleanObj.md b/snippets/cleanObj.md index f2a915719..2b74d6743 100644 --- a/snippets/cleanObj.md +++ b/snippets/cleanObj.md @@ -7,17 +7,16 @@ Also if you give it a special key (`childIndicator`) it will search deeply insid ```js const cleanObj = (obj, keysToKeep = [], childIndicator) => { - Object.keys(obj).forEach(key => { + return Object.keys(obj).forEach(key => { if (key === childIndicator) { cleanObj(obj[key], keysToKeep, childIndicator); } else if (!keysToKeep.includes(key)) { delete obj[key]; } - }) +  }), obj } /* const testObj = {a: 1, b: 2, children: {a: 1, b: 2}} - cleanObj(testObj, ["a"],"children") - console.log(testObj)// { a: 1, children : { a: 1}} + cleanObj(testObj, ["a"],"children") // { a: 1, children : { a: 1}} */ ```