We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Using bitwise operator '&' for even/odd test on numeric input provides slight performance improvement; the Javascript solution is shown below, written in a compact form:
The explanation as requested: "Bitwise operator & sets each bit to 1 if both bits are 1, for example: 5 & 1 will reault in 1 (same as 0101 & 0001 = 0001)" re: JavaScript Bitwise Operations (https://www.w3schools.com/js/js_bitwise.asp)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 5: Arrow Functions
You are viewing a single comment's thread. Return to all comments →
Using bitwise operator '&' for even/odd test on numeric input provides slight performance improvement; the Javascript solution is shown below, written in a compact form:
The explanation as requested: "Bitwise operator & sets each bit to 1 if both bits are 1, for example: 5 & 1 will reault in 1 (same as 0101 & 0001 = 0001)" re: JavaScript Bitwise Operations (https://www.w3schools.com/js/js_bitwise.asp)