Ultimately we're going to create a puzzle app that represents a security system. In order to get past the system, a user will need to enter the correct numerical code, check the correct pattern of checkboxes in a grid, and finally match a color EXACTLY to the background.
These components are half-built, but not fully-built. You're going to finish building as many of them as you can.
- Clone this repository using
git clone
cd
into the project foldernpm install
npm start
The styling is mostly built out, so you probably won't need to work much on the CSS, but the components are still pretty rough. Each one has a list of features you'll want to build out.
- Make the component's state's
numberA
property display where it currently says##A
. - The increase button works, but the decrease button doesn't. Build the decrease button's
onClick
function. - Right now there's only a
numberPlate
div for thenumberA
value. Build out sibling elements that are also number plates for the other three numbers. - Have "Your Sum"
<h3>
element display the sum of your current four digits.
- Fix the number plates so that they can only ever show a single, non-negative digit, 0-9.
- Find a way to randomize the code when a user first loads the page. Make the hint accurate.
- Come up with a better hint mechanism. Right now there are still hundreds of combos that would total to any given sum. It's more like a password system than a puzzle, but a better hint (or set of hints) could make it more fun.
- BEFORE fixing this component, make sure you understand how the checkboxing works. The CSS is written so that if a div has both "checkbox" and "true" in it's class list, it will be styled with a check. Otherwise, it will be rendered without one.
- The last two checkboxes have incomplete
className
attributes. Update them with the JSX necessary for them to reflect the component's state. - FIRST code out the
handleClickForBox()
function. If the clicked box is currently listed as false, change it to true. If it's currently true, change it to false. Remember, you'll need to use thecomponent.setState()
method once you've built out the logic. - Update the last two checkboxes to have and
onClick
attribute, like the first two do. - Code out the
countTrue
function to iterate over thearrayOfChecks
and count up the number oftrue
values. Return that number instead of the placeholder "##" that's there now. - Code out the
winning()
function to check and see ifcomponent.state.checks
array perfectly matches theanswerKey
array.
- Add 12 more checkboxes, for a total of 16, and update the answer key and target sums to match.
- Right now the hint is hard coded. Generate the number dynamically, by examining the answer key.
- The hint is pretty opaque and not very helpful. Come up with a better system.
- Generate a random pattern.
- Build out the
recolor
function to use acomponent.setState()
method to make the state's red, green, and blue values accurate. - Fill in the "Target Total" section with some JSX that will display the sum of the colors currently stored in the
component.state
object. - Add in the missing color
input
ranges for green and blue. - Build out the
winning
function to figure out whetheryourColor
perfectly matches theanswerColor
.
- Right now, this puzzle is almost impossible. Make this third part more manageable by either making the
winning
function more flexible, or by making the clue a little more interesting.
This last part was built, but never finished, and it isn't included in the App.js
file yet. The actual sliding mechanic is already built out, but the answer key and some other features (including the winning()
function to see if the puzzle is finished correctly) still need to be built out.