Last active
May 8, 2021 04:17
-
-
Save waptik/795708293e442e3f0ee0c63f40552b78 to your computer and use it in GitHub Desktop.
[SOLVED] - I need help to: 1: rename keys to lowercase values 2: remove empty objects with one non-null key
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
// current code | |
const arrs = [ | |
{ | |
comments: 'asd', | |
movement: 'Back Squat', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '330', | |
}, | |
{ | |
comments: 'asd', | |
movement: 'Bench Press', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '100', | |
}, | |
{ | |
comments: 'Comment', | |
movement: 'Clean', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '195', | |
}, | |
{ | |
comments: 'Front squat comment alpha', | |
movement: 'Front Squat', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '315', | |
}, | |
{ | |
comments: 'egg', | |
movement: 'Strict', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '155', | |
}, | |
{ comments: 'sleep', movement: null, userID: null, weight: null }, | |
{ comments: 'look', movement: null, userID: null, weight: null }, | |
{ | |
comments: 'abc', | |
movement: 'Strict Press', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '155', | |
}, | |
]; | |
// expected output | |
// 1. | |
const arrs = [ | |
{ | |
comments: 'asd', | |
movement: 'Back Squat', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '330', | |
}, | |
{ | |
comments: 'asd', | |
movement: 'Bench Press', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '100', | |
}, | |
{ | |
comments: 'Comment', | |
movement: 'Clean', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '195', | |
}, | |
{ | |
comments: 'Front squat comment alpha', | |
movement: 'Front Squat', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '315', | |
}, | |
{ | |
comments: 'egg', | |
movement: 'Strict', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '155', | |
}, | |
{ comments: 'sleep', movement: "N/A", userid: "N/A", weight: "N/A" }, | |
{ comments: 'look', movement: "N/A", userid: "N/A", weight: "N/A" }, | |
{ | |
comments: 'abc', | |
movement: 'Strict Press', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '155', | |
}, | |
]; | |
// or 2. | |
const arrs = [ | |
{ | |
comments: 'asd', | |
movement: 'Back Squat', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '330', | |
}, | |
{ | |
comments: 'asd', | |
movement: 'Bench Press', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '100', | |
}, | |
{ | |
comments: 'Comment', | |
movement: 'Clean', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '195', | |
}, | |
{ | |
comments: 'Front squat comment alpha', | |
movement: 'Front Squat', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '315', | |
}, | |
{ | |
comments: 'egg', | |
movement: 'Strict', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '155', | |
}, | |
{ | |
comments: 'abc', | |
movement: 'Strict Press', | |
userid: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '155', | |
}, | |
]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks again! I really appreciate it.