Build a Mathbot - Step 9

Tell us what’s happening:

I can see what’s my mistake in this step, it is saying you should have a variable called randomInt , but i have one:
let min = 5;
let max = 100;
let randomInt = Math.floor(Math.random() * (max - min) + min);
console.log(randomInt);

Your code so far

const botName = "MathBot";
const greeting = `Hi there! My name is ${botName} and I am here to teach you about the Math object!`;

console.log(greeting);

console.log("The Math.random() method returns a pseudo random number greater than or equal to 0 and less than 1.");

const randomNum = Math.random();
console.log(randomNum);

console.log("Now, generate a random number between two values.");

const min = 1;
const max = 100;

const randomNum2 = Math.random() * (max - min) + min;
console.log(randomNum2);

console.log("The Math.floor() method rounds the value down to the nearest whole integer.");

const numRoundedDown = Math.floor(6.7);
console.log(numRoundedDown);

console.log("Now, generate a random integer between two values.");
let min = 5;
let max = 100;

// User Editable Region

let randomInt = Math.floor(Math.random() * (max - min) + min);
console.log(randomInt);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Mathbot - Step 9

Welcome to the forum @Ali16 !

The code you wrote looks correct, but when I replace all of the starting code with your code, it breaks.

Try resetting the step to restore the starting code and try again.

Happy coding!

are you sure you can declare multiple variables with the same name? you have min and max twice, isn’t there a message about this in the console?

oh, thanks so much, Never mind, I found the issue. I had redeclared min and max with let even though they were already defined earlier. After removing those lines, the code worked and the test passed.