I am trying to look at a list of names as defined by B2, B3, B4, B5 up to B99 and compare to another set name(walkname) If the walkname is found in the list, it is evaluated as true and nothing happens except browser popup. If it is evaluated as false, the new name will be added to the last row. The below code works, but I do not want to have to define up to B99. What is the quickest way to do this and use the || at the same time?
var B2 = sstracker.getRange('B2').getValue();
var B3 = sstracker.getRange('B3').getValue();
var B4 = sstracker.getRange('B4').getValue();
var B5 = sstracker.getRange('B5').getValue();
if (walkname == B2 || walkname == B3 || walkname == B4 || walkname == B5)
{Browser.msgBox(true)}
else {var row1 = sstracker.getRange(sstrackerLastRow + 1, 2, 1, 1).setValue(walkname).setBackground('Red');}
I semi know how to use the following code and have tried to use it to do the same thing as above. The only problem is, it evaluates one at a time rather than looking at all the instances and using an OR statement. Essentially, the new name always gets added to the list unless it is first. I am a NOOB and realize there is probably a real easy answer to make the below code do the above code. I have searched the forums but am not sure what to even look for to get help on this. Help please! When you answer, try to keep it simple.
for(var i = 0; i < teacherarray.length; i++){
var teachname = teacherarray[i];
if(teachname == walkname){break}
else {var row1 = sstracker.getRange(sstrackerLastRow + 1, 2, 1, 1).setValue(walkname).setBackground('Red');}