Answer
See the detailed answer below.
Work Step by Step
$$\color{blue}{\bf [a]}$$
The rod lies along the $y$-axis and its center is on the origin.
We are told that its linear charge density is not uniform and is given by
$$\lambda=a|y|$$
where $a$ is constant.
So,
$$\lambda=
\begin{cases}
ay & \text{ if } \;\;0\leq y\lt\dfrac{L}{2} \\
-ay& \text{ if }\;\;\dfrac{-L}{2}\lt y\lt 0
\end{cases}$$
Now we can draw the $\lambda$ versus $y$ graph over the length of the rod, as we see in the first figure below.
$$\color{blue}{\bf [b]}$$
The author told us that this kind of problem needs integration. So we chose too small segments $dy$ on the rod at the same distance from the origin. Each one has a small charge of $dq$.
And we know that the linear charge density of the rod is given by
$$\lambda=a|y|=\dfrac{dq}{dy}$$
Thus,
$$dq=a|y|dy\tag 1$$
integrating from $y_i=-L/2$ to $y_f=L/2$
$$\int_0^Qdq=\int_{-L/2}^{L/2}a|y|dy$$
where $\int_{-L/2}^{L/2}|y|dy=2\int_0^{L/2} ydy$
$$Q=2a\int_{0}^{L/2}ydy=ay^2\bigg|_0^{L/2}$$
$$\boxed{Q=\dfrac{aL^2}{4}}$$
And hence,
$$\boxed{a=\dfrac{4Q}{L^2}}$$
$$\color{blue}{\bf [c]}$$
The two small segments above of charge $dq$ exert a small electric field at $x$ distance $dE$.
And since both $dE$s are making the same angle with horizontal but one below the $x$-axis and one above it, their $y$-compnents cancel each other.
Hence, the net electric field from both is toward the right.
where the net electric field from both $dq$ is given by
$$dE_{net}=2\left[\dfrac{1}{4\pi \epsilon_0}\dfrac{dq}{r^2}\cos\theta\right]\;\hat i$$
where $\cos\theta=x/r$
$$dE_{net}=2\left[\dfrac{1}{4\pi \epsilon_0}\dfrac{ xdq}{r^3} \right]\;\hat i$$
Plug $dq$ from (1),
$$dE_{net}=2\left[\dfrac{1}{4\pi \epsilon_0}\dfrac{ ax y dy }{r^3} \right]\;\hat i$$
where $r=\sqrt{(x^2+y^2)}$
$$dE_{net}= \dfrac{2ax }{4\pi \epsilon_0}\dfrac{ y dy }{(x^2+y^2)^{3/2}} \;\hat i$$
Integrating from $y=0$ to $y=L/2$,
$$\int_0^E dE_{net}=\int_0^{L/2} \dfrac{2ax }{4\pi \epsilon_0}\dfrac{ y dy }{(x^2+y^2)^{3/2}} \;\hat i$$
$$E= \left(\dfrac{2ax }{4\pi \epsilon_0} \;\hat i\right)\int_0^{L/2}\dfrac{ y dy }{(x^2+y^2)^{3/2}}\tag 2 $$
We can solve this $\int_0^{L/2}\dfrac{ y dy }{(x^2+y^2)^{3/2}}\tag a $ by assuming that
$$x^2+y^2=u\tag b$$
so $du=2ydy$, and hence,
$$y=\dfrac{du}{2dy}\tag c$$
Plug (b) and (c) into (a),
$$\int_0^{L/2}\dfrac{ y dy }{(x^2+y^2)^{3/2}}=\int\dfrac{\dfrac{du}{2dy} dy}{u^{3/2}}=\int \frac{1}{2}u^{-3/2}du=-u^{-1/2}=\dfrac{-1}{\sqrt{u}}$$
Back to the real terms,
$$\int_0^{L/2}\dfrac{ y dy }{(x^2+y^2)^{3/2}}=\dfrac{-1}{\sqrt{x^2+y^2}}\bigg|_0^{L/2}=\dfrac{-1}{\sqrt{x^2+(L^2/4)}}-\dfrac{-1}{\sqrt{x^2+0}}\\
=\dfrac{-1}{\sqrt{x^2+(L^2/4)}}+\dfrac{ 1}{x}$$
Plug into (2),
$$E= \left(\dfrac{2ax }{4\pi \epsilon_0} \;\hat i\right)\left[\dfrac{ 1}{x}- \dfrac{1}{\sqrt{x^2+(L^2/4)}}\right] $$
Plug $a$ from the boxed formula in part [a] above,
$$E= \dfrac{8Qx }{(4\pi \epsilon_0)L^2} \left[\dfrac{ 1}{x}- \dfrac{1}{\sqrt{x^2+(L^2/4)}}\right] \;\hat i $$
$$\boxed{E= \dfrac{8Q }{(4\pi \epsilon_0)L^2} \left[1- \dfrac{x}{\sqrt{x^2+(L^2/4)}}\right] \;\hat i }$$