任务是从对象函数中获取一个键值以打印到控制台,但有一点麻烦。
var chosenColor = function getThingsByColor(color){
var things = {
red: "This is a red thing",
blue: "This is a blue thing",
orange: "This is an orange thing"
};
return things[color] || "Sorry no color found";
}
coonsole.log(chosenColor('red'));
结果是红色未定义。