WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > PROGRAMMING LANGUAGES > Scripting and Server Side > Need advice on javascript loop problem?

 
  Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 27th January 14, 09:56 AM   #1
sam1203
WLC Member
 
Join Date: Jan 2014
Posts: 5
Default Need advice on javascript loop problem?

I am having trouble creating this javascript problem:

“Create a web page called “wartime.html” that consists of a textarea and a button which reads “Shoot the Cannon Until Surrender”. If the button is clicked, the program enters a loop that repeatedly prompts the user “Do you surrender, yes or no?”. If the user types “yes” or “y”, add the phrase “The war is over” to the text area and exit the loop. If the user types anything else, add the phrase “BOOM” to the textarea and prompt again for surrender.”

This is what I have so far for my function:

War Time

function decide() { var n1 = prompt(“Do you surrender? Yes or no?”, “”); document.getElementById(‘battlefield’).v… var counter=0 while (n1 == yes) {document.getElementById(“battlefield”)…. += “The war is over!”} }

h2{text-align=center} p{text-align=center}

War Time!

I am unsure as to what I have to do to make the loop respond to the user’s input

Last edited by meesa; 27th January 14 at 11:19 AM.
sam1203 is offline   Reply With Quote
 


Thread Tools
Display Modes
Threaded Mode Threaded Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:18 AM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyrightę 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.