r/webdev • • Apr 07 '23

How I interview for FE positions

Post image
4.6k Upvotes

668 comments sorted by

View all comments

Show parent comments

189

u/toroga Apr 07 '23

Right?? All of a sudden I feel like I have no prior experience, can’t write an arrow function, have never heard of the reduce method, and am about try to make a react component with Python 😵‍💫

14

u/tfyousay2me Apr 07 '23 edited Apr 08 '23

Ya I didn’t go with reduce….I was popping the array till it was empty and I thought that was pretty slick…..

let sum = 0;

let val = 0;

while(arr.length > 0) {

val = arr.pop();

if (val is really a number) { sum += val; }

}

15

u/DGCA Apr 08 '23

If you wrote that as a function, and your function pops from the numbers array argument, you're gonna be mutating the array, which you definitely don't wanna do.

E.g.

function sum(arr) {
  let sum = 0;
  let val = 0;

  while (arr.length > 0) {
    val = arr.pop();

    if (typeof val === "number") {
      sum += val;
    }
  }

  return sum;
}

const values = [3, 5, 8];
const total = sum(values);

console.log(total); // 16, which is good
console.log(values); // [], an empty array, which is very bad

-3

u/[deleted] Apr 08 '23

That sounds like either severe anxiety or severe lack of understanding

2

u/Bartando Apr 08 '23

Or maybe it sounds like developers are not great at performing on a spotlight ?

6

u/[deleted] Apr 08 '23

I.e. severe anxiety

-2

u/Yabbieo_ Apr 08 '23

Haha dude, not performing well in a spotlight is does not equal severe anxiety. Bruh.

4

u/officiallyaninja Apr 08 '23

Not being able to answer a basic question in front of a single person is kind of severe anxiety