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

Wednesday, December 19, 2012

LearnStreet Mastermind Game Sample Solution Method 1



function generateSolution(){
    // Create a random string with length 4 containing only values
    // from the letters "ROYGBV". Each of these letters will represent
    // the colors red, orange, yellow, green, blue, and violet.
    // WRITE YOUR CODE HERE
    var randomString = "";
    var possible = "ROYGBV";

    for( var i=0; i < 4; i++ ){
        randomString += possible.charAt(Math.floor(Math.random() * possible.length));
    }
    return randomString;
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts