I am trying to filter strings from an array. For example I have five strings
- adcfd
- adjnrj
- amlkc
- nfldkm
- cslkls
If I want to create a new array that contains the filtered array, e.g. it starts with 'ad' it will create an array with two elements [adcfd, adjnrj]
or if it starts with 'a' we will get an array with three elements [adcfd, adjnrj, amlkc]
The only thing in my mind is to compare each character from all the strings until we get two 'trues' then we can end the loop.
If there is any function that I don't know, can I give any suggestions?