diff --git a/snippets/deepMapKeys.md b/snippets/deepMapKeys.md index 01841e8de..a502ec428 100644 --- a/snippets/deepMapKeys.md +++ b/snippets/deepMapKeys.md @@ -4,7 +4,8 @@ Deep maps an object keys. Creates an object with the same values as the provided object and keys generated by running the provided function for each key. -Use Object.keys(obj) to iterate over the object's keys. Use Array.prototype.reduce() to create a new object with the same values and mapped keys using fn. +Use `Object.keys(obj)` to iterate over the object's keys. +Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`. ```js const deepMapKeys = (obj, f) => ( @@ -23,37 +24,31 @@ const deepMapKeys = (obj, f) => ( ``` ```js -'use strict'; const obj = { - foo:'1', - isnull:null, - nested:{ - bar:'1', - child:{ - withArray:[ - { - grandChild:[ 'hello' ] - } - ] - } - } -} + foo:'1', + nested:{ + child:{ + withArray:[ + { + grandChild:[ 'hello' ] + } + ] + } + } +}; const upperKeysObj = deepMapKeys(obj, (key) => key.toUpperCase()); /* -Formatted JSON Data { - "FOO":"1", - "ISNULL":null, - "NESTED":{ - "BAR":"1", - "CHILD":{ - "WITHARRAY":[ - { - "GRANDCHILD":[ 'hello' ] - } - ] - } - } + "FOO":"1", + "NESTED":{ + "CHILD":{ + "WITHARRAY":[ + { + "GRANDCHILD":[ 'hello' ] + } + ] + } + } } */ ```