为什么我的for循环中的if语句不能在Java脚本中运行

汉斯·贡德拉赫

我正在运行此程序,它会根据一些提示性问题,从旧的对象数组中生成一个新的数组。但是,当我运行程序时,循环中if无法识别该语句for新数组包含新数组中的所有内容。

function verb(first,second,third,fourth,conjugation,chapter) {

    this.first = first;
    this.second = second;
    this.third = third;
    this.fourth = fourth;
    this.conjugation = conjugation;
    this.chapter = chapter;
}
// Now we can make an array of people
/*var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
// add the last family member, "timmy", who is 6 years old
family[3] = new Person("timmy", 6);*/

var family = new Array();

family[0] = new verb("amo","amare","amavi",'amatum',1,1);
family[1] = new verb("moneo","monere","monui","monitum",2,1);
family[2] = new verb("a  "," a"," a","a ",3,6);
family[3] = new verb("debeo","debere","debui","debitum",2,1);
family[4] = new verb("do","dare","dedi","datum",1,1);
family[5] = new verb("servo","servare","servavi","servatum",1,1);
family[6] = new verb("conservo","conservare","conservavi","conservatum",1,1);
family[7] = new verb("terreo","terrere","terrui","territum",1,1);
family[8] = new verb("valeo","valere","valui","valitum",2,1);
family[9] = new verb("video","videre","vid","visum",2,1);
family[10] = new verb("voco","vocare","vocavi","vocatum",1,1);
family[11] = new verb("habeo","habere","habui","habitum",2,3);
family[12] = new verb("satio","satiare","satiavi","satiatum",1,3);
family[13] = new verb("culp","culpare","culpavi","culpatum",1,5);
family[14] = new verb(" ceno","cenare","cenavi","cenatum",1,5);
family[15] = new verb("maneo","manere","mansi","mansum",2,5);
family[16] = new verb("supero","supweare","superavi","superatum",1,5);
family[17] = new verb("tolero","tolerare","toleravi","toleratum",1,6);
family[18] = new verb("audeo","audere","ausus sum","   ",2,7);
family[19] = new verb("neco","necare","necavi","necatum",1,7);
family[20] = new verb("ago","agere","egi","actum",3,8);

var choose = prompt("do you want principle parts ?");
/*<?php echo $_POST["name"]; ?>




/*family[1] = new verb
family[2] = new verb

family[0].chapter
/*"var doceo = {
    definition:"to teach",
    first:"doceo",
    second:"docere",
    third:"dixi",
    fourth:"doctum"
    chapter:"3""*/

/*chap_beg = document.getElementById("0").submit;
chap_end = document.getElementByID("1").submit;*/

var chap_beg =   prompt("What chapter do you want to begin?");
/*var chap_beg = <?php echo $_POST["name"]; ?>*/
var chap_end = prompt("what chapter do you want too end"); 
/* var chap_end = <?php echo $_POST["name"]; ?>*/
/*if((Math.random())*6<1){
    person = 1;
}else if(1<(Math.random())*6<2){
    person = 2;
}else if(2<(Math.random())*6<3){
    person = 3;
}else if(3<(Math.random())*6<4){
  person = 4;
}else if(4<(Math.random())*6<5){
 person = 5;
}else if(5<(Math.random())*6<5){
    person = 6;
} */


var helparray = new Array();
helparray[1]=1;
helparray[2]=2;
helparray[3]=3;
helparray[4]=4;
helparray[5]=5;
helparray[6]=6;

 var person = helparray[Math.floor(Math.random() * helparray.length)];   



var randselect  = new Array();


for(i=0;i<family.length;i++) {


if( chap_beg < family[i].chapter <  chap_end) {

    console.log(family[i].first);
     randselect.push(family[i]);

  }else{
      console.log("no");
  }

    /* console.log(randselect[randselect.length-1]);*/


}
     var rand = randselect[Math.floor(Math.random() * (randselect.length - 1))];
     /*var rand = randselect[Math.round(Math.random() * (randselect.length - 1))];*/`enter code here`

屈服

amo
moneo
a  
debeo
do
servo
conservo
terreo
valeo
video
voco
habeo
satio
culp
 ceno
maneo
supero
tolero
audeo
neco
ago
朱Chu

这条线...

if( chap_beg < family[i].chapter <  chap_end) {

应该

if( chap_beg < family[i].chapter && family[i].chapter <  chap_end) {

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么我不能在Bash For循环中使用Unix Nohup?

为什么我可以在for循环中多次重定义相同的变量,但不能在循环外?

为什么不能在使用browserify的循环中要求(...)?

为什么我不能在循环中附加熊猫数据框

为什么不能在for循环中操纵“ i”

为什么我不能在每个循环中合并哈希

为什么我的硒不能在python脚本中工作?

为什么不能在bash循环中在后台运行命令?

为什么我不能在批处理文件中运行此Powershell脚本?

为什么我不能在`set <set <int >>`循环中更改值

为什么我不能在模板的django循环中获取按钮jQuery的正确ID

为什么我不能在netlify中运行此脚本?

为什么我不能在匿名方法中的while循环中使用break?

为什么我的功能规格不能在RSpec中运行?

为什么我们不能在插入排序的while循环中更改语句的顺序?

为什么“ if”语句不能在while循环中运行,而while循环中也没有其他事件发生?

为什么我不能在Swift中的for循环中使用i ++

为什么我不能在Powershell的foreach循环中查找数组索引?

为什么我的“为什么”循环中的“如果”语句不能更改我的一个对象?

为什么不能在else循环中放置else-if语句?

为什么我不能在 Swift 中自己运行命令?

为什么我们不能在循环中使用 async:true ?

为什么我不能在case语句java中返回值

为什么我不能在这个 while 循环中使用括号?

为什么不能在 for 循环中使用类型提示?

为什么我不能在循环中为顺序列表结构赋值

为什么我不能在 for 循环中打印每个结果?

为什么不能在java中的实例(类)范围内定义while循环或条件语句

Rust:为什么我不能在循环中匹配 mut 字符串选项?