You are an interviewer for a JavaScript position. Only 2 people are left...

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.

Attached: bad-job-interview.jpg (1200x799, 140K)

First one because bitops are sexier

Candidate two because other people will also be working on the project

Neither of them because they didn't use well developed and scrutinized libraries from npm like isOdd and isEven :^)

The second one sounds like someone that will accept a lower salary, so he's the guy.

2 because it's an interview not code golf.

Triggered

stay woke

This, if it's on npm you should never be righting it yourself/

Come to /wdg/ sometime.

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();

The one that writed unit tests

Attached: 1528966888186.jpg (500x341, 58K)

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.

What would you do then?

Attached: 1539963213442.jpg (1280x1483, 406K)

This.

the minority applicant. I don't want to get fired.

Has anyone learned to program? Best way to go about it if I want a job in less than 1 year?

Hackreactor
Turing
freeCodeCamp

The female.

/thread

>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.

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

>Righting

I'd fuck them in their asses instead.

>hard-to-read
t. brainlet

Kill youself motherfucker

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.