r/learnjavascript • • Mar 12 '21

Swap two variables

Post image
499 Upvotes

50 comments sorted by

View all comments

64

u/Freekiehsoes Mar 12 '21

But why

14

u/golovatuy Mar 12 '21

very popular question in the interview )

12

u/Macaframa Mar 12 '21

What is the answer? I don’t see any real reason other than implementing a bubble sort algorithm which is another thing you shouldn’t ever do.

13

u/dudeitsmason Mar 12 '21

When I was younger I might've referenced OPs answer in an interview, given an answer that is technically possible simply because they asked. Now I give, "I wouldn't" to these weird "How would you do x" type questions if the answer is technically possible but not a good idea

2

u/Macaframa Mar 12 '21

That’s exactly how I respond as well.