jeudi 9 février 2017

Simplify this code?

I'm new to coding, and for a javascript project, I've been asked to create a code that would allow users of a public school/university to input whether or not they have completed the prerequisite courses for a required program. This is what I have so far:

    var IT102 = prompt("Have you taken IT102?" , "y/n");
    if (IT102 == "y"){alert("You have met this requirement");} 
    if (IT102 == "n"){alert("You need to take IT102 before applying to this program.");}

There are 10 other courses, and as I'm learning to have 10 blocks of the same code for each course is a pain/bad form. Any ideas on how to simplify this? The user must be informed if they need to take the course if they input no.

Aucun commentaire:

Enregistrer un commentaire