
[英]How can I use a variable of one <script> in another <script> in javascript?
[英]how can I set a java script variable equal to another and use its properties
我只是一个初学者。 我正在制作一个程序,用户可以从一个数组中选择对象,然后放置到另一个数组中,在该数组中选择一个随机对象并将其制成变量。 但是,我似乎无法在新数组中对新变量使用相同的属性。
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;
}
var family = new Array();
family[0] = new verb("amo","amare","amavi",'amatum',1,1);
family[1] = new verb("moneo","monere","monitum",2,1);
family[3] = new verb("debeo","debere","debui","debitum",2,1);
for(i=0;i<20;i++) {
if(chap_beg< i < chap_end) {
var randselect = new Array();
randselect.push = family[i];
var rand = family[Math.floor(Math.random() * family.length)];
var t = rand.third;
var perfect2 = t.substring(0,(t.length)-2);
你为什么跳过家人[2]? 这部分应该是这样的:
randselect.push(family[i]);
var rand = family[Math.round(Math.random() * (family.length - 1))];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.