Skip to content

Lesson-2.1#1

Open
berhetsion1 wants to merge 1 commit intomainfrom
Lesson-2.1
Open

Lesson-2.1#1
berhetsion1 wants to merge 1 commit intomainfrom
Lesson-2.1

Conversation

@berhetsion1
Copy link
Owner

No description provided.

Copy link

@kaytijackson97 kaytijackson97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done converting those components into functional components! Remember that you can import useState and other hooks from react to clean up your code and to keep good indentation. Also you can clean up the extra commented out lines of code since you will no longer be needing them. Keep up the good work!

const isCorrectGuess = this.state.latestGuess === this.state.numberToGuess;

function NumberGuessingGame() {
const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can import useState from React to prevent writing React.useState everytime

const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber());
const[numberOfGuesses, setNumberOfGuesses]= React.useState(0);
const[latestGuess, setLatestGuess]= React.useState(null);
function handleGuess(guess) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation of handleGuess and handleReset should match state variables

}
// /**
// * These lines are required to make the methods/functions declared on this
// * class have the correct `this` object when they run.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove the commented out lines of code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants