目前底部的这两个警报都返回" undefined"。我不确定这个问题是否是由于我试图提醒错误的事情,我是否只是将其编码错误或者是什么,请帮助我们。)
var contents = [ "Loughborough University offers degree programmes and world class research.", "An alternative University", "Yet another University"];
function matchContents(contents,pattern)
{
var c = pattern.toLowerCase();
var d = [];
var arraypointer = 0;
for(var i = 0;i<=contents.length-1;i++)
{
for(var j = 0;j<=contents[i].length-1;j++)
{
if(c.charAt(j)>='a' && c.charAt(j)<='z')
if(contents[i].toLowerCase().indexOf(c.charAt(j)==-1))
j=contents[i].length;
}
d[arraypointer] = i;
arraypointer++;
}
}
alert(matchContents(contents,"LU"));
alert(matchContents(contents,"other"));
答案 0 :(得分:0)
可能只是返回数组d的情况。
def something1(x):
x += 0
return x
def something2(y):
y += 0
return y
def main():
print("1. Try to open door")
print("2. Go to room1")
print("3. Go to room2")
choice = int(input("Enter selection: ")
if choice == "1":
# Trying to get this if statement to work with the variables
# Don't know which function or parameters to pass in order to get it to work
if x == 3 and y == 2:
print("You're free")
else:
print("You're not free")
elif choice == "2":
room1()
elif choice == "3":
room2()
else:
print("ERROR")
main()
def room1():
print("1. Push thing1")
print("2. Push thing2")
print("3. Push thing3")
print("4. Return to previous room")
pushChoice = input("Enter selection: ")
if pushChoice == "1":
print("Thing1 pushed")
room1()
elif pushChoice == "2":
print("Thing2 pushed")
room1()
elif pushChoice == "3":
print("Thing3 pushed")
# The modified variable x for something1(x)
x = 3
x = something1(x)
room1()
elif pushChoice == "4":
main1()
else:
print("ERROR")
room1()
def room2():
print("1. Pull thingA")
print("2. Pull thingB")
print("3. Pull thingC")
print("4. Return to previous room")
pullChoice = input("Enter selection: ")
if pullChoice == "1":
print("ThingA pushed")
room1()
elif pullChoice == "2":
print("ThingB pushed")
# The modified variable y for something2(y)
y = 2
y = something1(y)
room1()
elif pullChoice == "3":
print("ThingC pushed")
room1()
elif pullChoice == "4":
main1()
else:
print("ERROR")
room1()