好的,我忘记了链接到列表中已经存在的单个变量的变量列表的名称是什么,但请看一下:
function Models(Make) {
var cars = {
"Acura": ['Integra', 'NSX', 'RSX', ],
"BMW": ['M3', ],
"Buick": ['Regal', ],
"Cadillac": ['CTS', ],
"Honda": ['Accord', 'Civic', 'CR-Z', 'Prelude', ],
"Mazda": ['3', 'MX-5', 'MX-6', 'RX-7', 'RX-8', ],
"Mini": ['Cooper', ],
"Nissan": ['240SX', '350Z', 'Fairlady', 'GT-R', 's13', 's14', 's15', ],
"Toyota": ['Celica', 'MR2', 'Supra', ],
};
var holder = cars[Make]
var Model = holder[Math.floor(Math.random() * holder.length)];
return Model;
}
function main() {
var Makes = [
'Acura',
'BMW',
'Buick',
'Cadillac',
'Honda',
'Mazda',
'Mini',
'Nissan',
'Toyota',
];
var Make = Makes[Math.floor(Math.random() * Makes.length)];
var Model = Models(Make);
var Out = Make + " " + Model;
return Out;
}
document.write(main());
我想在车辆型号之后添加第三类(例如 Mini Cooper “S” 或 Honda Civic “Del Sol”),我该怎么做?