我有一个作业可以在js中创建汽车数据库

时间:2019-07-04 21:20:59

标签: javascript

我的作业是创建一个数据库。我使用对象...无法解决此问题

我使用了对象,但遇到了一个问题,这个问题的名称:未捕获的SyntaxError:意外的令牌{

var carLandRover {
manufacturer: "Jaguar",
model: "Vogue",
yearOfCarManufacture: "2003",
color: "black",
sold: true
};
console.log(carLandRover)

var carToyota {
manufacturer: "Toyota",
model: "LandCruiser",
yearOfCarManufacture: "2006",
color: "silver",
sold: true
};
console.log(carToyota)

var carMercedes {
manufacturer: "Mercedes",
model: "Vito",
yearOfCarManufacture: "2006",
color: "white",
sold: false
};
console.log(carMercedes)

var carBmw {

manufacturer: "Bmw",
model: "x5",
yearOfCarManufacture: "2000",
color: "silver",
sold: true
};
console.log(carBmw)



var carLexus {
manufacturer: "Toyota",
model: "Rx",
yearOfCarManufacture: "2010",
color: "red",
sold: true
};
console.log(carLexus)

var carPorshe {
manufacturer: "Volkswagen",
model: "911",
yearOfCarManufacture: "2012",
color: "green",
sold: false
};

console.log(carPoshe)

SyntaxError: Unexpected token {

1 个答案:

答案 0 :(得分:1)

尝试一下。 您的代码中缺少等于=的内容。

var carLandRover = {
  manufacturer: "Jaguar",
  model: "Vogue",
  yearOfCarManufacture: "2003",
  color: "black",
  sold: true
};

console.log(carLandRover)

var carToyota = {
  manufacturer: "Toyota",
  model: "LandCruiser",
  yearOfCarManufacture: "2006",
  color: "silver",
  sold: true
};

console.log(carToyota)

var carMercedes = {
  manufacturer: "Mercedes",
  model: "Vito",
  yearOfCarManufacture: "2006",
  color: "white",
  sold: false
};

console.log(carMercedes)

var carBmw = {
  manufacturer: "Bmw",
  model: "x5",
  yearOfCarManufacture: "2000",
  color: "silver",
  sold: true
};

console.log(carBmw)

var carLexus = {
  manufacturer: "Toyota",
  model: "Rx",
  yearOfCarManufacture: "2010",
  color: "red",
  sold: true
};

console.log(carLexus)

var carPorsche = {
  manufacturer: "Volkswagen",
  model: "911",
  yearOfCarManufacture: "2012",
  color: "green",
  sold: false
};

console.log(carPorsche)