12. Higher or Lower. Recursion in Javascript

Please I don’t know what I am doing wrong. I am getting “Oops, try again. false”. Please help! https://www.codecademy.com/courses/javascript-lesson-205/2/3#

This is my code:

function guessNumber(number) {
// Prompt the user for a number
var guess = prompt(“Guess a number between 1 and 100”);

// Convert their guess to a number using +
guess = +guess;

// Define base case
if (guess === number) {
return console.log("You got it! The number was " + number);
} else {
console.log(“Please try again”);
}
// Define recursive case with a function call
guessNumber(number);
}

// Call the function guessNumber() with an integer for an argument
guessNumber(7);

var guess = prompt(“Guess a number between 1 and 100”);

remove the var keyword.

Though it’s not your fault but the system checker doesn’t expect it.

1 Like

Thank You! It worked!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.