Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Need advice on javascript loop problem?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #161182
    sam1203
    Participant

    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 Holiday in Kashmir

    Kashmir Tour Package

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.