I want to get all words with <=3
letters from an array.
Is iterating the array and checking every entry an efficient approach?
arr = ["cat", "apple", "window", "dog"];
for(i=0; i<arr.length; i++){
if(arr[i].match(/^[a-z]{3}$/)){
console.log(arr[i])
}
}
//returns: "cat" and "dog"
Or is there already a built-in function that does the job for me, so I don't have to explicitly define a for-loop and and if-statement.