Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:15:37+00:00 2026-05-27T05:15:37+00:00

I want my code to halt/stop/break where i put the return; and i want

  • 0

I want my code to halt/stop/break where i put the return; and i want it to halt, i have tried using break if anyone could help me that would be appreciated, i am pretty new to Javascript so don’t be upset if i dont get everything right the first time 😀 anyhelp would be very appreciated.

function InitAll() {
    var name = prompt("What is your name?", "");
    document.write("Hello, " + name + " this is a little Javascript Activity!");
    var PromptAnswer = prompt("So, " + name + " do you like to play Soccer?", "");
    if (PromptAnswer == "yes" || "Yes" || "Yes!" || "yes!" || "yeah" || "yeah!" || "Yeah!") {
        document.write("Cool, that's awesome, i play Soccer too!");
        var PromptAnswer2 = prompt("Well, even some people play Soccer and don't like it, do you like soccer?", "");
        if (PromptAnswer2 == "yes" || "Yes" || "Yes!" || "yes!" || "yeah" || "yeah!" || "Yeah!") {
            document.write("Yeah, its pretty fun.");
        }
        if (PromptAnswer2 == "") {
            return;
        }
        else {
            document.write("Well, that's really too bad, but i guess if you don't like it, you dont like it. :D");
        }
    }
    else {
        var PromptAnswer3 = prompt("Well, what sports do you like to play?", "");
        if (PromptAnswer3 == "football" || "Football") {
            document.write("Haha yeah, football is pretty awesome, even though i'm a Javascript Script, my Creator can throw football pretty well. :D");
        }
        else {
            document.write(PromptAnswer3 + " is pretty cool.");
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:15:38+00:00Added an answer on May 27, 2026 at 5:15 am

    There are several issues in your code.

    The prompt function can return null so you probably want to change this:

        if (PromptAnswer2 == "") {
            return;
    

    to this:

        if (!PromptAnswer2) {
            return;
        }
    

    The return statement will finish the execution of that function, returning control back to whatever called the function.

    That will check PromptAnswer2 for null, "", undefined and several other things too.

    Secondly, statements like this:

    if (PromptAnswer == "yes" || "Yes" || "Yes!" || "yes!" || "yeah" || "yeah!" || "Yeah!")
    

    must be written like this:

    if (PromptAnswer == "yes" || PromptAnswer == "Yes" || PromptAnswer == "Yes!" || PromptAnswer == "yes!" || PromptAnswer == "yeah" || PromptAnswer == "yeah!" || PromptAnswer == "Yeah!")
    

    or perhaps even better to remove the different case possibilities:

    PromptAnswer = PromptAnswer.toLowerCase();
    if (PromptAnswer == "yes" || PromptAnswer == "yes!" || PromptAnswer == "yeah" || PromptAnswer == "yeah!")
    

    or using regular expressions:

    if (PromptAnswer.match(/^(yes|yeah)!?$/i))
    

    Third, you may want to know that document.write() on a fully loaded document will clear the current document and start writing a new document. It is usually not what one wants to do in event handling javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Aptana 3.07 and I want code assist for ExtJS 3.4. I
In my project I have some tables that are not managed by Code First
I've dealt with instances where I would throw/rethrow an exception knowing that the code
I dont want code, that users send each other to run on my server.
I know that someone is going to want code for this issue but the
I am using the same code for both tablets and mobile, and I want
I don't want code, just need help finding where to start this project. I
I have a UIButton that I disable for a few seconds after the user
I have an application that loads lots of data into memory (this is because
I don't have formal knowledge of continuations, and am wondering if someone can help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.