Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isObject(obj) {
- return obj === Object(obj);
- }
- function formatData(obj, indents) {
- const objEntries = Object.entries(obj);
- for (var i = 0; i < objEntries.length; i++) {
- const key = objEntries[i][objEntries[i].length - 2];
- const value = objEntries[i][objEntries[i].length - 1];
- if (!isObject(value)) {
- console.log("\t".repeat(indents) + key + ": " + value)
- if (i === objEntries.length - 1) {
- console.log("-".repeat(50));
- }
- } else {
- console.log("\t".repeat(indents) + key + ":");
- formatData(value, (indents + 1));
- }
- }
- }
- function printDetails(obj) {
- formatData(obj, 0);
- }
Add Comment
Please, Sign In to add comment