How can I improve this version of the board game Mastermind?
The first thing I notice is that you're "manually" handling both color and position. This isn't actually necessary if you set everything up using simple arrays.

An array is, by definition, an indexed list of values. So if you use a simple array for your code and the pegs, then positions are the array's indices and colors are its values. This simplifies things considerably.

For instance, to find exact (color and position) matches, you only need to check if code[i] === pegs[i]. And to check if a peg matches anywhere in the code, you only need to check code.indexOf(peg[i]) !== -1. So if you can get something like this:

var code = ["white","black","red","blue","green"];  // the code
var pegs = ["white","black","blue","red","orange"]; // the player's selections


it'll make the checking a lot easier.

Now, along the way you'll need to do some extra work to keep track of the number of matches, and make sure you're not double-matching stuff. I.e. you need to pare down your arrays as you go, so they only contain the remaining unmatched values.

Here's an example:

function evaluateSolution(code, pegs) {
  var i, l,
      foundIndex,
      exactMatches = 0,
      valueMatches = 0;

  // copy the arrays, so we don't ruin the orignals
  code = code.slice(0);
  pegs = pegs.slice(0);

  // First pass: Look for value &amp; position matches
  // We're looping "backwards", so we can safely remove items
  // "behind us"
  for( i = pegs.length - 1 ; i &gt;= 0 ; i-- ) {
    // If there's a match, remove the matched index from both
    // the code and the pegs so it isn't matched again later.
    if(pegs[i] === code[i]) {
      exactMatches++;
      pegs.splice(i, 1);
      code.splice(i, 1);
    }
  }

  // Now, pegs and code only contain unmatched values

  // Second pass: Look for value matches anywhere in the code
  for( i = 0 , l = pegs.length ; i &lt; l ; i++ ) {
    // attempt to find the peg in the remaining code
    foundIndex = code.indexOf(pegs[i]);
    if( foundIndex !== -1 ) {
      valueMatches++;
      // remove the matched code peg, since it's been matched
      code.splice(foundIndex, 1);
    }
  }

  // Now, return the number of exact and inexact matches
  // as an object, so it's easy to use
  return {
    exactMatches: exactMatches,
    valueMatches: valueMatches,
    totalMatches: exactMatches + valueMatches
  };
}


If you feed the arrays above to evaluateSolution() you'll get this back:

{
  exactMatches: 2,
  valueMatches: 2,
  totalMatches: 4
}


If exactMatches === code.length, then congrats, you've won! Otherwise, use the numbers to render the hint.



Other observations:


You leave a lot of blank lines in your code, but the non-blank lines are pretty crammed (e.g. your whitespace-less for-loop declarations). Give you code (and the reader) some space to breathe. 
I looked briefly at the code on GitHub, and there's a lot going on. Too much really. But here's a hint: You can build most of HTML using JavaScript. Copy/pasting the HTML for each "turn" and giving it a new ID is a nightmare to deal with. Just loop and create elements in code.