Back to Freecodecamp

Step 7

curriculum/challenges/english/blocks/workshop-mathbot/66eb3ec3b07dfe8f898646c0.md

latest1.7 KB
Original Source

--description--

As you learned in previous lessons, the Math.floor() method rounds the value down to the nearest whole integer.

js
const price = 10.99;
Math.floor(price); // 10

Create a variable called numRoundedDown and assign it the result of rounding the floating point number 6.7 down to the nearest whole integer.

Then, log the numRoundedDown variable to the console to see the result.

--hints--

You should have a numRoundedDown variable.

js
assert.isNotNull(numRoundedDown);

The numRoundedDown variable should be a number.

js
assert.isNumber(numRoundedDown);

Your numRoundedDown variable should equal the result of rounding the floating point number 6.7 down to the nearest whole integer.

js
assert.equal(numRoundedDown, 6);

You should not hardcode the value of 6 for the numRoundedDown variable.

js
assert.notMatch(code, /numRoundedDown\s*=\s*6/);

You should log the numRoundedDown variable to the console.

js
assert.match(code, /console\.log\(\s*numRoundedDown\s*\)/);

--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.");
--fcc-editable-region--

--fcc-editable-region--