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 7694707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:22:47+00:00 2026-05-31T21:22:47+00:00

First and foremost, I’ve been learning JS for about 2-3 hours. I’ve lost track.

  • 0

First and foremost, I’ve been learning JS for about 2-3 hours. I’ve lost track. It’s 5 AM. I’m at a hackathon and trying to write my java application as a webapp. I have 7 hours. Any help would be greatly appreciated. I also know that eval is a terrible idea. However, it’s the easiest thing for my purpose right now. That being said:

edit for clarity So essentially, I have a little hangman-style learn coding game: I have a library of very short, non-buggy code snippets. The program introduces bugs (omissions mostly) to the code, and displays the buggy code. The player then attempts to either correct the code or, if they choose, to write a different snippet that mirrors the intended result of the displayed, buggy code. They input their answer in a textarea, and the program then compares the results of the execution of both code snippets (buggy snippet and user supplied snippet). The user wins if the outputs match.

Would there happen to be a way to compare result to another variable containing another eval?

as in:

edit for clarity The logic behind the following code snippet is:

There is a variable, result, which I am trying to use to reference the result of the call to eval() a value (potentially buggy code snippet) in an input area (game.input). The array goodCode contains the good code; i.e. non-buggy code. I want to call eval() on both snippets of code (the one from goodCode and the one from game.input), and compare the output of their executions. if their executions are the same, the program will output the successful execution, and a message that says “winner”.

goodCode = new Array("document.write('<b>Hello World</b>');")
var goodResult = eval(goodCode[0])
function executeJS()
{
    var game = document.forms['game'];
    var result = eval(game.input.value);
    var answer = eval(goodCode[0]);

    if (result === goodResult)
    {
        game.execute.value = result;
        document.write("winner!")
    }
}
<head>
    <body>
        <form name="game">
             <textarea type=text name="input" rows="10" cols="30" value=""></textarea><br>
             <input type="button" value="guess" onclick="executeJS();"
        </form>
    </body>
</head>

I’m sure my terminology is really off in my explanation. Sorry about that.
Any help would be appreciated.

  • 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-31T21:22:48+00:00Added an answer on May 31, 2026 at 9:22 pm

    If both code snippets returned a value, you could compare them. But document.write() etc. do not return anything useful the only thing you could do is comparing the code itself without executing it.

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

Sidebar

Related Questions

First of all, I know how to build a Java application. But I have
First and foremost, I do not know RegEx but am trying to piece something
First and foremost. I'm totally new to programming in Excel. I'm trying to make
First and foremost, I'm so sorry about how long this question is and appreciate
First and foremost-- I have a file of strings. The smallest file is about
I need to know, first and foremost, if what I'm trying to do is
I'm currently trying to write some unit test on some javascript files. My first
First and foremost, I am not asking anyone to write a program for me
First and foremost, I apologize for any vagueness in this question. At this point,
First and foremost thank you for checking out my problem, and for any 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.