Can this for loop in JavaScript be altered to repeat the prompt questions if they are not filled in? -
i have completed code challenge , have been trying see if can altered repeat prompt questions, if not filled in user? able using while loop , wondering if possible in loop. have played around conditional statements, beginner , have had no luck far. if able let me know if possible , explain how, appreciated.
// loop code challenge //write varibales needed var quote; var author; var authorandquote; // variables = to? need length property for loop function know var quote = prompt("please write known quote below?"); var author = prompt("please write author quote below?"); var authorandquote = 'quote' + 'author'; for(var = 0; < authorandquote.length; += 1){ } // print console console.log("your quote " + quote + " author " + author + "."); // while loop code challenge //write varibales needed var quote; var author; //use ! in while loop state while not true keep prompting question while (!quote) { quote = prompt("please write known quote below?"); } while (!author) { author = prompt("please write author quote below?"); } //print answer console console.log("your quote " + quote + " author " + author + ".");
Comments
Post a Comment