can't find error in my code?

六月ゝ 毕业季﹏ 提交于 2019-12-02 11:10:25

You have a comma after that large JSON object you defined at the top of your JavaScript, followed by another var.

var list= {
 "listOfProducts": [
 {
  "name":"hard disk",
  "price": "50$",
  "quality":"good",
 },
 ...[a bunch of stuff]...
},

var target=document.getElementById("outputPlace"),
    searchForm=document.getElementById("formSearch"),
    productList=list.listOfProducts,
    listLength=productList.length,
    searchValue=document.getElementById("searchBox"),
    searchInput=searchValue.value;

Both of the two other proposed answers would fix this (well ok Otome deleted their answer which was to drop the second var).

Change this

var list = {
   ...
},

var target=document.getElementById("outputPlace"),

to this:

var list = {
 ...
};

var target=document.getElementById("outputPlace"),

And you have one more comma at the end of script, after }

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!