diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index f146ecd91fe..451e9637085 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -4751,6 +4751,12 @@ "title": "Certified Full Stack Developer Exam", "intro": ["Pass this exam to become a Certified Full Stack Developer."] }, + "lab-golf-score-translator": { + "title": "Build a Golf Score Translator", + "intro": [ + "For this lab, you will use array methods to translate golf scores into their nickname." + ] + }, "lab-record-collection": { "title": "Build a Record Collection", "intro": [ diff --git a/client/src/pages/learn/full-stack-developer/lab-golf-score-translator/index.md b/client/src/pages/learn/full-stack-developer/lab-golf-score-translator/index.md new file mode 100644 index 00000000000..4b8c71d74bf --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-golf-score-translator/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Build a Golf Score Translator +block: lab-golf-score-translator +superBlock: full-stack-developer +--- + +## Introduction to the Build a Golf Score Translator + +For this lab, you will use array methods to translate golf pars and strokes into their nicknames. diff --git a/curriculum/challenges/_meta/lab-golf-score-translator/meta.json b/curriculum/challenges/_meta/lab-golf-score-translator/meta.json new file mode 100644 index 00000000000..68c8b5b75e2 --- /dev/null +++ b/curriculum/challenges/_meta/lab-golf-score-translator/meta.json @@ -0,0 +1,11 @@ +{ + "name": "Build a Golf Score Translator", + "isUpcomingChange": false, + "dashedName": "lab-golf-score-translator", + "superBlock": "full-stack-developer", + "helpCategory": "JavaScript", + "challengeOrder": [{ "id": "689f7996426c1534fa5bea66", "title": "Build a Golf Score Translator" }], + "blockType": "lab", + "blockLayout": "link", + "usesMultifileEditor": true +} diff --git a/curriculum/challenges/english/25-front-end-development/lab-golf-score-translator/689f7996426c1534fa5bea66.md b/curriculum/challenges/english/25-front-end-development/lab-golf-score-translator/689f7996426c1534fa5bea66.md new file mode 100644 index 00000000000..2810b199111 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/lab-golf-score-translator/689f7996426c1534fa5bea66.md @@ -0,0 +1,156 @@ +--- +id: 689f7996426c1534fa5bea66 +title: Build a Golf Score Translator +challengeType: 26 +dashedName: build-a-golf-score-translator +--- + +# --description-- + +In the game of Golf, each hole has a `par`, meaning the average number of `strokes` a golfer is expected to make in order to sink the ball in the hole to complete the play. Depending on how far above or below `par` your `strokes` are, there is a different nickname. + +In this lab, you will write a function that converts the `par` and `strokes` to their nickname. + +**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. You should create a function named `golfScore`. +1. `golfScore` should take two numeric arguments, which are the par for the course and the amount of strokes made +1. `golfScore` should return a string. +1. `golfScore` should `"Hole-in-one!"` if `strokes` is `1`. +1. `golfScore` should return `"Eagle"` if `strokes` is less than or equal to `par` minus `2`. +1. `golfScore` should return `"Birdie"` if `strokes` is equal to `par` minus `1`. +1. `golfScore` should return `"Par"` if `strokes` is equal to `par` +1. `golfScore` should return `"Bogey"` if `strokes` is equal to `par` plus `1`. +1. `golfScore` should return `"Double Bogey"` if `strokes` is equal to `par` plus `2`. +1. `golfScore` should return `"Go Home!"` if `strokes` is greater than `par` plus `3`. + +# --hints-- + +You should create a function named `golfScore`. + +```js +assert.isFunction(golfScore); +``` + +`golfScore` should take two parameters. + +```js +assert.lengthOf(golfScore, 2); +``` + +`golfScore` should return a string + +```js +assert.isString(golfScore(4,1)); +``` + +`golfScore(4, 1)` should return the string `Hole-in-one!` + +```js +assert.strictEqual(golfScore(4,1), 'Hole-in-one!'); +``` + +`golfScore(4, 2)` should return the string `Eagle` + +```js +assert.strictEqual(golfScore(4,2), 'Eagle'); +``` + +`golfScore(5, 2)` should return the string `Eagle` + +```js +assert.strictEqual(golfScore(5,2), 'Eagle'); +``` + +`golfScore(4, 3)` should return the string `Birdie` + +```js +assert.strictEqual(golfScore(4,3), 'Birdie'); +``` + +`golfScore(4, 4)` should return the string `Par` + +```js +assert.strictEqual(golfScore(4,4), 'Par'); +``` + +`golfScore(1, 1)` should return the string `Hole-in-one!` + +```js +assert.strictEqual(golfScore(1,1), 'Hole-in-one!'); +``` + +`golfScore(5, 5)` should return the string `Par` + +```js +assert.strictEqual(golfScore(5,5), 'Par'); +``` + +`golfScore(4, 5)` should return the string `Bogey` + +```js +assert.strictEqual(golfScore(4,5), 'Bogey'); +``` + +`golfScore(4, 6)` should return the string `Double Bogey` + +```js +assert.strictEqual(golfScore(4,6), 'Double Bogey'); +``` + +`golfScore(4, 7)` should return the string `Go Home!` + +```js +assert.strictEqual(golfScore(4,7), 'Go Home!'); +``` + +`golfScore(5, 9)` should return the string `Go Home!` + +```js +assert.strictEqual(golfScore(5,9), 'Go Home!'); +``` + +# --seed-- + +## --seed-contents-- + +```js +const names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"]; + +``` + + +# --solutions-- + +```js +function golfScore(par, strokes) { + if (strokes === 1) { + return "Hole-in-one!"; + } + + if (strokes <= par - 2) { + return "Eagle"; + } + + if (strokes === par - 1) { + return "Birdie"; + } + + if (strokes === par) { + return "Par"; + } + + if (strokes === par + 1) { + return "Bogey"; + } + + if(strokes === par + 2) { + return "Double Bogey"; + } + + return "Go Home!"; +} +``` + diff --git a/curriculum/superblock-structure/full-stack.json b/curriculum/superblock-structure/full-stack.json index 8fb82d81094..f560d495df8 100644 --- a/curriculum/superblock-structure/full-stack.json +++ b/curriculum/superblock-structure/full-stack.json @@ -689,6 +689,9 @@ { "dashedName": "lab-lunch-picker-program" }, + { + "dashedName": "lab-golf-score-translator" + }, { "dashedName": "lab-reverse-a-string" },