该函数应返回一个 单个对象 以键为参数 someKey和value作为someValue
let convertToKeyValuePair = (someKey,someValue)=>{
return { someKey : someValue}
// this function should return a single object which has
//key as the value of someKey and value as someValue
};
console.log(convertToKeyValuePair("someKey","someValue"))
let convertToKeyValuePair = (someKey,someValue)=>{
// this function should return a single object which has
//key as the value of someKey and value as someValue
};
module.exports = {convertToKeyValuePair:convertToKeyValuePair};
答案 0 :(得分:1)
我假设您要使用computed property name?在变量周围添加方括号:
let convertToKeyValuePair = (someKey,someValue)=>{
return { [someKey] : someValue}
// this function should return a single object which has
//key as the value of someKey and value as someValue
};