JSFiddle - React, Tailwind, and code Playground

by Brock Whittaker

HTML

<input id='input'></input>
<span></span>

<p></p>

JavaScript

function stringMatch(i, a) {
    counter = 0;
    consecutive_counter = 0;
    off_consecutive_counter = 0;
    for (x = 0; x < a.length; x++) {
        if (i.charAt(x) === a.charAt(x)) {
            counter += 10; // reward 10 points for a full match
        } else {
            if (i.charAt(x) === 'c' && a.charAt(x) === 'k' || i.charAt(x) === 'k' && a.charAt(x) === 'c' || i.charAt(x) === 's' && a.charAt(x) === 'c' || i.charAt(x) === 'c' && a.charAt(x) === 's' || i.charAt(x) === 'g' && a.charAt(x) === 'j' || i.charAt(x) === 'j' && a.charAt(x) === 'g' || i.charAt(x) === 's' && a.charAt(x) === 'z' || i.charAt(x) === 'z' && a.charAt(x) === 's') {
                counter += 7; // reward 7 points for a commonly mispelled letter
            } else {
                if (i.charAt(x - 1) === a.charAt(x) || i.charAt(x + 1) === a.charAt(x)) {
                    counter += 6; // reward 5 points for the letter being off one place.
                    // this is important because if they add an additional letter you don't want none of the correct lettters to be placed.
                    // eg. (additionally vs aditionally)
                } else {
                    if (i.charAt(x - 2) === a.charAt(x) || i.charAt(x + 2) === a.charAt(x)) {
                        counter += 2;
                    } else {}
                }
            }
        }
    }
    counter -= Math.abs(a.length - i.length) * 3;
    return counter / a.length;
}

// this is string match above

function intializeObject() {
    obj = {};
}

function initializeObject_User() {
    obj_user = {};
}

function processKey(obj, array) {
    function addKeyToObject(obj_key, answer) {
        obj[obj_key] = answer;
    } // adds a key 

    function findNumberKeys(directive) {
        return Object.keys(directive).length; // returns numberKeys
    } // using return instead of a variable

    function lowerCaseString(string) {
        obj[string] = obj[string].replace(/\.|\?|"|'|-|!|,/g, "");
        obj[string]...