-1

I am making a personality quiz where your result will be based on how many points you get in the end. There are multiple buttons which give you different amounts of points. The last button is a "are you finished button" where your points will add up and you will get your result. I tried testing this by pressing the button which will give you 200 points. But nothing happened. Anyone know what is wrong?

var poeng = 0;
                             
function answerOne() {

poeng = 200;

console.log(poeng)
check()
}

function answerTwo() {

poeng = -300;

console.log(poeng)
check()
}

function answerThree() {

poeng = 500;

console.log(poeng)
check()
}

function answerFour() {

poeng = 600;

console.log(poeng)
check()
}

function answerFive() {

if(poeng == 200) {

poeng = poeng + 0;

console.log(poeng)
check()
}

else if (poeng == -300) {

poeng = poeng - 300;

console.log(poeng)
check()
}

else if (poeng == 500) {

poeng = poeng - 1000;

console.log(poeng)
check()
}

else if (poeng == 600) {

poeng = poeng + 0;

console.log(poeng)
check()
}

console.log(poeng)
check()
}

function check() {

if(poeng => 200) {

 document.write('<img style="position: relative; top: 500px; left: 200px;" src="bilder/cat2.jpg">');

}
}
  • Please try using the [debugging capabilities](//developer.mozilla.org/en-US/docs/Mozilla/Debugging/Debugging_JavaScript) of your browser. Learn about [how to debug small programs](//ericlippert.com/2014/03/05/how-to-debug-small-programs/). Use tools like [JSHint](//jshint.com/) to find problems with your code immediately. Use the [browser console (dev tools)](//webmasters.stackexchange.com/q/8525) (hit `F12`) and read any errors. Read the [JS docs](//developer.mozilla.org/en-US/docs/Web/JavaScript/Reference) and [tutorials](//developer.mozilla.org/en-US/docs/Web/JavaScript/Guide). – Sebastian Simon May 30 '21 at 16:03
  • `document.write` is [not recommended](/q/802854/4642212) for DOM manipulations, as it is obsolete, slow and not suitable for any evolving application. See [the documentation about the DOM API on MDN](//developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) and use methods and properties that aren’t discouraged. – Sebastian Simon May 30 '21 at 16:04

1 Answers1

1

It should be

poeng >= 200

not

poeng => 200

=> creates an arrow function while >= checks for greater than or equal to

Luke-zhang-04
  • 782
  • 7
  • 11