Why is it saying TypeError: spinResults is not a function


#1

//Make it computerChoice so the computer picks red, blue, or yellow.

confirm("Welcome to The Spinner");
confirm("Press ok to play");
var spin = prompt("Type 'spin' to spin the wheel");

if (spin === spin) {

spinResults();

}

var spinResults = function (spining) {

var mathSpin = Math.random();

if (mathSpin < 0.34) {

console.log("You got red");

} else if (0.34 < mathSpin < 0.67) {

console.log("You got blue");

}
else {

console.log("You got green");

}
};


#2

Two things:

  • if (spin === "spin") {

and

} else if (0.34 < mathSpin < 0.67) {

should be more like:

} else if (mathSpin < 0.67) {

On a side note you never called your "spinResults function" so it'll never display anything to the console.


#3

Now it says undefined right before the answer
//Make it computerChoice so the computer picks red, blue, or yellow.

confirm("Welcome to The Spinner");
confirm("Press ok to play");
var spin = prompt("Type 'spin' to spin the wheel");

if (spin === "spin") {

console.log(sr);

}

var spinResults = function (spining) {

var mathSpin = Math.random();

if (mathSpin < 0.34) {

console.log("You got red");

} else if (mathSpin < 0.67) {

console.log("You got blue");

}
else {

console.log("You got green");

}
};
var sr = spinResults();


#4

Take out this if statement.

if (spin === "spin") {

console.log(sr);

}

var spinResults = function (spining) { //take out the 'spining'

One more thing!

spinResults(); //take out the 'var sr = '

#5

THANK YOU SO MUCH that helped alot