I’m trying to make a little javascript game where you guess a hex code (yes the code currently tells you the hex answer that is so that I can get it wrong/right on purpose) I have a lot of variables with stupid names please don’t criticize on that I’ve had tons of problems with how my variable names are messing up my stuff in the past and so I changed them, basically the variables rar,rbr,gar,gbr,bar,bbr are all strings when I have multiple lines of code redefining them as numbers, I get zero errors in console and have no idea what is wrong. No I am not a profesional coding veteran, please don’t flame me for how awful my code is, I know.
var ra = Math.floor(Math.random() * 16)
var rb = Math.floor(Math.random() * 16)
var ga = Math.floor(Math.random() * 16)
var gb = Math.floor(Math.random() * 16)
var ba = Math.floor(Math.random() * 16)
var bb = Math.floor(Math.random() * 16)
var raa = 0
var rba = 0
var gaa = 0
var gba = 0
var baa = 0
var bba = 0
var rac = 0
var rbc = 0
var bac = 0
var bbc = 0
var gac = 0
var gbc = 0
var rar= 0
var rbr= 0
var gar= 0
var gbr= 0
var bar= 0
var bbr= 0
var rag= 0
var rbg= 0
var gag= 0
var gbg= 0
var bag= 0
var bbg= 0
if (ra == 11){
raa = "A"
} else if (ra == 12){
raa = "B"
} else if (ra == 13){
raa = "C"
} else if (ra == 14){
raa = "D"
} else if (ra == 15){
raa = "E"
} else if (ra == 16){
raa = "F"
} else if (ra == 10){
raa = 0 }else {
raa = ra
}
if (rb == 11){
rba = "A"
} else if (rb == 12){
rba = "B"
} else if (rb == 13){
rba = "C"
} else if (rb == 14){
rba = "D"
} else if (rb == 15){
rba = "E"
} else if (rb == 16){
rba = "F"
} else if (rb == 10){
rba = 0 }else {
rba = rb
}
if (ga == 11){
gaa = "A"
} else if (ga == 12){
gaa = "B"
} else if (ga == 13){
gaa = "C"
} else if (ga == 14){
gaa = "D"
} else if (ga == 15){
gaa = "E"
} else if (ga == 16){
gaa = "F"
} else if (ga == 10){
gaa = 0 }else {
gaa = ga
}
if (gb == 11){
gba = "A"
} else if (gb == 12){
gba = "B"
} else if (gb == 13){
gba = "C"
} else if (gb == 14){
gba = "D"
} else if (gb == 15){
gba = "E"
} else if (gb == 16){
gba = "F"
} else if (gb == 10){
gba = 0 }
else {
gba = gb
}
if (ba == 11){
baa = "A"
} else if (ba == 12){
baa = "B"
} else if (ba == 13){
baa = "C"
} else if (ba == 14){
baa = "D"
} else if (ba == 15){
baa = "E"
} else if (ba == 16){
baa = "F"
}else if (ba == 10){
baa = 0 }else {
baa = ba
}
if (bb == 11){
bba = "A"
} else if (bb == 12){
bba = "B"
} else if (bb == 13){
bba = "C"
} else if (bb == 14){
bba = "D"
} else if (bb == 15){
bba = "E"
} else if (bb == 16){
bba = "F"
} else if (bb == 10){
bba = 0
}else if (bb == 10){
bba = 0 }else {
bba = bb
}
answer = ""+raa+""+rba+""+gaa+""+gba+""+baa+""+bba
document.body.style.backgroundColor = "#" + answer;
var percen = 0
function colorstuff() {
alert("guess the color of the background")
alert(answer)
var mayb = prompt("enter the hex code")
rag = mayb.charAt(0)
rbg = mayb.charAt(1)
gag = mayb.charAt(2)
gbg = mayb.charAt(3)
bag = mayb.charAt(4)
bbg = mayb.charAt(5)
raa = answer.charAt(0);
rba = answer.charAt(1);
gaa = answer.charAt(2);
gba = answer.charAt(3);
baa = answer.charAt(4);
bba = answer.charAt(5);
if (rag === "A"){
rar= 11
} else if (rag === "B"){
rar= 12
} else if (rag === "C"){
rar= 13
} else if (rag === "D"){
rar= 14
} else if (rag === "E"){
rar= 15
} else if (rag === "F"){
rar= 16
} else if (rag === 0){
rar= 10 }else {
rar= rag
}
if (rbg === "A"){
rbr= 11
} else if (rbg === "B"){
rbr= 12
} else if (rbg === "C"){
rbr= 13
} else if (rbg === "D"){
rbr= 14
} else if (rbg === "E"){
rbr= 15
} else if (rbg === "F"){
rbr= 16
} else if (rbg === 0){
rbr= 10 }else {
rbr= rbg
}
if (gag === "A"){
gar= 11
} else if (gag === "B"){
gar= 12
} else if (gag === "C"){
gar= 13
} else if (gag === "D"){
gar= 14
} else if (gag === "E"){
gar= 15
} else if (gag === "F"){
gar= 16
} else if (gag === 0){
gar= 10 }else {
gar= gag
}
if (gbg === "A"){
gbr= 11
} else if (gbg === "B"){
gbr= 12
} else if (gbg === "C"){
gbr= 13
} else if (gbg === "D"){
gbr= 14
} else if (gbg === "E"){
gbr= 15
} else if (gbg === "F"){
gbr= 16
} else if (gbg === 0){
gbr= 10 }else {
gbr= gbg
}
if (bag === "A"){
bar= 11
} else if (bag === "B"){
bar= 12
} else if (bag === "C"){
bar= 13
} else if (bag === "D"){
bar= 14
} else if (bag === "E"){
bar= 15
} else if (bag === "F"){
bar= 16
} else if (bag === 0){
bar= 10 }else {
bar= bag
}
if (bbg === "A"){
bbr= 11
} else if (bbg === "B"){
bbr= 12
} else if (bbg === "C"){
bbr= 13
} else if (bbg === "D"){
bbr= 14
} else if (bbg === "E"){
bbr= 15
} else if (bbg === "F"){
bbr= 16
} else if (bbg === 0){
bbr= 10 }else {
bbr= bbg
}
if (raa === "A"){
ra = 11
} else if (raa === "B"){
ra = 12
} else if (raa === "C"){
ra = 13
} else if (raa === "D"){
ra = 14
} else if (raa === "E"){
ra = 15
} else if (raa === "F"){
ra = 16
} else if (raa === 0){
ra = 10 }else {
ra = raa
}
if (rba === "A"){
rb = 11
} else if (rba === "B"){
rb = 12
} else if (rba === "C"){
rb = 13
} else if (rba === "D"){
rb = 14
} else if (rba === "E"){
rb = 15
} else if (rba === "F"){
rb = 16
} else if (rba === 0){
rb = 10 }else {
rb = rba
}
if (gaa === "A"){
ga = 11
} else if (gaa === "B"){
ga = 12
} else if (gaa === "C"){
ga = 13
} else if (gaa === "D"){
ga = 14
} else if (gaa === "E"){
ga = 15
} else if (gaa === "F"){
ga = 16
} else if (gaa === 0){
ga = 10 }else {
ga = gaa
}
if (gba === "A"){
gb = 11
} else if (gba === "B"){
gb = 12
} else if (gba === "C"){
gb = 13
} else if (gba === "D"){
gb = 14
} else if (gba === "E"){
gb = 15
} else if (gba === "F"){
gb = 16
} else if (gba === 0){
gb = 10 }
else {
gb = gba
}
if (baa === "A"){
ba = 11
} else if (baa === "B"){
ba = 12
} else if (baa === "C"){
ba = 13
} else if (baa === "D"){
ba = 14
} else if (baa === "E"){
ba = 15
} else if (baa === "F"){
ba = 16
}else if (baa === 0){
ba = 10 }else {
ba = baa
}
if (bba === "A"){
bb = 11
} else if (bba === "B"){
bb = 12
} else if (bba === "C"){
bb = 13
} else if (bba === "D"){
bb = 14
} else if (bba === "E"){
bb = 15
} else if (bba === "F"){
bb = 16
} else if (bba === 0){
bb = 10
}else {
bb = bba
}
rag = parseFloat(rag)
rbg = parseFloat(rbg)
gag = parseFloat(gag)
gbg = parseFloat(gbg)
bag = parseFloat(bag)
bbg = parseFloat(bbg)
rar = parseFloat(rar)
rbr = parseFloat(rbr)
gar = parseFloat(gar)
gbr = parseFloat(gbr)
bar = parseFloat(bar)
bbr = parseFloat(bbr)
rag = parseInt(rag)
rbg = parseInt(rbg)
gag = parseInt(gag)
gbg = parseInt(gbg)
bag = parseInt(bag)
bbg = parseInt(bbg)
rar = parseInt(rar)
rbr = parseInt(rbr)
gar = parseInt(gar)
gbr = parseInt(gbr)
bar = parseInt(bar)
bbr = parseInt(bbr)
rag = Number(rag)
rbg = Number(rbg)
gag = Number(gag)
gbg = Number(gbg)
bag = Number(bag)
bbg = Number(bbg)
rar = Number(rar)
rbr = Number(rbr)
gar = Number(gar)
gbr = Number(gbr)
bar = Number(bar)
bbr = Number(bbr)
if (rar = ra){
rac = 100
} else if (rar < ra){
rac = (rar/ra)*100
} else if (rar > ra){
rac = (ra/rar)*100
}
if (rbr = rb){
rbc = 100
} else if (rbr < rb){
rbc = (rbr/rb)*100
} else if (rbr > rb){
rbc = (rb/rbr)*100
}
if (gar = ga){
gac = 100
} else if (gar < ga){
gac = (gar/ga)*100
} else if (gar > ga){
gac = (ga/gar)*100
}
if (gbr = gb){
gbc = 100
} else if (gbr < gb){
gbc = (gbr/gb)*100
} else if (gbr > gb){
gbc = (gb/gbr)*100
}
if (bar = ba){
bac = 100
} else if (bar < ba){
bac = (bar/ba)*100
} else if (bar > ba){
bac = (ba/bar)*100
}
if (bbr = bb){
bbc = 100
} else if (bbr < bb){
bbc = (bbr/bb)*100
} else if (bbr > bb){
bbc = (bb/bbr)*100
}
percen = (rac+rbc+gac+gbc+bac+bbc)/6
alert(percen)
alert(""+ra+""+rb+""+ga+""+gb+""+ba+""+bb)
}