I have two simple arrays:
var arr_must_exist = ["1","2","3"];
var arr_created = ["2","4","7","8"]; //This is varies depend of the array created.
So, if arr_created
is like the example there should be an alert like Your choice must contain 1 and 3
Example:
arr_created = ["2","4","7","8"];
alert(`Your choice must contain 1 and 3`)
arr_created = ["2","3","7","8"];
alert(`Your choice must contain 1`)
arr_created = ["4","5","7","8"];
alert(`Your choice must contain 1, 2 and 3`)
arr_created = ["1","2","9","3"];
alert(`Your choice is valid`)
I use $.each
but it's only check the array. Not comparing them.
$.each(arr_is_must_exist , function(index, val_must_exist) {
$.each(arr_is_exist_in_table , function(index, val_is_exist) {
if(val_must_exist != val_is_exist){
alert("Your choice must contain 1,2,3");
}
});
});
I look here but there is not accepted answer. I use IE and mozilla (it's for local user)