मैं वर्तमान में एक क्लास असाइनमेंट पर काम कर रहा हूं और हम सीख रहे हैं कि क्या / अन्यथा बयान। मैं जानना चाहूंगा कि क्या कोड समान है return false;
एक के लिए if
बयान।
उदाहरण के लिए:
var why = prompt("Why won"t you fill in my prompt?");
if(why === "" || why === null){
// How can you make this false, so that it will ask the prompt question again?
return false; /*Like that--but not a function*/
}
उत्तर:
उत्तर № 1 के लिए 1पहले अपनी प्रतिक्रिया के लिए एक कंटेनर को परिभाषित करें और तब तक संकेत दें जब तक यह स्वीकार्य मूल्य न हो:
var reason = null;
while (reason === "" || reason === null) {
reason = prompt("Why won"t you fill in my prompt?");
}
// continue with the reason defined
जवाब के लिए 0 № 2
var why=null;
while (why===null||why===""){
why = prompt("Why won"t you fill in my prompt?");
}