Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java beginner question

Name: hank aaron 2009-03-16 22:00

while programming the game mastermind I became stuck when having to figure out how to come up with the correct integers and i will figure the sum for these after i find them
for example

secretCode = 123

input = 222

output is correct integers: 1 and sum: 2

for input = 122

output is correct integers: 2 and sum: 3

Name: Anonymous 2009-03-17 4:11

>>10
var secretCode=(Math.floor(1000+Math.random()*9000)).toString();
var userInput=prompt('Enter 4-digit number','');var sum=0;var numc=0;
for(var i in user){if(user[i]==sec[i]){numc++;sum+=parseInt(user[i])}}
alert('Correct numbers:'+numc+' Correct numbers sum:'+sum);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List