I have one array of strings. I need to find all strings starting with a key.
for eg: if there is an array [\'apple\',\'ape\',\'open\',\'soap\']
when searched with
function find(key, array) {
// The variable results needs var in this case (without 'var' a global variable is created)
var results = [];
for (var i = 0; i < array.length; i++) {
if (array[i].indexOf(key) == 0) {
results.push(array[i]);
}
}
return results;
}