For else loop in Javascript?

后端 未结 7 1325
我寻月下人不归
我寻月下人不归 2021-02-03 20:47

Is there a Javascript equivalent of the python \'for-else\' loop, so something like this:

searched = input(\"Input: \");
for i in range(5):
    if i==searched:
          


        
相关标签:
7条回答
  • 2021-02-03 21:31

    In these cases you can do a straight check for the value

    if (!(searched in range(5))) { 
        console.log("No match found!"); 
    }else{
        console.log(searched + " was found!");
    }
    
    0 讨论(0)
提交回复
热议问题