From 3ac4a79ef60c81dcab2697376916159af6df5df1 Mon Sep 17 00:00:00 2001 From: jolson615 Date: Tue, 13 Aug 2019 13:00:39 -0400 Subject: [PATCH] updates solution --- src/App.js | 2 +- src/components/checkboxes.js | 52 +++++++++++++++++------------------ src/components/numberDials.js | 8 +++--- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/App.js b/src/App.js index 43f157e..5d977a3 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React from 'react'; import './App.css'; import NumberDials from './components/numberDials' -import SlidingPuzzle from './components/slidingPuzzle' +// import SlidingPuzzle from './components/slidingPuzzle' import Navbar from './components/navbar' import Checkboxes from './components/checkboxes' import ColorCaptcha from './components/colorCaptcha' diff --git a/src/components/checkboxes.js b/src/components/checkboxes.js index 9f51820..5dc739b 100644 --- a/src/components/checkboxes.js +++ b/src/components/checkboxes.js @@ -3,7 +3,7 @@ import './checkboxes.css' const Checkboxes = () => { const component = new React.Component() - const answerKey = [ + component.answerKey = [ true, false, true, true, false, false, false, true, false, false, true, false, @@ -14,10 +14,10 @@ const Checkboxes = () => { checks: [true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true] } - const handleClickForBox = (i) => { + component.handleClickForBox = (i) => { // Start by accessing the current array of checks. const arrayOfChecks = component.state.checks - if (arrayOfChecks[i] == true) { + if (arrayOfChecks[i] === true) { arrayOfChecks[i] = false } else { arrayOfChecks[i] = true @@ -25,19 +25,19 @@ const Checkboxes = () => { component.setState({checks: arrayOfChecks}) } - const countTrue = (arrayOfChecks) => { + component.countTrue = (arrayOfChecks) => { let total = 0 arrayOfChecks.forEach(entry => { - if (entry == true) { + if (entry === true) { total += 1 } }) return total } - const winning = () => { + component.winning = () => { for (let i = 0; i < 16; i++) { - if (component.state.checks[i] != answerKey[i]) { + if (component.state.checks[i] !== component.answerKey[i]) { return false } } @@ -48,29 +48,29 @@ const Checkboxes = () => { // To increase readability we are unpacking the checks array here const arrayOfChecks = component.state.checks return ( -
+

Check only the correct boxes

Target Sum: 7

-

Your Sum: {countTrue(arrayOfChecks)}

+

Your Sum: {component.countTrue(arrayOfChecks)}

-
handleClickForBox(0)}/> -
handleClickForBox(1)}/> -
handleClickForBox(2)}/> -
handleClickForBox(3)}/> -
handleClickForBox(4)}/> -
handleClickForBox(5)}/> -
handleClickForBox(6)}/> -
handleClickForBox(7)}/> -
handleClickForBox(8)}/> -
handleClickForBox(9)}/> -
handleClickForBox(10)}/> -
handleClickForBox(11)}/> -
handleClickForBox(12)}/> -
handleClickForBox(13)}/> -
handleClickForBox(14)}/> -
handleClickForBox(15)}/> +
component.handleClickForBox(0)}/> +
component.handleClickForBox(1)}/> +
component.handleClickForBox(2)}/> +
component.handleClickForBox(3)}/> +
component.handleClickForBox(4)}/> +
component.handleClickForBox(5)}/> +
component.handleClickForBox(6)}/> +
component.handleClickForBox(7)}/> +
component.handleClickForBox(8)}/> +
component.handleClickForBox(9)}/> +
component.handleClickForBox(10)}/> +
component.handleClickForBox(11)}/> +
component.handleClickForBox(12)}/> +
component.handleClickForBox(13)}/> +
component.handleClickForBox(14)}/> +
component.handleClickForBox(15)}/>
) @@ -78,4 +78,4 @@ const Checkboxes = () => { return component } -export default Checkboxes +export default Checkboxes; diff --git a/src/components/numberDials.js b/src/components/numberDials.js index 12789b1..89b2457 100644 --- a/src/components/numberDials.js +++ b/src/components/numberDials.js @@ -38,22 +38,22 @@ const NumberDials = () => {
{component.state.numberA}
- +
{component.state.numberB}
- +
{component.state.numberC}
- +
{component.state.numberD}
- +