-
-
Notifications
You must be signed in to change notification settings - Fork 145
chore(curriculum): Add escape-room-workshop prototype for js-projects #1087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mtrivera
wants to merge
15
commits into
freeCodeCamp:main
Choose a base branch
from
mtrivera:escape-room-workshop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a327c0e
chore(curriculum): Add workshop-escape-room js-project prototype
mtrivera f64bad5
feat(curriculum): Add patternMatch solution
mtrivera 7f9cc8a
feat(curriculum): Add countdown solution
mtrivera 2e6ea1e
feat(curriculum): Add inputValidator solution
mtrivera e0e81b6
feat(curriculum): Return username in inputValidator
mtrivera 455a59c
feat(curriculum): Add progressState object
mtrivera b16202a
feat(curriculum): Add keypad object
mtrivera 6f9c57f
fix(curriculum): Remove prompt usage from inputValidator
mtrivera 2c6e2ef
feat(curriculum): Add openDoor object
mtrivera d308f57
feat(curriculum): Call openDoor function to escape room
mtrivera 354f934
fix: Add html file for `prompt` support
mtrivera 8d812d0
refactor: inputValidator returns a boolean value
mtrivera 00885aa
refactor: Remove `Object.values` usage and use `for..in` loop
mtrivera 676be6c
refactor: Remove deprecated progressState object
mtrivera 7bbec3f
chore: Add index.html file
mtrivera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| const progressState = { | ||
| 1: { | ||
| isSolved: false | ||
| }, | ||
| 2: { | ||
| isSolved: false | ||
| }, | ||
| 3: { | ||
| isSolved: false | ||
| }, | ||
| }; | ||
|
|
||
| const countdown = () => { | ||
| const answerToLifeMeaningUniverse = 42; | ||
| for (let i = 120; i > 0; i--) { | ||
| if (i === answerToLifeMeaningUniverse) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| const patternMatch = (text, pattern) => { | ||
| let left = 0; | ||
| let right = text.length; | ||
| const patternOffset = pattern.length; | ||
| while (left < right) { | ||
| if (text.slice(left, left + patternOffset) === pattern || | ||
| text.slice(right, right - patternOffset) === pattern) { | ||
| return true; | ||
| } | ||
| left++; | ||
| right--; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| const inputValidator = username => { | ||
| const minLength = 3; | ||
| const maxLength = 17; | ||
| const isValidInput = username => | ||
| username.length >= minLength && username.length <= maxLength; | ||
|
|
||
| do { | ||
| if (isValidInput(username)) { | ||
| console.log('Valid username entered...proceed'); | ||
| return true; | ||
| } | ||
| } while(username.trim() === ''); | ||
|
|
||
| console.log('Invalid username. It should be between 3 and 17 characters'); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| const keypad = { | ||
| 1: { | ||
| isLocked: true, | ||
| }, | ||
| 2: { | ||
| isLocked: true, | ||
| }, | ||
| 3: { | ||
| isLocked: true, | ||
| } | ||
| }; | ||
|
|
||
| const openDoor = keypad => { | ||
| if (countdown()) { | ||
| keypad[1].isLocked = false; | ||
| console.log('Clue 1 solved: keypad 1 unlocked'); | ||
| } | ||
|
|
||
| if (patternMatch('freecodecampfccFREECODECAMP', 'fcc')) { | ||
| keypad[2].isLocked = false; | ||
| console.log('Clue 2 solved: keypad 2 unlocked'); | ||
| } | ||
|
|
||
| if (inputValidator('fcc102014')) { | ||
| keypad[3].isLocked = false; | ||
| console.log('Clue 3 solved: keypad 3 unlocked'); | ||
| } | ||
|
|
||
| if (Object.values(keypad).every(lock => lock.isLocked === false)) { | ||
| console.log('Congratulations! You have solved all the puzzles and can now exit!'); | ||
| } else { | ||
| console.log('Access denied. One or more of the locks are still locked. Please check the progressState'); | ||
| } | ||
| } | ||
|
|
||
| openDoor(keypad); | ||
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.