aquí está el código
<script>
function studentName(x)
{
while(x == '' || x >= 0 || x < 0)
{
if(x == '')
{
x = prompt('Cannot leave field blank. Enter again');
}
else if (x >= 0)
{
x = prompt('Cannot Enter a number. Enter again')
}
else
{
x = prompt('Cannot Enter a number. Enter again')
}
}
return(x)
}
function studentScore(y)
{
while(y == '' || y > 100 || y < 0 || isNaN(y))
{
if (y == '')
{
y = parseFloat(prompt(Cannot leave field, blank please enter students score));
}
else if (y > 100 || y < 0)
{
y = parseFloat(prompt(Invalid score, please enter a score 0-100));
}
else
{
y = parseFloat(prompt(Invalid score, please enter a score 0-100));
}
}
return(y)
}
function another(z)
{
while(z == '' && z != 'n' || z != 'N' || z != 'y' || z != 'Y')
{
if(z != 'n' || z != 'N' || z != 'y' || z != 'Y')
{
z = prompt('Invalid Option. Enter another student? Y or N')
}
else
{
z = prompt('Invalid Option. Enter another student? Y or N')
}
}
return(z)
}
var names = []
var scores = []
var redo = true
var anotherName
var redo2
var retry = true
var anotherScore
var retry2
var i = 0
var a = 1
var score = 0
while(redo == true)
{
var studentNames = prompt('Enter student name');
var name = studentName(studentNames);
names.push(name)
while(retry == true)
{
var studentScores = parseFloat(prompt('Enter student score'));
score = score + studentScore(studentScores);
retry = prompt('Enter another score? Y/N');
retry2 = another(retry);
if(retry == 'y' || retry == 'Y')
{
retry = true
a++
}
else if(retry == 'n' || retry == 'N')
{
retry = false
}
}
score = score / a
scores[i] = score
redo = prompt('Enter another student? Y/N');
redo2 = another(redo);
if(redo == 'y' || redo == 'Y')
{
redo = true
retry = true
i++;
a = 1
score = 0
}
else if(redo == 'n' || redo == 'N')
{
redo = false
}
}
var message =
for(y=0; y < names.length; y++)
{
alert(names[y] + - + scores[y]);
}
cuando se le preguntó si la persona quiere entrar en otra anotación, incluso si escribe Y o y o n o N que dice no válida y entrar a otro estudiante cuando debería decir entrar en otra anotación y añadirlo a la matriz e incluso si entro en una respuesta no válida debe decir no válido no entrar en otro punto de conseguir otro estudiante lo que está mal aquí?