Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 条件的基本JS运算符_Javascript_Logical Operators - Fatal编程技术网

Javascript 条件的基本JS运算符

Javascript 条件的基本JS运算符,javascript,logical-operators,Javascript,Logical Operators,假设我有以下代码: if (x1 >= 300 && y1 >= 10) { ... } 我想说,如果x1大于或等于300,小于或等于800,以及如果y1大于或等于10,小于或等于30。我怎么写呢?你可以试试这个 if ((x1 >= 300 && x1 <= 800) && (y1 >= 10 && y1 <= 30)) { //.... } 如果((x1>=300&&x1=10&&

假设我有以下代码:

if (x1 >= 300 && y1 >= 10) { ... }
我想说,如果x1大于或等于300,小于或等于800,以及如果y1大于或等于10,小于或等于30。我怎么写呢?

你可以试试这个

if ((x1 >= 300 && x1 <= 800) && (y1 >= 10 && y1 <= 30)) {
    //....
}
如果((x1>=300&&x1=10&&y1请尝试以下操作:

if ( (300 =< x1 && x1 =< 800) && (10 =< y1 && y1 =< 30) ) { ... }
if((300=
如果((x1>=300&&x1=10&&y1=min&&x)您没有尝试以下简单的操作:
(x1>=300&&x1=10&&y1我想你知道这个问题的答案。我第一次学习编程时也问了你同样的问题。我想可能有一个中间运算符。那也很好。谢谢你/敬礼。可能是因为你的
if
语法不正确invalid@charlietfl谢谢,伙计。我没注意到。现在更正了
if((x1 >= 300 && x1 <= 800) && (y1 >= 10 && y1 <= 30))
{
   //do your stuff here
}
function between(x, min, max) {
  return x >= min && x <= max;
}
// ...
if (between(x, 300, 800)) {
   // something
 }