function fiveChar(inputArray) {
var output = input.join();
return output;
}
console.log(fiveChar(['lion', 'gorilla', 'elk', 'kangaroo']));
How can I make this only return lion
and elk
, given they're under five characters?
Thanks!
function fiveChar(inputArray) {
var output = input.join();
return output;
}
console.log(fiveChar(['lion', 'gorilla', 'elk', 'kangaroo']));
How can I make this only return lion
and elk
, given they're under five characters?
Thanks!
You can use .filter()
to filter the array down into a new array with strings that have a .length
less than 6 characters.
function fiveChar(inputArray) {
return inputArray.filter(function(in) {
return in.length < 6;
});
}