You are an interviewer for a JavaScript position. Only 2 people are left. You ask them to write a function taking a Number and returning true if that Number is odd.
First candidate writes: function isOdd(n) { return !!(n&1); }
Second candidate writes: function isOdd(number) { const even = number % 2 === 0; return !even; }
Which one would you hire and why? There's only 1 correct answer.
Candidate two because other people will also be working on the project
Cooper Carter
Neither of them because they didn't use well developed and scrutinized libraries from npm like isOdd and isEven :^)
Daniel Cooper
The second one sounds like someone that will accept a lower salary, so he's the guy.
Ethan Stewart
2 because it's an interview not code golf.
Brandon James
Triggered
Thomas Turner
stay woke
Robert Powell
This, if it's on npm you should never be righting it yourself/
Come to /wdg/ sometime.
Jayden Sullivan
Neither. Both pieces are difficult to understand at a glance and will produce undefined behavior.
Negating the output of a logical operation and blindly returning it is a bad idea. It makes it hard to know precisely what the function will do with a given input if you don't have intimate knowledge of how JS's & and % operators will interpret their input. In addition if your assumptions about how the language will interpret your statement are not correct you will create bugs. It's obvious what SHOULD be correct and how it SHOULD operate but what's mathematically correct is often not what a computer will do. It's up to the programmer to expect this and handle it.
Instead both candidates should be evaluating the value returned by their respective operations and returning explicit values based on them. They should also be explicitly defining the return values for edge cases, particularly because Javascript is REALLY good at doing retarded undefined shit without excepting when fed with bad or unexpected input.
If I had to pick I'd say candidate 2 but I don't like either of them. Also who the hell is giving them prompts with function names that are in camelCase()? Fire them immediately and find me someone who knows to write function names like_this();
I'd say 2 is the lesser if I was forced to pick one, but I'd move him to an unimportant project pretty quickly. The lack of clarity and missing checks is unacceptable in an environment that has a team of people working on the same project.
the minority applicant. I don't want to get fired.
Josiah Cox
Has anyone learned to program? Best way to go about it if I want a job in less than 1 year?
Hackreactor Turing freeCodeCamp
Daniel Mitchell
The female.
Christian Campbell
/thread
Austin Diaz
>You are an interviewer for a JavaScript position I spent all day debugging JS and NodeJS callback hell. I'd never be in an interview for JS. You people are a blight on software development.
Kayden Perez
Entrant 1 is clearly just after job security and will write a bunch of awful, terse, hard-to-read shit. Entrant 2's entry isn't great, but it's passable.
also, what said
Ethan Ortiz
>Righting
Jayden James
I'd fuck them in their asses instead.
Ian Rogers
>hard-to-read t. brainlet
Tyler Long
Kill youself motherfucker
Christopher Flores
Neither, why over complicate something as simple as determining if a number is odd or even. I'm not hiring someone who can write a function in the least amount of code. I'm hiring someone who is going to be an asset to the team who I would want to work in a shared code base with.