Code:
function isAlreadySelected(newSelection, previousSelections)
{
for(var index = 0; index < previousSelections.length; index = index +1)
{
if(newSelection == previousSelections[index]) return true;
}
}
I'm currently working on the same program and am having real difficulty with the above function. It seems to be working apart from when you enter the first number it thinks that that number has been chosen already. After this it doesn't let you enter the same number again.
I have tried adding else return false in braces out of braces and also tried adding another if statement with != instead of == ending in false but none of this seems to work.
I would really appreciate it if somebody could point me in the right direction.
Thank you
Comment