I got some problem with this function Search program names that can be limited in the number of outputs that implement callback functions. hope you can help me figure out
function filteritem(str,num,callback){
let result = name.filter( name => name.indexOf(str) !== -1 )
result.forEach(element => element.length == num)
callback(result);
}
function showFilter(wrd){
console.log(wrd);
}
console.log(filteritem("a",3,showFilter))
My output is :
[
'Abigail', 'Alexandra',
'Amanda', 'Angela',
'Bella', 'Carol',
'Caroline', 'Carolyn',
'Diana', 'Elizabeth',
'Ella', 'Faith',
'Olivia'
]
undefined
The output I want is :
["Abigail", "Alexandra", "Alison"];