Javascript, while loop return
问题 var i = 0; while(i < 100){ return "The number is " + i; i++; } What is wrong with my return statement? Why can I return a string plus a variable? 回答1: return means end of function and return some value. Any statements after return statement will not be executed and the execution of a function will terminate at return statement. So, return in your case will make the loop to execute only one and terminate it. 回答2: First of all your code should be inside a function. Secondly the return statement