Array Filter 💻 Exercise Walkthrough with JavaScript ✔️

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

A even more simplified version:

function validUserNames(userNames){
return userNames.filter(name => name.length < 10);
}

fergusonshuai
Автор

This guy is such a wonderful teacher. I believe he could make the hard concepts easier to learn. Keep up the thoughtful explanations and examples.

webdevchris
Автор

Thank you for this. The jump in complexity here is a lot to take in and I think a LOT of people had issues with this lesson because of it, even though we had previously reviewed functions in functions, it was kind of left in the dust and we didn't use it again after that. I guess, besides now.

SetariM
Автор

can also be written all in one line:
const validUserNames = userNames => userNames.filter(users => users.length < 10);

mest
Автор

const validUserNames = usernames => (usernames.filter(user => user.length < 10));
my answer...

suryasaini
Автор

const validUserNames = arr => arr.filter(name => name.length < 10); 😎

hoangdesu
Автор

I actually ended up getting it on my own, although I did use MDN. Here is my solution:
function validUserNames(usernames) {
const filtered = usernames.filter(username => username.length < 10);
return filtered;
}

DanClapp
Автор

//this is a short version with arrow functions and implicit returns
const validUserNames = usernames => usernames.filter(n => n.length < 10)

bkhero
Автор

I came here from Colt Steele, thanks

kylesera
Автор

Ah ok thx I was close, but I didn't make it a variable and return the variable. I also can follow it better in the long form. Colt did say declaring a function as variable to reuse in another video, but I totally didn't make the connection.

tonybowen
Автор

let validUserNames = strings => {return strings.filter(string => string.length < 10)}

VagabondOfNote
Автор

Very helpful this was confusing. I forgot to add a function in the filter parameters to get it to work.

steven
Автор

My .filter argument wasn’t a function. Thanks for the help.

LukeCodes-JobbyorBust
Автор

solved it with a general idea of how and some research. Stumbled into the solution but this video helped explain what I was attempting to do

Jaygoesin
Автор

omg I was so close, should have kept trying... curse that extra return on the second line @.@

AugustLoves
Автор

I even thought that I had to make an array of user names to pull Thanks man.

zenguitarankh
Автор

Heyy, I love this video. You broke down the complexity of the Excercise. Please could you make videos on other tough exercises.

edwardalabi
Автор

the million different syntaxis of writing these callback functions really make it only harder...

Woef
Автор

I was so close to the short version! It was the two 'return' keywords that threw me off because they both run :) . I get it now. Very cool!!!

cleansermacaroni
Автор

I kept trying to overcomplicate it and add .map() to this one until I realized I was only supposed to use .filter()....it shouldn't have taken me a whole hour! 😅
Simplest solution applying arrow functions is: "const validUserNames = usernames => usernames.filter(username =>username.length < 10)"

non-influential