CodePen 控制台不会给出任何输出
CodePen console will not give any output
我正在做一个涉及对象的练习,为了查看输出,我使用了 CodePen 上的控制台。我写了下面的代码,但是控制台没有给出任何输出,有人能帮我指出我的代码有什么问题吗?
我需要使用模板字符串打印 "In school, I'll learn ExpressJS and ReactJS."。
{
let basic = {
language: "JavaScript",
frameworks: [{
end: "back",
list: [{
name: "ExpressJS",
released: 2010
},
{
name: "MeteorJS",
released: 2012
}
]
},
{
end: "front",
list: [{
name: "ReactJS",
released: 2013
},
{
name: "VueJS",
released: 2014
}
]
}
]
};
}
console.log(basic.frameworks[0].list[0].name); // => ExpressJS
console.log(`In school I will learn ${basic.frameworks[0].list[0].name} and ${(basic.frameworks[0].list[0].name}`); // => In school, I'll learn ExpressJS and ReactJS.
那是因为 basic
未定义(查看您的浏览器控制台)。
删除变量定义前后的括号{
你很接近!您需要更改的内容很少
- 将您的 console.log 转换为带反引号的字符串文字 ``
- 从
${(basic.frameworks[0].list[0].name}
中删除 (
- 您的基本变量定义不应在
{}
. 下
这应该可以解决您的问题!
let basic = {
language: 'JavaScript',
frameworks: [{
end: 'back',
list: [{
name: 'ExpressJS',
released: 2010
}, {
name: 'MeteorJS',
released: 2012
}]
}, {
end: 'front',
list: [{
name: 'ReactJS',
released: 2013
}, {
name: 'VueJS',
released: 2014
}]
}]
};
console.log(basic.frameworks[0].list[0].name); // => ExpressJS
console.log(`In school I will learn ${basic.frameworks[0].list[0].name} and ${basic.frameworks[0].list[0].name}`);
我正在做一个涉及对象的练习,为了查看输出,我使用了 CodePen 上的控制台。我写了下面的代码,但是控制台没有给出任何输出,有人能帮我指出我的代码有什么问题吗?
我需要使用模板字符串打印 "In school, I'll learn ExpressJS and ReactJS."。
{
let basic = {
language: "JavaScript",
frameworks: [{
end: "back",
list: [{
name: "ExpressJS",
released: 2010
},
{
name: "MeteorJS",
released: 2012
}
]
},
{
end: "front",
list: [{
name: "ReactJS",
released: 2013
},
{
name: "VueJS",
released: 2014
}
]
}
]
};
}
console.log(basic.frameworks[0].list[0].name); // => ExpressJS
console.log(`In school I will learn ${basic.frameworks[0].list[0].name} and ${(basic.frameworks[0].list[0].name}`); // => In school, I'll learn ExpressJS and ReactJS.
那是因为 basic
未定义(查看您的浏览器控制台)。
删除变量定义前后的括号{
你很接近!您需要更改的内容很少
- 将您的 console.log 转换为带反引号的字符串文字 ``
- 从
${(basic.frameworks[0].list[0].name}
中删除 - 您的基本变量定义不应在
{}
. 下
(
这应该可以解决您的问题!
let basic = {
language: 'JavaScript',
frameworks: [{
end: 'back',
list: [{
name: 'ExpressJS',
released: 2010
}, {
name: 'MeteorJS',
released: 2012
}]
}, {
end: 'front',
list: [{
name: 'ReactJS',
released: 2013
}, {
name: 'VueJS',
released: 2014
}]
}]
};
console.log(basic.frameworks[0].list[0].name); // => ExpressJS
console.log(`In school I will learn ${basic.frameworks[0].list[0].name} and ${basic.frameworks[0].list[0].name}`);