The map function will run the function on each element but, will still return all elements of the original array. Currently, the nameFun has an implicit(default) return of undefined if the condition did not match.
If you return something else the output might be a little more intuitive. For example:
function nameFun(name) {
if (name.startsWith("E")) {
return name;
} // also note that you do not need a `;` here
return "no match";
}
Note, that when using filter you actually want the default undefined return from nameFun as that will ensure that the word is filtered out.