#Need help refactoring these lines of code

12 messages · Page 1 of 1 (latest)

cerulean brook
#

As the title says. t's hilarious, but I'm literally stuck with this on a video congratulating the end of module 3. Thanks in advance!

frosty raft
#

Can you send a link to your Scrim?

#

BTW - not sure it's worth trying to refactor 3 lines of code that's going to take at least 1 line to discriminate saving you a whopping 1-2 lines of code...

cerulean brook
frosty raft
#

Are you comfortable with arrow functions?

cerulean brook
frosty raft
#

Ok... you could do it instead with a parameter that determines the operation to use...

cerulean brook
frosty raft
#

Yeah, that's kinda what I was getting at with my last comment - you pass the action that you want to perform however this is not really what I'd call a "refactor" in the sense that it in face has overly complicated the code and there's very little reuse in there... maybe you need something similar but break it into two functions "addEmoji" and "remove Emoji" then you can refactor the common code...

cerulean brook
#

Okay, got it, thank you so much for help