I am trying to create a dynamic check in JavaScript for the "if" structure, for example:
var var1=1;
var comparator="!==";
var var2=1;
if(var1+comparator+var2){
alert("Yes, its false");
}else{
alert("Yes, its true");
}
Three variables can be changed at the request of the user. I found that the sentence is always checked "true" because the "if" structure confirms that a string exists.
I want the user to change any of these three variables, and the function returns the result. Obviously, the comparison operator is controlled by another function that restricts the options for the operators: "===", "! ==" ...
Thank you and welcome
source
share