Back to Freecodecamp

Step 16

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

latest3.5 KB
Original Source

--description--

For the last step of the workshop, you will log the message "It was fun learning about the different Math methods with you!" to the console.

And with that last change, you have completed the MathBot workshop!

--hints--

You should log the message "It was fun learning about the different Math methods with you!" to the console.

js
assert.match(code, /console\.log\((['"`])It\s+was\s+fun\s+learning\s+about\s+the\s+different\s+Math\s+methods\s+with\s+you\!\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);

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

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

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

const numRoundedUp = Math.ceil(3.2);
console.log(numRoundedUp);

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

const numRounded = Math.round(2.7);
console.log(numRounded);
const numRounded2 = Math.round(11.2);
console.log(numRounded2);

console.log("The Math.max() and Math.min() methods are used to get the maximum and minimum number from a range.");

const maxNum = Math.max(3, 125, 55, 24);
console.log(maxNum);
const minNum = Math.min(6, 90, 14, 90, 2);
console.log(minNum);

--fcc-editable-region--

--fcc-editable-region--

--solutions--

js
const botName = "MathBot";
const greeting = `Hi there! My name is ${botName} and I want to teach you about the different Math methods in JavaScript.`;

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 max = 100;
const min = 1;

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

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

console.log(
  "The Math.ceil() method rounds the value up to the nearest whole integer."
);
const numRoundedUp = Math.ceil(3.2);
console.log(numRoundedUp);

console.log(
  "The Math.round() method rounds the value to the nearest whole integer."
);
const numRounded = Math.round(2.7);
console.log(numRounded);
const numRounded2 = Math.round(11.2);
console.log(numRounded2);

console.log(
  "The Math.max() and Math.min() methods are used to get the maximum and minimum number from a range."
);
const maxNum = Math.max(3, 125, 55, 24);
console.log(maxNum);
const minNum = Math.min(6, 90, 14, 90, 2);
console.log(minNum);

console.log("It was fun learning about the different Math methods with you!");