基本上,我想输出这些吉他的评级,但我得到一个“TypeError:taylorGuitar.guitarRating 不是一个函数。这是代码:
var taylorGuitar = [
{
"model": "814ce",
"stringsCount": 6,
"pickup": true,
"stringsTuning": ["E", "A", "D", "G", "B", "E"],
"playabilityRating": 8,
"soundRating": 10,
"lookRating": 10,
"woods": {
"front": "Cedar",
"back": "Rosewood",
"fretboard": "Rosewood"
}
},
{
"model": "410ce",
"stringsCount": 6,
"pickup": true,
"stringsTuning": ["E", "A", "D", "G", "B", "E"],
"playabilityRating": 8,
"soundRating": 9,
"lookRating": 8,
"woods": {
"front": "Cedar",
"back": "Rosewood",
"fretboard": "Rosewood"
}
},
{
"guitarRating": function(){
totalScore = taylorGuitar.playabilityRating + taylorGuitar.soundRating + taylorGuitar.lookRating;
return totalScore;
}
}
];
var rating = taylorGuitar.guitarRating();
console.log(rating);