## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Aug 17 09:32
• Jun 20 21:19
@bjorno43 banned @shenerd140
• Apr 25 17:13
@mstellaluna banned @cmal
• Jan 08 22:05
@mstellaluna banned @dertiuss323
• Nov 07 2018 04:42
User @texas2010 unbanned @ows-ali
• Nov 02 2018 16:25
@texas2010 banned @ows-ali
• Oct 12 2018 05:50
@bjorno43 banned @NACH74
• Oct 05 2018 23:02
@mstellaluna banned @JomoPipi
• Sep 16 2018 12:21
@bjorno43 banned @yash-kedia
• Sep 16 2018 12:16
@bjorno43 banned @vnikifirov
• Sep 05 2018 08:12
User @bjorno43 unbanned @androuino
• Sep 05 2018 07:38
@bjorno43 banned @androuino
• Aug 23 2018 16:57
User @bjorno43 unbanned @rahuldkjain
• Aug 23 2018 16:23
@bjorno43 banned @rahuldkjain
• Jul 29 2018 14:13
User @bjorno43 unbanned @jkyereh
• Jul 29 2018 01:00
@bjorno43 banned @jkyereh
• Jul 10 2018 22:09
@bjorno43 banned @manafn
• Jul 06 2018 15:20
@texas2010 banned @imlegend19
• Jul 03 2018 12:28
@bjorno43 banned @vbvmatta
• Jun 29 2018 13:54
@bjorno43 banned @OGTechnoBoy
Stephen James
@sjames1958gm
@kerafyrm02
3 is 011 and 4 is 100 so |= is 111 which is 7
kerafyrm02
@kerafyrm02
^
Emil
@aguyinmontreal
I'm trying to find it's a typo of what
what did he really mean?
kerafyrm02
@kerafyrm02
The bitwise part or the recurssion part?
Emil
@aguyinmontreal
what is the non-bitwise equivalent of "|="?
I think the recursion part is fine, so yes, the weird bitwise typo part.
kerafyrm02
@kerafyrm02
well he was probably trying to be fancy and used the bitwise part- it may not be a typo
you rarely use bitwise in programming. except for maybe a few exceptions
at least in JS
Stephen James
@sjames1958gm
Rarely use it in web programming for sure :)
kerafyrm02
@kerafyrm02
That's all i do btw-
Emil
@aguyinmontreal
function markErrorRows($rows, add) { var added = false;$rows.each(function () { added |= markErrorRow($(this), add); }); return added; } Stephen James @sjames1958gm @aguyinmontreal Look like he is using so that if any return true then the final answer is true where false is 0 and true is non-zero kerafyrm02 @kerafyrm02 yeah so its base is if added is t/f Stephen James @sjames1958gm Probably could do ||= and it might be slightly clearer Emil @aguyinmontreal @sjames1958gm are you sure ||= is valid? I don't see it in the list https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators Stephen James @sjames1958gm @aguyinmontreal maybe not :( kerafyrm02 @kerafyrm02 nope- Stephen James @sjames1958gm nope Emil @aguyinmontreal so what is the non-bitwise equivalent of |= ? kerafyrm02 @kerafyrm02 It seems to me it does two things Stephen James @sjames1958gm Well in this case added = added || markErrorRow() But there is no non-bitwise equivalent of that kerafyrm02 @kerafyrm02 if its < 0 then it returns that value if it's >= 0 then it adds it that's from testing it myself ie (function(){ var x = 3; x |= 4; // x = 7 but if x |= -3; // x = -3 })(); Emil @aguyinmontreal alright! thanks guys! @kerafyrm02 @sjames1958gm CamperBot @camperbot aguyinmontreal sends brownie points to @kerafyrm02 and @sjames1958gm :sparkles: :thumbsup: :sparkles: :cookie: 288 | @kerafyrm02 |http://www.freecodecamp.org/kerafyrm02 :star2: 9179 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm kerafyrm02 @kerafyrm02 weird- nvr came across that before Emil @aguyinmontreal @kerafyrm02 everyday we learn something new :D kerafyrm02 @kerafyrm02 It seems like an unintended each function though. Emil @aguyinmontreal function markErrorRows($rows, add) { var added = false; $rows.each(function () { added |= markErrorRow($(this), add); }); return added; }
What do you mean by "unintended"? $rows.each is pretty clear for me kerafyrm02 @kerafyrm02 added will get overwritten multiple times. at least that what it seems to me each differs from map -- because it will stop the each if one false is encountered. Emil @aguyinmontreal you mean an unintended each function inside the $rows.each function?
yes, maybe :D
kerafyrm02
@kerafyrm02
im curious as to what the main goal is
Emil
@aguyinmontreal
it's part of a form validation
kerafyrm02
@kerafyrm02
Why not just use regex functions?
Emil
@aguyinmontreal

it's then used here:

if (markErrorRows(\$rows, !hideErrors)) {
errors.push("Office Locations" + ": " + "Please fill the fields labelled in red.");
}

@kerafyrm02 - the representation of negative numbers in binary, especially something like -1 is 1111111111111 - mostly ones. So if you OR those values together, most of the bits are already set to 1, which likely result in not much of a change in the final numeric value.