/    Sign up×
Community /Pin to ProfileBookmark

JavaScript – Check how much numbers are right

Hello

I want to check with a prompt if a number is right.

Example: Number = 123456

if number == 123456 print out: the numbers are right

But, if only 3 numbers are right print out: Only some numbers are right

Else: Nothing right.

Possible code:

[CODE]var check = prompt (“What Number?”);

if (check == 123456) {
alert(“You won!”);
}
else if (check >= 3) {
alert(“Only 3 numbers are right”)
}
else {
alert(“You won nothing”)
}[/CODE]

I realise I should put 123456 somewhere special so the if/else knows what’s right.

Anyway, how should this work?

(And is there a way to change the prompt by a html input)

Thanks for reading,

Niely

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Nielyboyken spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...