I am having a hard time figuring this out, I have two simple arrays and I want to populate one by asking a visitor to enter information, it goes something like this...
So, I have the country array with assign numerically. Then I prompt for the president/prime minister of each country and those names are assigned to the president array so I can print (example) Obama is the President of USA. I am trying to figure out how to use a for loop to go through the prompts and assign the input to the president array, then I have to 'assign'(?) the now populated president array to the country array according to the numbers. Or rather I want to populate president by using a loop (with length property of the country array) in a for loop that prompts for the name of the president/prime minister.
Any help would be very kindly appreciated. I am just pulling at straws here.
Code:
var country = new Array(5);
c_list[0] = "USA";
c_list[1] = "UK";
c_list[2] = "France";
c_list[3] = "Germany";
c_list[4] = "Spain";
var president = new Array(); // Last name only
president[0] = window.prompt("President of USA?", ""); // Obama
president[1] = window.prompt("Prime Minister of UK?", ""); // Brown
president[2] = window.prompt("President of France?", ""); // Sarkozy
president[3] = window.prompt("Prime Minister of Germany?", ""); // Merkel
president[4] = window.prompt("President of Spain?", ""); // Zapatero
So, I have the country array with assign numerically. Then I prompt for the president/prime minister of each country and those names are assigned to the president array so I can print (example) Obama is the President of USA. I am trying to figure out how to use a for loop to go through the prompts and assign the input to the president array, then I have to 'assign'(?) the now populated president array to the country array according to the numbers. Or rather I want to populate president by using a loop (with length property of the country array) in a for loop that prompts for the name of the president/prime minister.
Any help would be very kindly appreciated. I am just pulling at straws here.