From 41baee79a8e150fd70b2448849eef1a3e054b316 Mon Sep 17 00:00:00 2001 From: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Date: Wed, 25 Sep 2024 08:52:09 -0700 Subject: [PATCH] feat(curriculum): adding the Mathbot workshop to frontend cert (#56173) Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com> --- client/i18n/locales/english/intro.json | 7 +- .../workshop-mathbot/index.md | 9 ++ .../_meta/workshop-mathbot/meta.json | 69 ++++++++++ .../66ea7adae8053065a64f9002.md | 72 ++++++++++ .../66ea7e7399244c6d4b6052a1.md | 34 +++++ .../66ea7fc048a6e26e33c598fe.md | 61 +++++++++ .../66ea8239b9eeb76f12299030.md | 79 +++++++++++ .../66ea845f54195c7020cc521b.md | 76 +++++++++++ .../66ea89c25e1bd871688eba6a.md | 49 +++++++ .../66eb3ec3b07dfe8f898646c0.md | 80 +++++++++++ .../66eb480d996af5918d7c9c86.md | 52 +++++++ .../66eb488c0129e192542f0865.md | 88 ++++++++++++ .../66eb499511810e932ca7eecc.md | 58 ++++++++ .../66ecdcf7c8d9a6f49094ffde.md | 113 ++++++++++++++++ .../66ece0b518f5dcf5930612ab.md | 66 +++++++++ .../66ece147323c91f654bf8dd9.md | 118 ++++++++++++++++ .../66ece75c0b840df77c7e20f0.md | 127 ++++++++++++++++++ 17 files changed, 1157 insertions(+), 1 deletion(-) create mode 100644 client/src/pages/learn/front-end-development/workshop-mathbot/index.md create mode 100644 curriculum/challenges/_meta/workshop-mathbot/meta.json create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7adae8053065a64f9002.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7e7399244c6d4b6052a1.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7fc048a6e26e33c598fe.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea8239b9eeb76f12299030.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea845f54195c7020cc521b.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea89c25e1bd871688eba6a.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb3ec3b07dfe8f898646c0.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb480d996af5918d7c9c86.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb488c0129e192542f0865.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb499511810e932ca7eecc.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ecdcf7c8d9a6f49094ffde.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece0b518f5dcf5930612ab.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece147323c91f654bf8dd9.md create mode 100644 curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece75c0b840df77c7e20f0.md diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 038e7e17393..1ad6d9f58fe 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -2087,7 +2087,12 @@ ] }, "hxwa": { "title": "141", "intro": [] }, - "xkbo": { "title": "142", "intro": [] }, + "workshop-mathbot": { + "title": "Build a Mathbot", + "intro": [ + "In this workshop, you will review how to work with the different Math object methods by building a Mathbot." + ] + }, "lab-fortune-teller": { "title": "Build a Fortune Teller", "intro": [ diff --git a/client/src/pages/learn/front-end-development/workshop-mathbot/index.md b/client/src/pages/learn/front-end-development/workshop-mathbot/index.md new file mode 100644 index 00000000000..02a4a0dbb96 --- /dev/null +++ b/client/src/pages/learn/front-end-development/workshop-mathbot/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Build a Mathbot +block: workshop-mathbot +superBlock: front-end-development +--- + +## Introduction to the Build a Mathbot + +This is a test for the new project-based curriculum. diff --git a/curriculum/challenges/_meta/workshop-mathbot/meta.json b/curriculum/challenges/_meta/workshop-mathbot/meta.json new file mode 100644 index 00000000000..dc2480b25b7 --- /dev/null +++ b/curriculum/challenges/_meta/workshop-mathbot/meta.json @@ -0,0 +1,69 @@ +{ + "name": "Build a Mathbot", + "blockType": "workshop", + "isUpcomingChange": true, + "usesMultifileEditor": true, + "hasEditableBoundaries": true, + "dashedName": "workshop-mathbot", + "order": 142, + "superBlock": "front-end-development", + "challengeOrder": [ + { + "id": "66ea7adae8053065a64f9002", + "title": "Step 1" + }, + { + "id": "66ea7e7399244c6d4b6052a1", + "title": "Step 2" + }, + { + "id": "66ea7fc048a6e26e33c598fe", + "title": "Step 3" + }, + { + "id": "66ea8239b9eeb76f12299030", + "title": "Step 4" + }, + { + "id": "66ea845f54195c7020cc521b", + "title": "Step 5" + }, + { + "id": "66ea89c25e1bd871688eba6a", + "title": "Step 6" + }, + { + "id": "66eb3ec3b07dfe8f898646c0", + "title": "Step 7" + }, + { + "id": "66eb480d996af5918d7c9c86", + "title": "Step 8" + }, + { + "id": "66eb488c0129e192542f0865", + "title": "Step 9" + }, + { + "id": "66eb499511810e932ca7eecc", + "title": "Step 10" + }, + { + "id": "66ecdcf7c8d9a6f49094ffde", + "title": "Step 11" + }, + { + "id": "66ece0b518f5dcf5930612ab", + "title": "Step 12" + }, + { + "id": "66ece147323c91f654bf8dd9", + "title": "Step 13" + }, + { + "id": "66ece75c0b840df77c7e20f0", + "title": "Step 14" + } + ], + "helpCategory": "JavaScript" +} \ No newline at end of file diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7adae8053065a64f9002.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7adae8053065a64f9002.md new file mode 100644 index 00000000000..12e6b83d243 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7adae8053065a64f9002.md @@ -0,0 +1,72 @@ +--- +id: 66ea7adae8053065a64f9002 +title: Step 1 +challengeType: 1 +dashedName: step-1 +--- + +# --description-- + +In this workshop, you will review working with the different `Math` object methods by building a Mathbot. This Mathbot will log some math operations and messages to the console in efforts to teach you about JavaScript's `Math` object. + +For this first step, start by creating a variable called `botName` and assign it the string value of `"MathBot"`. + +Then, create another variable called `greeting` and assign it the sentence `"Hi there! My name is [botName goes here] and I am here to teach you about the Math object!"`. In place of the `[botName goes here]` placeholder, use the `botName` variable. + +You are free to use template literals or string concatenation with the `+` operator to achieve this. + +Finally, log the `greeting` variable to the console. + +# --hints-- + +You should have a variable called `botName`. + +```js +assert.isNotNull(botName); +``` + +Your `botName` variable should be a string. + +```js +assert.isString(botName); +``` + +You should assign the string value `"MathBot"` to the `botName` variable. + +```js +assert.strictEqual(botName, "MathBot"); +``` + +You should have a variable called `greeting`. + +```js +assert.isNotNull(greeting); +``` + +Your `greeting` variable should be a string. + +```js +assert.isString(greeting); +``` + +You should use assign the following sentence to the `greeting` variable: `"Hi there! My name is [MathBot goes here] and I am here to teach you about the Math object!"`. Make sure to replace `[MathBot goes here]` with the `botName` variable. + +```js +assert.strictEqual(greeting, "Hi there! My name is MathBot and I am here to teach you about the Math object!"); +``` + +You should log the `greeting` variable to the console. + +```js +assert.match(code, /console\.log\(greeting\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7e7399244c6d4b6052a1.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7e7399244c6d4b6052a1.md new file mode 100644 index 00000000000..bd69b1cc9f0 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7e7399244c6d4b6052a1.md @@ -0,0 +1,34 @@ +--- +id: 66ea7e7399244c6d4b6052a1 +title: Step 2 +challengeType: 1 +dashedName: step-2 +--- + +# --description-- + +The next part of the workshop will review how the `Math.random()` method works. + +Start by adding another `console.log()` that logs the string `"The Math.random() method returns a pseudo random number between 0 and less than 1."` to the console. + +# --hints-- + +You should have a `console.log()` that logs the string `"The Math.random() method returns a pseudo random number between 0 and less than 1."`. + +```js +assert.match(code, /console\.log\((`|'|")\s*The\s+Math\.random\(\)\s+method\s+returns\s+a\s+pseudo\s+random\s+number\s+between\s+0\s+and\s+less\s+than\s+1\.\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); +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7fc048a6e26e33c598fe.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7fc048a6e26e33c598fe.md new file mode 100644 index 00000000000..c2e6e5d9b83 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea7fc048a6e26e33c598fe.md @@ -0,0 +1,61 @@ +--- +id: 66ea7fc048a6e26e33c598fe +title: Step 3 +challengeType: 1 +dashedName: step-3 +--- + +# --description-- + +Now, it is time to generate a random number using the `Math.random()` method. + +Create a variable called `randomNum` and assign it the value of the result of calling the `Math.random()` method. + +Then, log the `randomNum` variable to the console. + +Try adding a space in the code to re-run the bot and see different random numbers that are generated. + +# --hints-- + +You should have a variable called `randomNum`. + +```js +assert.isNotNull(randomNum); +``` + +You should assign the result of calling the `Math.random()` method to the `randomNum` variable. + +```js +assert.match(code, /randomNum\s*=\s*Math\.random\(\);?/); +``` + +You should not hardcode a random number for the `randomNum` variable. Make sure to use the `Math.random()` method to generate the random number. + +```js +assert.notMatch(code, /randomNum\s*=\s*0\.\d+;?/); + +// check for whole random numbers just in case a camper does this +assert.notMatch(code, /randomNum\s*=\s*\d+;?/); +``` + +You should log the `randomNum` variable to the console. + +```js +assert.match(code, /console\.log\(\s*randomNum\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 between 0 and less than 1."); +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea8239b9eeb76f12299030.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea8239b9eeb76f12299030.md new file mode 100644 index 00000000000..43e3ffe0c43 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea8239b9eeb76f12299030.md @@ -0,0 +1,79 @@ +--- +id: 66ea8239b9eeb76f12299030 +title: Step 4 +challengeType: 1 +dashedName: step-4 +--- + +# --description-- + +The next portion of the workshop is to review how to generate a random number between two values. + +Start by adding another `console.log()` that logs the message `"Now, generate a random number between two values."` to the console. + +Then, create a variable called `min` and assign it the value of `1` and create a variable called `max` and assign it the value of `100`. + +In the next step, you will generate a random number between these two values. + +# --hints-- + +You should have a `console.log()` that logs the message `"Now, generate a random number between two values."`. + +```js +assert.match(code, /console\.log\((`|'|")\s*Now,\s+generate\s+a\s+random\s+number\s+between\s+two\s+values\.\s*\1\);?/); +``` + +You should have a variable called `min`. + +```js +assert.isNotNull(min); +``` + +Your `min` variable should be a number. + +```js +assert.isNumber(min); +``` + +You should assign the number `1` to your `min` variable. + +```js +assert.equal(min, 1); +``` + +You should have a variable called `max`. + +```js +assert.isNotNull(max); +``` + +Your `max` variable should be a number. + +```js +assert.isNumber(max); +``` + +You should assign the number `100` to your `max` variable. + +```js +assert.equal(max, 100); +``` + +# --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 between 0 and less than 1."); + +const randomNum = Math.random(); +console.log(randomNum); +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea845f54195c7020cc521b.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea845f54195c7020cc521b.md new file mode 100644 index 00000000000..73499467345 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea845f54195c7020cc521b.md @@ -0,0 +1,76 @@ +--- +id: 66ea845f54195c7020cc521b +title: Step 5 +challengeType: 1 +dashedName: step-5 +--- + +# --description-- + +The formula to generate a random number between two values is the following: + +```js +Math.random() * (maximum - minimum) + minimum; +``` + +This will produce a result that is a floating point number between two values. + +Create a variable called `randomNum2` and assign it the result of generating a value between the `min` and `max` values. + +Then, log the `randomNum2` variable to see the result. Try refreshing the page to see different results. + +# --hints-- + +You should have a variable called `randomNum2`. + +```js +assert.isNotNull(randomNum2); +``` + +Your `randomNum2` variable should be a number. + +```js +assert.isNumber(randomNum2); +``` + +You should assign the result of generating a value between the `min` and `max` values. Make sure not to hardcode a value. You should use the formulae provided above. + +```js +assert.isAtLeast(randomNum2, min); +assert.isAtMost(randomNum2, max); + +assert.notMatch(code, /randomNum2\s*=\s*0\.\d+;?/); + +// check for whole random numbers just in case a camper does this +assert.notMatch(code, /randomNum2\s*=\s*\d+;?/); +``` + +You should log the `randomNum2` variable to the console. + +```js +assert.match(code, /console\.log\(\s*randomNum2\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 between 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; +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea89c25e1bd871688eba6a.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea89c25e1bd871688eba6a.md new file mode 100644 index 00000000000..309cb1fd5a9 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ea89c25e1bd871688eba6a.md @@ -0,0 +1,49 @@ +--- +id: 66ea89c25e1bd871688eba6a +title: Step 6 +challengeType: 1 +dashedName: step-6 +--- + +# --description-- + +Up until this point, you have only been dealing with floating point numbers and the number `0`. + +For the next part of the workshop, you will review how to work with the `Math.floor()` method. + +Start by adding a `console.log()` that logs the message `"The Math.floor() method rounds the value down to the nearest whole integer."` + +# --hints-- + +You should log the message `"The Math.floor() method rounds the value down to the nearest whole integer."` + +```js +assert.match(code, /console\.log\((["'])The\s+Math\.floor\(\)\s+method\s+rounds\s+the\s+value\s+down\s+to\s+the\s+nearest\s+whole\s+integer\.\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 between 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); +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb3ec3b07dfe8f898646c0.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb3ec3b07dfe8f898646c0.md new file mode 100644 index 00000000000..d9cb1dc8e5b --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb3ec3b07dfe8f898646c0.md @@ -0,0 +1,80 @@ +--- +id: 66eb3ec3b07dfe8f898646c0 +title: Step 7 +challengeType: 1 +dashedName: step-7 +--- + +# --description-- + +As you learned in the previous lecture videos, 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 between 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-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb480d996af5918d7c9c86.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb480d996af5918d7c9c86.md new file mode 100644 index 00000000000..c538d34f3eb --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb480d996af5918d7c9c86.md @@ -0,0 +1,52 @@ +--- +id: 66eb480d996af5918d7c9c86 +title: Step 8 +challengeType: 1 +dashedName: step-8 +--- + +# --description-- + +Now, it is time to review how the `Math.ceil()` method works. + +Start by logging the string `"The Math.ceil() method rounds the value up to the nearest whole integer."` to the console. + +# --hints-- + +You should log the message `"The Math.ceil() method rounds the value up to the nearest whole integer."` + +```js +assert.match(code, /console\.log\((['"`])The\s+Math\.ceil\(\)\s+method\s+rounds\s+the\s+value\s+up\s+to\s+the\s+nearest\s+whole\s+integer\.\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 between 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-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb488c0129e192542f0865.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb488c0129e192542f0865.md new file mode 100644 index 00000000000..4092057fbe6 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb488c0129e192542f0865.md @@ -0,0 +1,88 @@ +--- +id: 66eb488c0129e192542f0865 +title: Step 9 +challengeType: 1 +dashedName: step-9 +--- + +# --description-- + +In the previous lecture videos, you learned how to work with the `Math.ceil()` method like this: + +```js +const price = 10.01; +Math.ceil(price); // 11 +``` + +The `Math.ceil()` method rounds the value up to the nearest whole integer. + +Create a variable called `numRoundedUp` and assign it the result of rounding the floating point number `3.2` up to the nearest whole integer. + +Then, log the `numRoundedUp` variable to the console to see the result. + +# --hints-- + +You should have a `numRoundedUp` variable. + +```js +assert.isNotNull(numRoundedUp); +``` + +The `numRoundedUp` variable should be a number. + +```js +assert.isNumber(numRoundedUp); +``` + +Your `numRoundedUp` variable should equal the result of rounding the floating point number `3.2` down to the nearest whole integer. + +```js +assert.equal(numRoundedUp, 4); +``` + +You should not hardcode the value of `4` for the `numRoundedUp` variable. + +```js +assert.notMatch(code, /numRoundedUp\s*=\s*4/); +``` + +You should log the `numRoundedUp` variable to the console. + +```js +assert.match(code, /console\.log\(\s*numRoundedUp\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 between 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("The Math.ceil() method rounds the value up to the nearest whole integer."); + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb499511810e932ca7eecc.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb499511810e932ca7eecc.md new file mode 100644 index 00000000000..494cba51b8f --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66eb499511810e932ca7eecc.md @@ -0,0 +1,58 @@ +--- +id: 66eb499511810e932ca7eecc +title: Step 10 +challengeType: 1 +dashedName: step-10 +--- + +# --description-- + +The next portion of the workshop will review how to round numbers to the nearest whole integer. + +Start by adding a `console.log()` that logs the message `"The Math.round() method rounds the value to the nearest whole integer."` to the console. + +# --hints-- + +You should log the message `"The Math.round() method rounds the value to the nearest whole integer."` to the console. + +```js +assert.match(code, /console\.log\((['"])The\s+Math\.round\(\)\s+method\s+rounds\s+the\s+value\s+to\s+the\s+nearest\s+whole\s+integer\.\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 between 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("The Math.ceil() method rounds the value up to the nearest whole integer."); + +const numRoundedUp = Math.ceil(3.2); +console.log(numRoundedUp); + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ecdcf7c8d9a6f49094ffde.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ecdcf7c8d9a6f49094ffde.md new file mode 100644 index 00000000000..bc778f96e01 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ecdcf7c8d9a6f49094ffde.md @@ -0,0 +1,113 @@ +--- +id: 66ecdcf7c8d9a6f49094ffde +title: Step 11 +challengeType: 1 +dashedName: step-11 +--- + +# --description-- + +In the lecture videos, you learned that the `Math.round()` method rounds the value to the nearest whole integer. + +Here are some examples: + +```js +Math.round(6.7); // 7 +Math.round(3.2); // 3 +``` + +This differs from the `Math.floor()` and `Math.ceil()` methods, which round down and up to the nearest whole integer, respectively. + +Create a new variable called `numRounded` and assign the result of rounding the number `2.7`. Then, log the value of `numRounded` to the console. + +Below that, create another new variable called `numRounded2` and assign the result of rounding the number `11.2`. Then, log the value of `numRounded2` to the console. + +# --hints-- + +You should have a variable called `numRounded`. + +```js +assert.isNotNull(numRounded); +``` + +You should assign the result of rounding the number `2.7` to the variable `numRounded`. + +```js +assert.equal(numRounded, 3); +``` + +You should not hardcode the value of `3` for the variable `numRounded`. Make sure you are using the `Math.round()` method. + +```js +assert.notMatch(code, /numRounded\s*=\s*3/); +``` + +You should log the value of `numRounded` to the console. + +```js +assert.match(code, /console\.log\(\s*numRounded\s*\)/); +``` + +You should have a variable called `numRounded2`. + +```js +assert.isNotNull(numRounded2); +``` + +You should assign the result of rounding the number `11.2` to the variable `numRounded2`. + +```js +assert.equal(numRounded2, 11); +``` + +You should not hardcode the value of `11` for the variable `numRounded2`. Make sure you are using the `Math.round()` method. + +```js +assert.notMatch(code, /numRounded2\s*=\s*11/); +``` + +You should log the value of `numRounded2` to the console. + +```js +assert.match(code, /console\.log\(\s*numRounded2\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 between 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("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."); + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece0b518f5dcf5930612ab.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece0b518f5dcf5930612ab.md new file mode 100644 index 00000000000..522a30777ff --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece0b518f5dcf5930612ab.md @@ -0,0 +1,66 @@ +--- +id: 66ece0b518f5dcf5930612ab +title: Step 12 +challengeType: 1 +dashedName: step-12 +--- + +# --description-- + +For the last portion of the workshop, you will review how to get the minimum and maximum values of a set of numbers. + +Start by adding a `console.log()` that logs the message `"The Math.max() and Math.min() methods are used to get the maximum and minimum number from a range."` to the console. + +# --hints-- + +You should log the message `"The Math.max() and Math.min() methods are used to get the maximum and minimum number from a range."` to the console. + +```js +assert.match(code, /console\.log\((['"`])The\s+Math\.max\(\)\s+and\s+Math\.min\(\)\s+methods\s+are\s+used\s+to\s+get\s+the\s+maximum\s+and\s+minimum\s+number\s+from\s+a\s+range\.\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 between 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("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); +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece147323c91f654bf8dd9.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece147323c91f654bf8dd9.md new file mode 100644 index 00000000000..83aa40bb7d2 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece147323c91f654bf8dd9.md @@ -0,0 +1,118 @@ +--- +id: 66ece147323c91f654bf8dd9 +title: Step 13 +challengeType: 1 +dashedName: step-13 +--- + +# --description-- + +In the previous lecture videos, you learned how to get the maximum and minimum values from a range of numbers like this: + +```js +Math.max(1, 2, 3, 4, 5); // 5 +Math.min(1, 2, 3, 4, 5); // 1 +``` + +Create a variable called `maxNum` and assign it the result of finding the maximum number between the numbers `3, 125, 55, 24`. Then, log the value of `maxNum` to the console. + +Below that, create a variable called `minNum` and assign it the result of finding the minimum number between the numbers `6, 90, 14, 90, 2`. Then, log the value of `minNum` to the console. + +# --hints-- + +You should have a variable called `maxNum`. + +```js +assert.isNotNull(maxNum); +``` + +Your `maxNum` variable should be assigned the result of the finding the maximum number between the numbers `3, 125, 55, 24`. + +```js +assert.equal(maxNum, 125); +``` + +You should not hardcode the value of `125` to the `maxNum` variable. Make sure to use the `Math.max()` method instead. + +```js +assert.notMatch(code, /maxNum\s*=\s*125/); +``` + +You should log the value of `maxNum` to the console. + +```js +assert.match(code, /console\.log\(\s*maxNum\s*\)/); +``` + +You should have a variable called `minNum`. + +```js +assert.isNotNull(minNum); +``` + +Your `minNum` variable should be assigned the result of the finding the minimum number between the numbers `6, 90, 14, 90, 2`. + +```js +assert.equal(minNum, 2); +``` + +You should not hardcode the value of `2` to the `minNum` variable. Make sure to use the `Math.min()` method instead. + +```js +assert.notMatch(code, /minNum\s*=\s*2/); +``` + +You should log the value of `minNum` to the console. + +```js +assert.match(code, /console\.log\(\s*minNum\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 between 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("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."); + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece75c0b840df77c7e20f0.md b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece75c0b840df77c7e20f0.md new file mode 100644 index 00000000000..cd129af78e1 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-mathbot/66ece75c0b840df77c7e20f0.md @@ -0,0 +1,127 @@ +--- +id: 66ece75c0b840df77c7e20f0 +title: Step 14 +challengeType: 1 +dashedName: step-14 +--- + +# --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 between 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("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 between 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( + "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!"); +```