Hello there! I am new to programming and recently started learning JavaScript. I am working on a simple program where the user can select a name from a list of candidates and then choose a category to receive information about that candidate. However, the code I have written doesn't seem to be working properly, and I'm struggling to figure out why. Any assistance or guidance would be greatly appreciated. Thank you!
<html>
<head>
<title>candidate-database</title>
<script type="text/javascript">
//<!CDATA[
//storing data about the applicants
applicantName= new array ("Joe","Sarah", "Roger", "Mike");
applicantCategory= new array ("University","Year","SAT","GPA");
applicantInfo= new array (
new array ("Stanford","Senior","2250","3.6"),
new array ("UC Berkeley","Junior","2100","3.9"),
new array ("MIT","Junior","2200","3.3"),
new array ("Carnegie Mellon","Sophomore","2150","3.4")
);
//this function evaluates the data provided
function getInfo (){
var theApplicant=" ";
var menuA="Please choose an applicant by typing a number\n";
menuA+="0)Joe\n";
menuA+="1)Sarah\n";
menuA+="2)Roger\n";
menuA+="3)Mike\n";
theApplicant=prompt(menuA);
return theApplicant;
var theCategory=" ";
var menuB="Please Choose a category by typing a number\n";
menuB+="0)University\n";
menuB+="1)Year\n";
menuB+="2)SAT\n";
menuB+="3)GPA\n";
theCategory=prompt(menuB);
return theCategory;
}//end function
//the main code evaluates the result and displays the correct info to the user
function main () {
var output=" ";
var name=getInfo()
var category=getInfo()
var result=applicantInfo [name] [category];
output="The database related to" +applicantName;
output+="listens to" +result+ "in that specific category.";
alert(output);
}//end main
</script>
</head>
<body>
</body>
</html>