Monday, December 6, 2021

Filtering (startwith) of array in Javascript

 const countries = ["Norway", "sweden", "Denmark", "New Zealand"];


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


console.log(startsWithN)


//Output

["Norwing", "NewZealand"]

No comments:

Post a Comment