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
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:
: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.
kerafyrm02
@kerafyrm02
@Emil I still dont see how that function does form validation.
Emil
@aguyinmontreal
@kerafyrm02 me too :D, it's part of a bigger form validation system
kerafyrm02
@kerafyrm02
there's like 5 types total. so much easier imo to do regex for each one
Not even 5 that need to be validated ., lol.
Emil
@aguyinmontreal
@kerafyrm02 yes, regex is definitely used somewhere :D
kerafyrm02
@kerafyrm02
email / number
are $rows the input fields? Emil @aguyinmontreal yes :D kerafyrm02 @kerafyrm02 what's the point of add? doesnt even get used Emil @aguyinmontreal I think it's the system that puts the fields in red when the value is incorrect kerafyrm02 @kerafyrm02 but i mean the function never uses it no point of passing it to it what kind of input field do you use Emil @aguyinmontreal yes in markErrorRow function markErrorRow($row, add) { var $cols =$row.find('.col:not(.optional)'); var filled = rowFilled($row); var added = false;$cols.each(function () { var $self =$(this); if (!getValue($self) && filled === -1) { if (add) { added = true;$self.addClass('empty_error'); } } else { $self.removeClass('empty_error'); } }); return added; } markErrorRow and markErrorRows are not the same kerafyrm02 @kerafyrm02 Can you do this in your console on your page that has the form? var inputs =$("input");
\$.each(inputs, function(_, e){

console.log(e.type);

});
kerafyrm02
@kerafyrm02