Bafurious Δημοσ. 16 Ιανουαρίου 2015 Δημοσ. 16 Ιανουαρίου 2015 Γειά σας, είμαι αρχάριος και προσπαθώ να μάθω τα βασικά της javascript μέσω του codecademy. Λοιπόν για να την τα πολυλογώ εδώ είναι ο κώδικας όπου περιέχει if/else μέσα σε switch αλλά πάντα μου βγαζει το σφάλμα SyntaxError: missing ) after condition. Έχω ελέγξει τις συνθήκες και λόγω της έλλειψης γνώσεων και υπομονής κυρίως ζητάω τα φώτα σας γιατι θα τρελαθώ var user = prompt("Do you play World of Warcraft? Please answer with YES , NO or ??? if you don't know what it is.").toUpperCase(); switch(user) { case 'YES': var yes_question = prompt("Do you play PVP , PVE OR RP?").toUpperCase(); if (yes_question === "RP" || yes_question === "PVE") { console.log(yes_question + " " + "is chilling and casual :P"); } else if (yes_question === "PVP") { var pvp_arena_q = prompt("Do you play arena? YES or NO?").toUpperCase(); if (pvp_arena_q === "YES") { var pvp_rating = prompt("Cool and what's your experience? \ Only numbers allowed between 0 and 3500"); if (pvp_rating >= 0 && pvp_rating <=1500) { console.log("It seems you have not that much \ experience in arena. Keep trying!");} else if (pvp_rating >= 1501 && pvp_rating <=1900) { console.log("Your experience in arena is okay but \ you can improve by a lot if you keep playing!!!"); } else if (pvp_rating >= 1901 && pvp_rating <=2200) { console.log("Your decent but still you can improve \ if you keep playing!!!"); } else if (pvp_rating >= 2201 && pvp_rating <=2600) { console.log ("You are pretty good but still you \ can get better a bit :P"); } else if (pvp_rating >= 2601 && pvp_rating <=3500) { console.log("You 've got some nice gladiator \ experience! Damn im so jelly now!!!"); } else if (pvp_rating >3500) { console.log ("This rating is too high to be true. \ It seems that you are lying or you've cheated. \ SHOO!!!"); } else { console.log("Please enter a valid number between 0 \ and 3500 and try again."); } } else if (pvp_arena_q==="NO") { console.log("Ok you don't lose any special anyway. It's unbalanced as fuck as always ;/") } else {console.log("Please answer to my question with YES or NO"); } } else { console.log("I didn't understand your input. Please choose PVP, PVE OR RP");} break; case 'NO' : console.log("That's good :)"); break; case '???' : console.log("World of Warcraft is an online game that makes you numb! The less you know about it the best it is for you!!!! "); break; default: console.log("Please answer to my question..."); } Ευχαριστώ πολύ, Μανώλης EDIT: χαχαχα τελικά είμαι για πολλές σφαλιάρες, μόλις εκανα επικόλληση τον κώδικα πήρε το μάτι μου ένα κενό στην μεταβλητή pvp_rating. Ήταν γραμμενη σαν "pvp _rating" αντί για "pvp_rating"....
paparovic Δημοσ. 16 Ιανουαρίου 2015 Δημοσ. 16 Ιανουαρίου 2015 Κατέβασε το WebStorm για editor που σου επισημαίνει τέτοιες απροσεξίες 1
Προτεινόμενες αναρτήσεις
Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε
Πρέπει να είστε μέλος για να αφήσετε σχόλιο
Δημιουργία λογαριασμού
Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!
Δημιουργία νέου λογαριασμούΣύνδεση
Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.
Συνδεθείτε τώρα