作者:苏小丫123_877 | 来源:互联网 | 2023-09-08 07:46
IamabeginnerwhenitcomestoJavascript.IamnotreallysurewheretoaskappropriatelyandIt
I am a beginner when it comes to Javascript. I am not really sure where to ask appropriately and I thought since I've been stalking Stack Overflow for awhile now, this might be the right time to finally make an account and start my profile here. The book I am reading doesn't really have a Help Forum of any sort.
谈到Javascript,我是初学者。我不确定在哪里提出适当的问题,因为我现在一直在跟踪Stack Overflow一段时间,这可能是最终建立帐户并在这里开始我的个人资料的最佳时机。我正在阅读的这本书并没有任何形式的帮助论坛。
Anyways, I am reading a book that is in tandem with some JS exercise and I wanted to try combining principles of while-loops that contain nested if..else statements. My code is below :
无论如何,我正在阅读一本与JS练习相关的书,我想尝试结合包含嵌套if..else语句的while循环原理。我的代码如下:
var teams = ["Chiefs", "Bees", "Tigers", "Bears"];
var i = 0;
while (i
The exercise was only suppose to be using the concept of while and if but obviously with my curiosity into programming I wanted to add the else statement but I cannot get the code to work. The only instance I got the code to work properly was without the else statement.
练习只是假设使用while和if的概念,但显然我对编程的好奇心,我想添加else语句,但我无法让代码工作。我让代码正常工作的唯一实例是没有else语句。
My main goal/curiosity is I would like it to alert "Query not found!" when the if statement can't find the string in the array, in this case I've written "Lions".
我的主要目标/好奇心是我希望它提醒“查询未找到!”当if语句找不到数组中的字符串时,在这种情况下我写了“Lions”。
Thank you for your help in advance!
提前谢谢你的帮助!
3 个解决方案