#Need help refactoring these lines of code
12 messages · Page 1 of 1 (latest)
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...
Perhaps you're right, but refactoring this code was set as an additional task, so I can't go to module 4 with peace of mind until I figure it out 😄
Ok... I did the "add" part - maybe you can figure out the remove?
https://scrimba.com/scrim/co5914ba3bee1a6e5b859e5a7
Are you comfortable with arrow functions?
Oh thanks, I'm not familiar with such functions yet, but I'll read about how it works
Ok... you could do it instead with a parameter that determines the operation to use...
I also found this way of refactoring, not sure if it looks like something valid or not https://scrimba.com/scrim/co3804c9aae78d7aef9d036e4
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...
Okay, got it, thank you so much for help