DEV Community

Discussion on: How would you refactor this JS function?

 
rkallan profile image
RRKallan

so based on the original provided code there is no iteration.
And on that function variable name is isFirstLine as boolean. And then just be an ashole, but isFirstLine could refer to new section

Thread Thread
 
sargalias profile image
Spyros Argalias

I know there's no iteration in the original example. In my answer I'm making a guess at what a caller of lineChecker might intend to do. It's not shown in the opening post. I'm just creating it myself. It's fictional, so it won't always apply.

Sure, isFirstLine could refer to whatever you want. Anyone can name anything what they want. If, in your application, that could refer to a new section, then my example solution wouldn't apply.

Sorry, I didn't quite catch that but did you mean to call me an "asshole" there, or am I misunderstanding?

Thread Thread
 
rkallan profile image
RRKallan

Sorry, I didn't quite catch that but did you mean to call me an "asshole" there, or am I misunderstanding?

No i'm not mentioning you, it meant to me because of the question. There I totally can understand your approach

Thread Thread
 
sargalias profile image
Spyros Argalias

I see, sorry for asking and for misunderstanding.

Good points :)

Thread Thread
 
rkallan profile image
RRKallan

No sorry please. Always better to ask and to clarify.
Also good to see and hear different approaches.

Which also is good that you can defend and clarify your solution.