Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var box0 = document.getElementById("box0");
- var box1 = document.getElementById("box1");
- var box2 = document.getElementById("box2");
- var box3 = document.getElementById("box3");
- var color1 = "rgb(" + (Math.floor(Math.random() * 256)) + "," + (Math.floor(Math.random() * 256)) + "," + (Math.floor(Math.random() * 256)) + ")";
- var color2 = "rgb(" + (Math.floor(Math.random() * 256)) + "," + (Math.floor(Math.random() * 256)) + "," + (Math.floor(Math.random() * 256)) + ")";
- var color3 = "rgb(" + (Math.floor(Math.random() * 256)) + "," + (Math.floor(Math.random() * 256)) + "," + (Math.floor(Math.random() * 256)) + ")";
- var color0 = [color1, color2, color3];
- var randomNumber = color0 [Math.floor(Math.random() * 3)];
- box0.style.backgroundColor = randomNumber;
- box0.style.width = "100px";
- box0.style.height = "100px";
- box0.style.display = "inline-block";
- box1.style.backgroundColor = color1;
- box1.style.width = "100px";
- box1.style.height = "100px";
- box1.style.display = "inline-block";
- box2.style.backgroundColor = color2;
- box2.style.width = "100px";
- box2.style.height = "100px";
- box2.style.display = "inline-block";
- box3.style.backgroundColor = color3;
- box3.style.width = "100px";
- box3.style.height = "100px";
- box3.style.display = "inline-block";
- //var newcolor = [color1, color2, color3];
- //var new0 = newcolor [Math.floor(Math.random() * 3)];
- //var new1 = newcolor [Math.floor(Math.random() * 3)];
- //var new2 = newcolor [Math.floor(Math.random() * 3)];
- //var new3 = newcolor [Math.floor(Math.random() * 3)];
- box1.onclick = function click () {
- if( box1.style.backgroundColor === box0.style.backgroundColor){
- resultatSvar.innerHTML = "Riktig!";
- box1.style.width = "105px";
- box1.style.height = "105px";
- box1.style.border = "solid 2px";
- //box1.style.backgroundColor = new1;
- //box0.style.backgroundColor = new0;
- }else{
- resultatSvar.innerHTML = "Feil!";
- }
- }
- box2.onclick = function click () {
- if( box2.style.backgroundColor === box0.style.backgroundColor){
- resultatSvar.innerHTML = "Riktig!";
- box2.style.width = "105px";
- box2.style.height = "105px";
- box2.style.border = "solid 2px";
- //box2.style.backgroundColor = new2;
- //box0.style.backgroundColor = new0;
- }else{
- resultatSvar.innerHTML = "Feil!";
- }
- }
- box3.onclick = function click () {
- if( box3.style.backgroundColor === box0.style.backgroundColor){
- resultatSvar.innerHTML = "Riktig!";
- box3.style.width = "105px";
- box3.style.height = "105px";
- box3.style.border = "solid 2px";
- //box3.style.backgroundColor = new3;
- //box0.style.backgroundColor = new0;
- }else{
- resultatSvar.innerHTML = "Feil!";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement