/    Sign up×
Community /Pin to ProfileBookmark

Help me fix js code!

Im gonna pull my hair out!

Is there anyone out there that can change this code to do the following:

Insert a while loop that will stay there saying no until the user gets the right answer and then it will give the right answer and move on.

????????

thanks,
DD

[upl-file uuid=6002a653-f38e-46d4-9e86-4ee82a71a0d2 size=569B]math.txt[/upl-file]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@AdamBrillApr 23.2003 — Ok, try this:<HTML>
<HEAD>
<TITLE>Math Facts</TITLE>
</HEAD>
<BODY>
<H2>MATH FACTS 1..3</H2>
<SCRIPT LANGUAGE="JavaScript">
for (i=1; i<=3; i=i+1)
{
for (j=1; j<=3; j=j+1)
{
ans=i + j;
document.write(i + "+" + j + "=" + "<BR>");
keepgoing=true;
while(keepgoing){
var user_input = prompt("What is your answer?",0);
if (ans == user_input)
{
document.write("Yes, the answer is " + ans + "<BR>");
keepgoing=false;
break;
}
else
{
document.write("No...<BR>");
}
}
}
}
</SCRIPT>
</H3>
</BODY>
</HTML>
Let me know if you need more help... ?
Copy linkTweet thisAlerts:
@donald_dauthorApr 23.2003 — thanks adam!
×

Success!

Help @donald_d 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 5.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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