The Artima Developer Community
Sponsored Link

Java Answers Forum
Arrays and loops

1 reply on 1 page. Most recent reply: Mar 11, 2008 1:34 AM by shipra kumar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Bianca G

Posts: 1
Nickname: geneva76
Registered: Feb, 2008

Arrays and loops Posted: Feb 21, 2008 8:35 AM
Reply to this message Reply
Advertisement
Hiya,

Okay I'm a total beginner in javascript but wanting to learn. I'm working on a very simple website to start myself off, but I'm totally stuck!!
I have 2 arrays and need to use either a for or while loop (no idea which, as I said, very new to this) to match them up somehow

var password = new Array (5);
password[0] = 'password';
password[1] = 'bluesky';
password[2] = 'dr45gr6';
password[3] = 'onlyme';
password[4] = 'lothlorien';


var customercodes = new Array (5);
customercodes[0] ='lt-17';
customercodes[1] = 'gw-3';
customercodes[2] = 'lg-9';
customercodes[3] = 'il-77';
customercodes[4] = 'fy-32';

These are the 2 array and I want to put in a prompt window (I can get that far!!! lol ) to give instruct user to put in a password. The password should then match up the the customercode (like password 1 is customercode 1) and display that on the screen. If a wrong password is entered, it should keep asking til a right one is entered.

Does anyone have any tips which loops to use and how I should put it??


shipra kumar

Posts: 3
Nickname: shipra31
Registered: Mar, 2008

Re: Arrays and loops Posted: Mar 11, 2008 1:34 AM
Reply to this message Reply
You should first use a for/while to match the customer ID
once u get a matching id then u should check for the corresponding password using if statement

Flat View: This topic has 1 reply on 1 page
Topic: Arrays and loops Previous Topic   Next Topic Topic: Just Started Java... need some help please!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use