Something like this:
function isOdd (num) {
return (num & 1) === 1;
}
the 1 (in num & 1) is used as a mask to check whether the number num is odd or not. If the last bit is set to 1 we know it is odd otherwise it is not odd.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What do you mean by bit manipulation "technique?"
Something like this:
function isOdd (num) {
return (num & 1) === 1;
}
the 1 (in num & 1) is used as a mask to check whether the number num is odd or not. If the last bit is set to 1 we know it is odd otherwise it is not odd.