What is 12 in Gray Code?

12 in decimal is 1010 in Gray code.

example of convert binary number to gray code in javascript

<!-- Binary To Gray Code -->
<script type="text/javascript">
	function binaryToGray (number){
		if(isBinary(number)){
			var gray = "";
			gray = gray + number.charAt(0);
			for (var i = 1; i < number.length; i++) {
				if (number.charAt(i) == number.charAt(i-1)) {
					gray = gray + '0';
				}
				else{
					gray = gray + '1';
				}
			}
			document.getElementById('result').innerHTML  = gray;
		}else{
			document.getElementById('result').innerHTML  = "Input is not a binary number";
		}
	}