For loop vs filter reduce
Imagine you are in an interview and the interviewer shows you two code... one using for loop and another using filter + reduce.. The code is to find the sum of all even number from array. What will run faster? here is the code using foor loop.. using filter reduce... So now what will you answer?? So lets test it live and see which will run faster So as you can see for loop run faster than filter + reduce.. But what is exactly the reason that filter reduce running slower than for loop The reason: filter will create a array first so it will get all even number and then it will start finding sum of array... this way it works on two loop causing to run slower.. I have made whole video about this https://youtube.com/shorts/qJ6rLpSrLwY?si=qAfUZdJa6yrIA7qm

Imagine you are in an interview and the interviewer shows you two code... one using for loop and another using filter + reduce.. The code is to find the sum of all even number from array. What will run faster?
here is the code
So now what will you answer??
So lets test it live and see which will run faster
So as you can see for loop run faster than filter + reduce..
But what is exactly the reason that filter reduce running slower than for loop
The reason:
filter will create a array first so it will get all even number and then it will start finding sum of array... this way it works on two loop causing to run slower..
I have made whole video about this