I'm trying to loop through an array and check if the User's ip address matches one of the i.p addresses in my clientip array. After the first loop (i=0), it jumps to the else statement right away and doesn't check the other elements in the array. Any idea what is wrong? I think it's my logic that is wrong.
<script>
$(document).ready(function(){
for(var i = 0; clientip.length; i++){
if(clientip[i] === userip.toString() ){
console.log("Your IP is :", userip);
$("#showButtons").show();
break;
}
else{
console.log("Wrong ip address");
console.log(userip);
$("#showButtons").hide();
alert("You are not connected to the correct IP Address");
break;
};
};
});
</script>
Thank you