【发布时间】:2020-04-01 09:09:51
【问题描述】:
所以我在下面得到了一个问题......
function translateKey(student, keyToChange, translation) { }
/*
This function will take an object representing a student's data, a key that needs changing, and its English translation.
E.g.
const student = {
prénom: 'Carla',
surname: 'Bruni',
job: 'Artist'
}
const keyToChange = 'prénom'
const translation = 'firstName'
It returns a **new object** with the key successfully translated into English.
E.g.
{
firstName: 'Carla',
surname: 'Bruni,
job: 'Artist'
}
*/
我从...开始
function translateKey(student, keyToChange, translation) {
const translated = {keyToChange : translation};
const newObject = {};
// not really sure where to go from here, help please!
【问题讨论】:
-
你想去吗?您计划了哪些步骤?
-
我想返回一个带有翻译后的key的新对象
标签: javascript object return key rename