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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:28:42+00:00 2026-06-02T17:28:42+00:00

I want to make a quiz and the user should type the right answer.

  • 0

I want to make a quiz and the user should type the right answer.
Let’s say the answer is correct if the answer matches 90%. For example, if the user types

Britney Spers instead of Britney Spears, the answer should be right.

I searched for Javascript functions to determine how accurate the answer is, I found some interesting functions for PHP, Ruby etc, but I need it in JavaScript.

Has anybody experience with these kind of algorhitms?
Thank you if you answer 🙂

  • 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-02T17:28:44+00:00Added an answer on June 2, 2026 at 5:28 pm

    You’re looking for the edit distance (aka Levenshtein distance). Under this scheme, the distance between two strings is the number of insertions, deletions, or substitutions required to make the strings match. For example, if the right answer is “oranges”, then:

    • “oranges” has a distance of 0 (they are the same word)
    • “orange” has a distance of 1 (delete s)
    • “roranger” has a distance of 2 (insert r, substitute s -> r)
    • “sponges” has a distance of 3 (substitute o -> s, substitute r -> p, substitute o -> a)
    • “” has a distance of 7 (insert every letter in oranges)

    A simple algorithm for it in Javascript would look like this (adapted and modified from this gist):

    function(a, b){
      // Return the number of characters in the other
      // string if either string is blank.
      if(a.length == 0) return b.length; 
      if(b.length == 0) return a.length; 
    
      // Otherwise, let's make a matrix to represent the possible choices
      // we can take.
      var matrix = [];
    
    
      var i;
      for(i = 0; i <= b.length; i++){
        matrix[i] = [i];
      }
    
      var j;
      for(j = 0; j <= a.length; j++){
        matrix[0][j] = j;
      }
    
      for(i = 1; i <= b.length; i++){
        for(j = 1; j <= a.length; j++){
          if(b.charAt(i-1) == a.charAt(j-1)){
            matrix[i][j] = matrix[i-1][j-1];
          } else {
            matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution
                                    Math.min(matrix[i][j-1] + 1, // insertion
                                             matrix[i-1][j] + 1)); // deletion
          }
        }
      }
    
      return matrix[b.length][a.length];
    };
    

    One problem with your question is that the examples you wrote about what you’re looking for (e.g. “matches 90%” or “accuracy of the answer”) are not well-defined metrics.

    There are a lot of ways an answer can be wrong. For example, let’s say the right answer is “apple”. Which of these should be accepted?

    • “APPLE” (wrong capitalization)
    • “ppple” (misspelled)
    • “apples” (plural, but you wanted the singular)
    • “Fuji apple” (too specific)
    • “fruit” (too broad)

    and so on. Deciding which of these should be accepted is beyond the power of a simple edit-distance algorithm and will require heavier lifting, like NLP.

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

Sidebar

Related Questions

Let's say I want make some of my sources publicly available via my blog
I am making a quiz application with question and answer. I want to make
I want make interactive application where user launches it and can do various task
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I want to make an quiz wizard using jQuery. Here is the link which
Well, I have a number of different content types that I want to make
I want make datetimepicker in my project. Using jquery how it is possible? I
I want make a bash script which returns the position of an element from
I use codeigniter and i want make uniqid code with php as following code(by
I am new android app developer i want make app for tablets and phone

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.