为什么我的位置未定义并且显示不更新?

Why are my locations undefined and display not updating?

我在 class 项目中遇到一些问题。在我们进行的当前部分之前,一切都运行良好且花花公子。基本上,我们必须添加原型和案例才能移动到每个位置。现在我的代码行不通了,老师就像宠物石一样乐于助人。我的代码有两个部分,html(其中包含部分代码,包括项目等)和包含位置的 .js 文件。

我在 Github 上创建了一个存储库,因此所有想要提供帮助的人都可以轻松访问它。在这一点上向我的教授提交已经太晚了,但我很好奇我做错了什么。

https://github.com/EmeraldX/Project-Help/tree/master

main 和 directions.js 是我目前正在使用的文件。

谢谢!

更新:好的,所以它仍然无法正常工作,当我使用 Chrome 的控制台时,它只是告诉我:

function updateDisplay( message ) { var textArea = document.getElementById("introduction"); textArea.value = message + "\n\n" + textArea.value;

无法读取 属性 'value' 的 null

我尝试使用 firefox 打开您的 html 页面和 js,并使用 firebug 控制台查看是否有任何问题。

您的 js 中似乎缺少 )

SyntaxError: missing ) after argument list directions.js:7:145

这是对的:

locations[2] = new Location(2,"Lake","A large lake that is formed by a river flowing from the East.", 
                                new Item(1,"Fish","An old rotting fish.");

缺少“)”

更正后,您似乎错过了 ) 第 7、9、13 和 14 行。

然后弹出一个新错误:

ReferenceError: Item is not defined directions.js:7:2

这可以通过在 main.html.

中调用您的 direction.js js 脚本来纠正

希望能帮到你