function mapKeyToCamelCase(data) {
// 参考答案
const rename = (name) => {
return name.split('_').reduce((pre, current) => {
return pre + current[0].toUpperCase() + current.substring(1)
});
}
let res = Array.isArray(data) ? [] : {};
for (let i in data) {
if (typeof data[i] === 'object' && data[i] !== null) {
res[rename(i)] = mapKeyToCamelCase(data[i])
} else {
res[rename(i)] = data[i];
}
}
return res;
}