Sto avendo un momento frustrante cercando di farlo funzionare, Chrome continua a mostrare un errore di sintassi Uncaught, ma essendo un principiante di javascript, non ho idea di dove cercare. Qualsiasi aiuto o puntatori sarebbe apprezzatoJavascript - Uncaught SyntaxError: identificatore imprevisto
function details(user) {
var fuel = prompt("Would you prefer petrol or diesel?");
var passengers = prompt("How many passengers will there be?");
var aircon = prompt("Do you require air-conditioning?");
var transmission = prompt("Do you want a Manual, Semi-Automatic or Automatic Transmission?");
var hire = prompt("How long would you like to hire a vehicle for? (Day Hire, Weekend Hire or Weekly Hire)");
if (fuel == "petrol" && passengers == "2" && aircon = "yes" && transmission == "semi-automatic") {
result = "Lambourghini Aventador";
} else {
result = "some form of SUV"
}
if result = "Lambourghini Aventador") {
if (hire == "Day hire") {
cost = 2000;
}
if (hire == "Weekend hire") {
cost = 3800;
}
if (hire == "Weekly hire") {
cost = 12000;
}
}
}
Generalmente il messaggio di errore è accompagnato da un numero di riga. Puoi anche cliccarci sopra e ti mostrerà esattamente dove si trova l'errore. –
Una rapida visione mi dice che ti manca un ';' dopo 'result =" qualche forma di SUV "'. Non sono sicuro se questo è il problema però. –
Vorrei anche cambiare l'istruzione if per 'if ((fuel ==" petrol ") && (passenger ==" 2 ") && (aircon ==" yes ") && (transmission ==" semi-automatic ")) '. Oh, e ti manca un '=' in '(aircon =" yes ")', che dovrebbe essere '(aircon ==" yes ")' –