select elements of an array starting by a certain letter javascript

Solutions on MaxInterview for select elements of an array starting by a certain letter javascript by the best coders in the world

showing results for - "select elements of an array starting by a certain letter javascript"
Antoine
28 Oct 2017
1const countries = ['Norway', 'Sweden',  'Denmark', 'New Zealand'];
2
3const startsWithN = countries.filter((country) => country.startsWith("N"));
4
5console.log(startsWithN);
6
7// Output: [ 'Norway', 'New Zealand' ]
8