I am doing a capture program where a teacher enters your password, if the password has not been registered before then you can register your name but if it is already registered a message will be sent saying "error". However, I'm not very good at the arrangements and flags because I do not understand the concept very well and consequently my program has the error of letting the teacher's name register even though that club is already registered. What am I doing wrong?
var menu_opcion;
var profesores_opcion;
var profesor= [];
var x;
var profesor1;
var renglon=0;
var error=0;
var nombre=[];
do{
menu_opcion=prompt("Ingrese la opcion deseada \n 1)Profesores \n 2)Grupo \n 3)Alumnos \n 4)Reportes \n 5) Calificacion \n 6) Salida")
if(menu_opcion==1)//PROFESORES
{
profesores_opcion=prompt("MENU PROFESORES \n1)Captura \n2)Consultas \n3)Cambios ")
if(profesores_opcion==1)
{
do{
error=0;
renglon=renglon+1;
profesor1=prompt("Registro Numero :"+ renglon+ "\nIngrese su clave")
for(x=1; x<=renglon; x++)
{
if(profesor1==profesor[x])
{
error=1;
}
if(error===0)
{
nombre[x]=prompt("Ingrese su primer nombre")
}
if(error===1)
{alert ("Numero ya registrado")
}
}
}while(error!==0)
}
}
}while (menu_opcion!=6)