Skip to content
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

Random Number Guess adding form #262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions projects/Random Number Guess/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ <h1>Guess My Number!</h1>
</header>
<main>
<section class="left">
<input type="number" class="guess" />
<button class="btn check">Check!</button>
<form class="form" action="">
<input type="number" class="guess" />
<button type="submit" class="btn check">Check!</button>
</form>
</section>
<section class="right">
<p class="message">Start guessing...</p>
Expand Down
5 changes: 4 additions & 1 deletion projects/Random Number Guess/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const displayMessage = function (message) {
document.querySelector('.message').textContent = message;
};

document.querySelector('.check').addEventListener('click', function () {
// on clicking on enter key or chick btn
document.querySelector('form.form').addEventListener('submit', function (e) {
e.preventDefault()
const guess = Number(document.querySelector('.guess').value);
console.log(guess, typeof guess);

Expand Down Expand Up @@ -55,6 +57,7 @@ else if(guess!==secretNumber){
}
}
})

/*else if(guess>secretNumber){
if(score>1){
document.querySelector('.message').textContent = 'Too high!';
Expand Down