I am attempting to generate an array of strings with a length greater than zero.
let sampleArray2:string[] = ["hello","world","angular","typescript"];
let subArray:string[] = sampleArray2
.map(() => sampleArray2
.find(val => val.length > 5)
);
console.log(subArray);
Instead of the anticipated result of
[ 'angular', 'angular', 'angular', 'angular' ]
,
I am hoping for it to display [ 'angular', 'typescript' ]
I am specifically seeking a solution that utilizes both map and find together to achieve this. How can I correct this?
Note: While using filter
would be a straightforward fix, I am exploring the possibility of combining map and find for the desired outcome.