Can anyone provide guidance on how to abbreviate an array of strings using the filter() method?
I am trying to use filter() with str.substring or another string method, but I'm not sure how to make it work properly.
In this code snippet, my goal is to return the first four characters of each name from the poshNames array. However, it seems like something is off.
Here's the JavaScript code:
let poshNames = ["Markol", "Andile", "Jazzmine", "Famisynth"];
let nickNames;
nickNames = poshNames.filter(function(name){
return name.str.substring(0,4);
});