Results 1 to 2 of 2
Thread: Making Loop to Search an array
Mar 2, 2012, 19:34 #1
- Join Date
- Mar 2012
- Bridgeport, Connecticut, United States
- 0 Post(s)
- 0 Thread(s)
Making Loop to Search an array
here is my assignment.
Below you will find an array of names to use in this problem. input should contain a number, which we will call n. input should contain a number, which we will call i. input should contain a letter, which we will call l. You are to create a program which looks at all the names from 0 through n; if the letter l, upper or lower case, appears in the name at position i, then the name should be printed along with a message like: xxxxxx contains the letter l at position i where xxxxxx is the name, l is the letter from input and i is the position from input. If the input n is greater than the number of names, an error message should be printed and no names should be examined. If a particular name does not have i characters, it should not cause an error message, but that name should be ignored. That is, if i is 6, Iowa should be ignored.
I figure i have to create a loop to search through the array of:
var names = new Array(); names = "Alabama"; names = "ALASKA"; names = "Arizona"; names = "Arkansas"; names = "California"; names = "Colorado"; names = "Connecticut"; names = "Delaware"; names = "Florida"; names = "Georgia"; names = "Hawaii";
But i am not sure how to do this. Im researching loops now. Any links would be helpful. Im obviously a nub.
Hate is not appreciated, just some love for the newbie. ;-)
Mar 3, 2012, 04:08 #2
- Join Date
- Jan 2007
- Christchurch, New Zealand
- 59 Post(s)
- 3 Thread(s)