【问题标题】:JS Exercise on Codecademy not working - accessing object data with bracket notationCodecademy 上的 JS 练习不起作用 - 使用括号表示法访问对象数据
【发布时间】:2015-08-06 09:11:12
【问题描述】:

我正在尝试这个问题。 [已编辑]

【问题讨论】:

    标签: javascript oop object javascript-objects


    【解决方案1】:

    它希望您将aProperty 设置为属性名称,然后将其与变量james 一起使用以获取值。

    var james = {
        job: "programmer",
        married: false
    };
    
    // set to the first property name of "james"
    var aProperty = 'job';
    
    // print the value of the first property of "james" 
    // using the variable "aProperty"
    console.log(james[aProperty])
    

    【讨论】:

    • 这就是答案...谢谢。我必须说,这是一种难以置信的……难以置信的愚蠢方式。在我看来,解释再清楚不过了。
    • 我认为我们的目标是让您轻松融入其中。但是,是的,有时 CA 上的说明可能不太清楚。
    • @Mazzone:你会考虑接受这个答案吗?为此,请单击左侧的刻度线。这就是我们在此处将问题标记为已解决的方式。
    猜你喜欢
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    • 2015-03-31
    • 2020-10-25
    • 2017-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多