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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:39:55+00:00 2026-06-17T11:39:55+00:00

I often test the output of JavaScript functions manually (by simply looking at the

  • 0

I often test the output of JavaScript functions manually (by simply looking at the output of each function in the console), and this can often be quite tedious. In JavaScript, is there any way to test the output of a series of function calls automatically, and return all tests that did not produce the expected results?

checkOutput([["add(1, 2)", 3], ["add(2, 2)", 4]]); //if the input does not match the output in one of these arrays, then return the function call(s) that didn't produce the correct output

function checkOutput(functionArray){
    //this function is not yet implemented, and should return a list of function calls that did not produce correct output (if there are any).
}

function add(num1, num2){
    return num1 + num2;
}
  • 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-06-17T11:39:56+00:00Added an answer on June 17, 2026 at 11:39 am

    Seems as simple as looping, eval the first element of each array and compare it to the second.

    function checkOutput(functionArray) {
        var check = function(e) {
            return eval(e[0]) !== e[1];
        };
        if( Array.prototype.filter)
            return functionArray.filter(check);
        // shim in older browsers
        var l = functionArray.length, i, out = [];
        for( i=0; i<l; i++)
            if( check(functionArray[i]))
                out.push(functionArray[i]);
        return out;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often manually pull in production data into my test database so I can
I often hear around here from test driven development people that having a function
When programming in Ruby I quite often have assignments like the following test =
Often I test a function or click too often on an key on my
I often use simple Chinese phrases like 你好 to test that my code can
I often write codes in MATLAB/Python to test whether my algorithm is feasible (&
I find myself often needing to use int.TryParse() to test if a value is
Very often, I just create a new folder and test things out in there.
Often times I write some SQL like this: string sql = @ -- Multi-line
Often times, a class would not have a direct output; it manipulates its dependencies,

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.