Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

select elements of an array starting by a certain letter javascript

const countries = ['Norway', 'Sweden',  'Denmark', 'New Zealand'];

const startsWithN = countries.filter((country) => country.startsWith("N"));

console.log(startsWithN);

// Output: [ 'Norway', 'New Zealand' ]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #select #elements #array #starting #letter #javascript
ADD COMMENT
Topic
Name
6+1 =