How to remember score in quiz [Point system]


Hello everybody!
I'm trying to build a very simple quiz.

3 questions.
Question answered correct: +10 points
Questions not answered correct: -5 points.

I'm stuck at the moment, I created a function to add 2 numbers, so I can get past the first question using the start number 0 and the "question is correct" number 10.
But then the trouble starts, how can my code remember that the previous answer is correct and the second question can change the previous number.

Below is my code, hopefully I've described it clearly enough!
Can somebody please help me? I'm pulling out my hair haha! Thank you so much!

var ready = confirm("Are you ready to play my epic quiz?");
if (ready == true) {
	console.log("Let's do this");
} 	else {
	console.log("WHY U NO GAME?");

var pointWin = 10;
var pointLoose = 5;
var score = 0;

var addTen = addTheseNumbers(score, pointWin)

function addTheseNumbers(a, b){
	var sum = a + b;
	return sum;

var userAnswer = window.prompt("Is Barack Obama the President?");

if (userAnswer === "Yes" || userAnswer === "yes" ) {
    console.log("Nice, you now have", addTen);
else {
    console.log("Aawh, you don't know anything, no points for u!");

var userAnswer = window.prompt("Is the earth flat?");

if (userAnswer === "No" || userAnswer === "no" ) {
    console.log("Nice, you now have")
else {
    console.log("You now have");

var userAnswer = window.prompt("How many cans are in a six-pack of beer?");

if (userAnswer === "6") {
    console.log("Nice, you now have");
else {
    console.log("You now have");


Create a variable? Am I missing something? That's how we get our programs to remember things.


Yeah that's what's confusing me.
The code like it is now will put out a "10" to the console when the first question is answered correctly, but how do I remember the 10 inside the code so I can add another 10 or subtract a 5?


var previous_answer = 10;