Hi, i would like to figure out how i can populate an array according to user input e.g say there is a name prompt that accepts a string “Smith” and also accepts any number in this case lets say “5” therefore what i need to now happen is push the string 5 times in the array end result being [“Smith” , “Smith” , “Smith” , “Smith” , “Smith”]
Pseudocode:
0. var array = []
1. var name = input(name)
2. var times = input(number)
3. loop {
- push name to array
- substract 1 from times
- if times <= 0 end loop
}
Yup, that’s it.
Thank you will defiantly give this a try!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.