I have an array of strings ["samantha", "mike", "john", "sammy", "carla"] and an input value of s.
const input = "s"; let names = ["samantha", "mike", "john", "sammy", "carla"]; let filteredNames = names.filter(name => name.startsWith(input)); This gives me "samantha" and "sammy" as a result.
How can I extract the string that all elements of filteredNames start with, in this case? So basically: How can I find out that sam is the matching string for this array?