Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, December 19, 2012

LearnStreet Mastermind Game Sample Solution Method 2



function checkAnswerMatch(currentGuess, answer){
    // This method will compare two sequences of input parameters:
    // "currentGuess", the sequence of guesses, and "answer", which
    // is the correct solution sequence generated by the method you wrote
    // above (generateSolution).
    // This method should return the number of correct matches between the
    // two inputs, where a correct match is defined as the same character in
    // the same position in each of the two input strings.
    //WRITE YOUR CODE HERE
    var correctMatches = 0;
    for( var i=0; i < 4; i++ ){
        if(currentGuess[i]===answer[i]){
            correctMatches++;
        }
    }
    return correctMatches;
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts