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

  • Home
  • SEARCH
  • 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 6716505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:44:30+00:00 2026-05-26T08:44:30+00:00

This is a javascript homework exercise. The problem is a combination of a syntax

  • 0

This is a javascript homework exercise. The problem is a combination of a syntax error on line 20 that looks correct to me, and the code not executing when I click button 1 in the browser. The code actually partially executed earlier until I started trying to match my curly braces. The different scenes didn’t show but the scenes numbers displayed. This is an if and else if statements in which a button is clicked to take the user to the next scene when the button is clicked. I’ve been at it for about 20 hours yesterday and today. Any suggestions? Here’s the code:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1       /DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>The mysterious road</title>
  <script type="text/javascript">

  var curScene = 0;

  var option = 0;

  function changeScene(option){
  var message = "";


  if (curScene === 0) {
curScene=1;
message = "Your journey begins at fork in the road.";

     else if(curScene ==1){ //This line is the syntax error
    if(option==1){
    curScene = 2;
    message = "You have arrived at a cute little house in the woods.";
    }   
    else{
     curScene = 3;
    message = "You are standing on the bridge overlooking a peaceful stream";
    }
   end curScene 1
    else if (curScene ==2){
    if(option==1){
    curScene = 4;
    message = "Peeking through the window, you see a witch inside the house.";

else{
     curScene = 5;
}       message = "Sorry, a witch lives in the house and you just become part of  her     stew.";
}

 }//ends curScene ==2
    else if (curScene ==3){
    if(option==1){
    curScene =6;
    message = "Sorry, a troll lives on the other side of the bridge and you just     became     his lunch";

else{
    curScene = 7;
    message = "Your stare is interupted by the arrival of a huge troll.";
}
    }

 }//ends curScene 3
    else if (curScene ==4){
    if(option==1){
    curScene = 8;


else{
    curScene = 5;
    message = "Sorry, you became part of the witche's stew.";
}
    }
}//ends curScene==4
    else if (curScene ==5){
    curScene = 0;
    }
    else if (curScene == 7){
        if (option ==1){
            curScene = 6;
            message = "Sorry, you've become the troll's tasty lunch.";
        }
        else{
            curScene = 9;
        }
    }
    else if (curScene == 8){
        message = "To be continued!";
    }
    else if (curScene == 9){
        message = "To be continued!";
    }

    }
  }//ends curScene 5
  else if (curScene == 7){
curScene = 6;

if(option==1){
    message = "Sorry, you became the troll's tasty lunch.";
}
 }//end curScene 7
 else {
curScene = 9;
 }//end of curScene 7

 }//end if 


 document.getElementById("sceneimg"). src = "scene0" + curScene + ".png;" 
alert(message);
 }//end of function

 </script>
 </head>
 <body>
 <div style="margin-top:100px; text-align:center">
 <p><img id="sceneimg" src="sfa/scene0.png" alt="Stick Figure" /></p>

 Enter here for a glorious adventure!
 <input type="button" id="option" value="1" onclick="changeScene(1)" />
 Enter this gate for the surpirse of your life!
 <input type="button" id="option" value="2" onclick="changeScene(2)" />
 </div>

</body>
</html>
  • 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-26T08:44:31+00:00Added an answer on May 26, 2026 at 8:44 am

    Hint 1

    Look at your browser’s error console for additional hints.

    Console example.

    A syntax error means the code could not be interpreted because the parser found something it didn’t expect and can not recover from. Could you see anything the interpreter may expect but isn’t there?

    Hint 2

    If you can’t figure out that, double check your control characters again. Make sure things are closed where they are opened. They must be symmetrical.

    Hint 3

    Mouse over the block below for another hint.

    Have you balanced your braces correctly?

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

Sidebar

Related Questions

I have this line of JavaScript and the behavior I am seeing is that
I have this Javascript data: [{id:123,type:test},{id:154,type:another}] How would you transform that into something so
I've recently come across this piece of JavaScript code: if (,>=,<=,<>,.indexOf(, + sCompOp +
Can you suggest some good Javascript assignments/homework to C programmers , who are not
This one is a case of not doing your homework.:-) Apart from dynamic loading
This javascript produces an error: missing ) after argument list In firebug with the
I tried this JavaScript code: dx = document.getElementById('box').style dx.backgroundColor= '#fff' dx.visibility = "visible"; dx.width
I'm getting this error with this javascript can anyone help me figure out what
This javascript works fine in Chrome and Firefox but not in IE8: <script type=text/javascript>
This JavaScript code... var o = {}; console.dir(o); o.foo = bar; console.dir(o); ...results in

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.