const replaceKeys = (val, replacer) =>
val instanceof Array
? val.map(n => replaceKeys(n, replacer))
: val instanceof Object
? Object.fromEntries(Object
.entries(val)
.map(n => [ replacer(n[0]), replaceKeys(n[1], replacer) ])
)
: val;
const newObj = replaceKeys(obj, k => k.toUpperCase());