divinedesigns1 Posted November 4, 2012 Share Posted November 4, 2012 hey guys can someone give me a simple but good ideal to create a program that uses if/else and while/do while? any simple program will do Link to comment Share on other sites More sharing options...
niche Posted November 4, 2012 Share Posted November 4, 2012 Why not use the tutorials? Link to comment Share on other sites More sharing options...
Ingolme Posted November 4, 2012 Share Posted November 4, 2012 I can't think of a project that doesn't use conditionals and loops. Link to comment Share on other sites More sharing options...
ReGA Posted November 9, 2012 Share Posted November 9, 2012 (edited) Hmmm... Yeah, tutorials are a good idea. But here are some examples any way: If, else: yourName=prompt("Please enter your full name:","John Johnson");if (yourName=="John Johnson") { alert("You used the standard name!");}else { if (yourName.length<=5) alert("Your name is a little short..."); else if (yourName.length>5 && yourName.length<=25) alert("I like your name..."); else { alert("Your name is too long."); }} Or this: yourName=prompt("Please enter your full name:","John Johnson");if (yourName=="John Johnson") { alert("You used the standard name!");}else if (yourName.length<=5) alert("Your name is a little short...");else if (yourName.length>5 && yourName.length<=25) alert("I like your name...");else { alert("Your name is too long.");} While/ Do-while: name=prompt("Enter a name (maximum 30 characters):");if (name) { while (name.length>30) { name=prompt("Enter a name (maximum 30 characters).",name); }} Or this: do { name=prompt("Enter a name (maximum 30 characters):");} while(name && name.length>30); Edited November 9, 2012 by ReGA Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now