Created
June 5, 2021 08:54
-
-
Save markwylde/2a78b1b3d6eab239bffe37f3ae1f8dbf to your computer and use it in GitHub Desktop.
Actual Stringify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function actualStringify (object) { | |
const newObject = {}; | |
for (const key in object) { | |
if (['String', 'Object', 'Number'].includes(object[key].constructor.name)) { | |
newObject[key] = object[key]; | |
} | |
} | |
return JSON.stringify(newObject, null, 2); | |
} | |
module.exports = actualStringify; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment