Back to Freecodecamp

Step 8

curriculum/challenges/english/blocks/workshop-mathbot/69218a15fe536ee1be38aefb.md

latest1.4 KB
Original Source

--description--

The next portion of the workshop is to review how to generate a random integer between two values.

Start by adding another console.log() that logs the message "Now, generate a random integer between two values." to the console.

In the next step, you will generate a random integer between the values of the min and max variables you have already created.

--hints--

You should have a console.log() that logs the message "Now, generate a random integer between two values.".

js
assert.match(code, /console\.log\((`|'|")\s*Now,\s+generate\s+a\s+random\s+integer\s+between\s+two\s+values\.\s*\1\);?/);

--seed--

--seed-contents--

js
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);

--fcc-editable-region--

--fcc-editable-region--