a H1 could be used multiple times, there fore it could be line 3, 9, 18 etc etc. So to check and set it only on first iteration, is from my perspective not correct
Also in the provided solution the <br /> is missing and would there placed a empty <h1> on first iteration and for all other <p>
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
The solution was just an example of how you can remove the Boolean argument for better code overall. It's just a fictional example.
Depending on what you need, you could make changes. For example, you can add a function for the <br> just like toHtmlHeading, or you could have a function such as toHtmlElement(text, tag) instead of individual functions for each element, or you could have a completely different parent.
Edit: Replaced my answer to also answer the added second part.
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
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
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?
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
a H1 could be used multiple times, there fore it could be line 3, 9, 18 etc etc. So to check and set it only on first iteration, is from my perspective not correct
Also in the provided solution the
<br />
is missing and would there placed a empty<h1>
on first iteration and for all other<p>
The solution was just an example of how you can remove the Boolean argument for better code overall. It's just a fictional example.
Depending on what you need, you could make changes. For example, you can add a function for the
<br>
just liketoHtmlHeading
, or you could have a function such astoHtmlElement(text, tag)
instead of individual functions for each element, or you could have a completely different parent.Edit: Replaced my answer to also answer the added second part.
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
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?
No i'm not mentioning you, it meant to me because of the question. There I totally can understand your approach
I see, sorry for asking and for misunderstanding.
Good points :)
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.