These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Nov 2017
AbrisM
@AbrisM
Nov 21 2017 00:49
Finally chat works!
AbrisM
@AbrisM
Nov 21 2017 01:39
Anyone alive? Hello
Brad
@bradtaniguchi
Nov 21 2017 01:50
@AbrisM people are just in a coma until you poke them with an @ lol
Ken Haduch
@khaduch
Nov 21 2017 04:15
@AbrisM - hello, people are around...
Ken Haduch
@khaduch
Nov 21 2017 04:23
@greaneym - hello... not sure what's supposed to be happening in this pen? Nothing seems to be loading or displaying, no errors displayed in the console.
abraham anak agung
@padunk
Nov 21 2017 04:28
Hi, did anybody know what is this ~ for ? i look at somene code and have this line r[e] = -~r[e]
Ken Haduch
@khaduch
Nov 21 2017 04:35
@padunk - check the Javascript operators documentation - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Bitwise_operators - it is an operator that does a "bitwise NOT" - Bitwise NOT ~ a Inverts the bits of its operand.
abraham anak agung
@padunk
Nov 21 2017 04:39
@khaduch thank you, i will take a look at it
CamperBot
@camperbot
Nov 21 2017 04:39
padunk sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3517 | @khaduch |http://www.freecodecamp.org/khaduch
0xyu
@0xyu
Nov 21 2017 07:25
var re = /[\W\s_]/gi;
who can told me the meaning of the character: "_"
Markus Kiili
@Masd925
Nov 21 2017 07:29
@Si13nce It is the underscore character. \w means word characters, and underscore is considered a word character because it is often used in variable names and identifiers in programming.
@Si13nce \W targets non-word characters, so it doesn't target underscore. Therefore in order to remove it, you need to add it to the regexp.
0xyu
@0xyu
Nov 21 2017 07:35
@Masd925 Thanks,I see what that means
CamperBot
@camperbot
Nov 21 2017 07:35
si13nce sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4578 | @masd925 |http://www.freecodecamp.org/masd925
Blauelf
@Blauelf
Nov 21 2017 09:44
@Si13nce \W (non-word character) is a superset of \s (whitespace character), so [\W\s_] is same as [\W_].
@padunk prepending -~ is +1 in disguise, ~- is -1, both convert to 32-bit signed integer first. For those integers, -a==~a+1
abraham anak agung
@padunk
Nov 21 2017 10:08
@Blauelf so in my example above, if r[e] =1 than -~r[e] will be 2?
Blauelf
@Blauelf
Nov 21 2017 10:09
Yes. -~a==a+1<=>-a==~a+1<=>a==~-a+1<=>~-a==a-1
abraham anak agung
@padunk
Nov 21 2017 10:15
Hmmm. Why dont write r[e]+1? It is the same right?
Blauelf
@Blauelf
Nov 21 2017 10:16
If the number fits into 32-bit signed integer, yes.
Maybe gives shorter code.
like 42*-~a vs. 42*(a+1) (but not in your case it seems)
abraham anak agung
@padunk
Nov 21 2017 10:36
@Blauelf Ok. Thank you. One more thing, could you give an example for ^? I didnt get what XOR is
CamperBot
@camperbot
Nov 21 2017 10:36
padunk sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4656 | @blauelf |http://www.freecodecamp.org/blauelf
Blauelf
@Blauelf
Nov 21 2017 10:58
@padunk XOR is exclusive OR (1 where exactly one input had a 1, and 0 for both 0 or both 1), so for example 0x42 ^ 0x23 (01000010 and 00100011) would result in 0x61 (01100001).
0x42 01000010
0x23 00100011
^    01100001
abraham anak agung
@padunk
Nov 21 2017 11:10
@Blauelf ok got it. Thanks again.
CamperBot
@camperbot
Nov 21 2017 11:10
api offline
J-Mag Guthrie
@baseballpoetess
Nov 21 2017 11:15
alas, poor CamperBot. I knew him, Horatio.
seriously, I have a question -- how do you do a popup window?
It's for tictactoe, so I'm legit
Markus Kiili
@Masd925
Nov 21 2017 11:18
@baseballpoetess There are alert, confirm, and prompt, but you can also do one with your own DOM element that you position over the page. Or use some library.
J-Mag Guthrie
@baseballpoetess
Nov 21 2017 11:18
Okay, I don't want an alert.
They look ugly.
I'm hoping to solve an issue of my tic tac toe not showing the screen at the end. becuase it chugs ahead to the next hing. I think if I made the next thing pop up and not over the whole board, the player could see how the game ended.
@Masd925 can you point me to a link where I can learn to do my own DOM element?
Markus Kiili
@Masd925
Nov 21 2017 11:23
@baseballpoetess I just mean an element that you style and position (fixed position perhaps) over the other elements of the page.
J-Mag Guthrie
@baseballpoetess
Nov 21 2017 11:25
Okay, yeah, but ..... maybe I need to retool my whole CSS or something to make that work. And I've never seen a working popup implemented so if you can point me to a link of someone doing that.
Markus Kiili
@Masd925
Nov 21 2017 11:25
You can dynamically generate it with JS when you need or you can define it with html and css and have for example display:none set on it at first and then show it at proper point.
J-Mag Guthrie
@baseballpoetess
Nov 21 2017 11:27
That's kinda how I do my board, first' it's a rectangle , then it's a table of 9 cells.
Markus Kiili
@Masd925
Nov 21 2017 11:28
You can use z-index to make it sure that the popup is shown on top of other content and fixed positioning for showing it on some specific position on the screen.
J-Mag Guthrie
@baseballpoetess
Nov 21 2017 11:28
kk, I'll try stuff and see what I come up with.
maybe it's my divs that are messing me up.
thanks @Masd925
CamperBot
@camperbot
Nov 21 2017 11:29
baseballpoetess sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4579 | @masd925 |http://www.freecodecamp.org/masd925
J-Mag Guthrie
@baseballpoetess
Nov 21 2017 11:29
ooo, cbot is back
Donnie
@Donnie-D
Nov 21 2017 11:40
A very warm greetings to all you wonderful campers :fire: :smile:
its funny I log in chat when I am stuck on something but end up staying much longer watching people talk .(popcorn time! Nosey me :shipit: )
Donnie
@Donnie-D
Nov 21 2017 11:47
CAN anyone answer my simple query please?
function loadDoc(url, cFunction) {
  var xhttp;
  xhttp=new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      cFunction(this);         //what is '''this''' pointing to in this case?
    }
  };
  xhttp.open("GET", url, true);
  xhttp.send();
}
CamperBot
@camperbot
Nov 21 2017 11:48
:bulb: to format code use backticks! ``` more info
Donnie
@Donnie-D
Nov 21 2017 11:49
i have read quite a bit about "this" but clearly not enough.
well there we go
Markus Kiili
@Masd925
Nov 21 2017 11:52
@Donnie-D onreadystatechange seems to be a method of xhttp object, so inside that method this points to the object xhttp.
You could use xhttp.readyState===4 etc too.
Donnie
@Donnie-D
Nov 21 2017 11:59
@Masd925 you are a boss
:+1:
Blauelf
@Blauelf
Nov 21 2017 12:17
@baseballpoetess cbot's api offline is a mistake in parsing a response, not really an offline api. In most cases, it means that cookies from this person to the other were recently given and are still in cooldown.
Donnie
@Donnie-D
Nov 21 2017 12:54
just an innocent question. Does one have to learn XML and PHP as well to get the full joy out of AJAX? Or even does one have to learn PHP anyway for front end only. Also I have been reading about XML online that its a machine and human both readable format. Does this make XML more useful than HTML?
Diego Mayer
@Chrono79
Nov 21 2017 12:58
@Donnie-D I would say no to all of those questions
Donnie
@Donnie-D
Nov 21 2017 12:59
@Chrono79 very deep lol
cheers
Diego Mayer
@Chrono79
Nov 21 2017 13:01
I could have writen a single no :P
But AJAX and PHP are independent of each other
Also, you can't write a webpage in xml, xml is used to transfer data, more like JSON
You're comparing different things, so the basic answer is no, without further data
Markus Kiili
@Masd925
Nov 21 2017 13:03
@Donnie-D AJAX transfers text that can be of any format. XML and JSON are popular such formats. PHP is used for backend.
Diego Mayer
@Chrono79
Nov 21 2017 13:04
AFAIK PHP is one of Markus favourite languages ;)
Markus Kiili
@Masd925
Nov 21 2017 13:04
:imp:
Diego Mayer
@Chrono79
Nov 21 2017 13:04
LOL
Donnie
@Donnie-D
Nov 21 2017 13:04
just when i started AJAX, I thought its purely related to Javascript but reading more into it makes me confused regarding its bigger picture and uses. thats all. but glad to see your response regarding XML. I was wondering why its there anyway then lol
Markus Kiili
@Masd925
Nov 21 2017 13:08
@Donnie-D Earlier XML was the dominant way to transmit structured data. That explains the X in the name.
Donnie
@Donnie-D
Nov 21 2017 13:12
:+1: allo'ya champions
Blauelf
@Blauelf
Nov 21 2017 13:12

@Donnie-D Neither XML nor PHP will give you an advantage, unless you actually use them.

Some people use PHP for command-line scripting (others prefer for example perl, bash, or python). Others use it for back-end, with Facebook and Wordpress most well-known users. If you want to work in a company that requires PHP, go for it. If not, maybe.

XML is something you should understand on a superficial level (nesting of elements, every element has to be closed, ...), and deeper (XSLT and stuff) as much as you need. It's still used on back-end, usually only basic features.

Markus Kiili
@Masd925
Nov 21 2017 13:20
@Blauelf Java likes to use XML for holding deployment information and for some build automation.
I am very sad that HTML5 won the battle against XHTML.
Diego Mayer
@Chrono79
Nov 21 2017 13:22
the X in XHTML is from strict (or maybe not)
It's from eXtensible it seems
Blauelf
@Blauelf
Nov 21 2017 13:23

The X of XHTML is same as the X of XML.

Our website claims to be XHTML, while it clearly isn't, but browsers won't complain but ignore the statement.

Ahmad Abdolsaheb
@ahmadabdolsaheb
Nov 21 2017 14:23
I was wondering if anyone knows a solution for mixing twitter Oauth and Jwt username/pass auth for redux
Margaret Greaney
@greaneym
Nov 21 2017 14:25
@khaduch , thanks for your response. I think I gave the wrong link. I am having problems with assets on codepen.io and put the js lib hexi.js as a pen and I think gave that link yesterday instead of to the react game. This is my attempt to make a react game with hexi.js, https://codepen.io/greaney/pen/eeVLEP
CamperBot
@camperbot
Nov 21 2017 14:25
greaneym sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3518 | @khaduch |http://www.freecodecamp.org/khaduch
Margaret Greaney
@greaneym
Nov 21 2017 14:27
I don't understand yet why it works locally on my laptop but not on codepen.io but I will keep trying. I did the assets test for just pixi.js alone and that works. I will try putting the hexi.js asset on github and see if it will work from there.
Stephen James
@sjames1958gm
Nov 21 2017 14:36
@greaneym For some reason when this is called gameScene.addChild(myS1); myS1 is not defined
It may be order of execution when in codepen vs. locally.
g.start() internally calls your setup() which uses myS1 but it is not yet defined or given a value.
It might be due to hoisting issues?
AbrisM
@AbrisM
Nov 21 2017 15:08
https://codepen.io/anon/pen/JOLbzW could someone tell me why this code isn't working?
Stephen James
@sjames1958gm
Nov 21 2017 15:11
What are you expecting it to do?
Blauelf
@Blauelf
Nov 21 2017 15:11
Click the cog icon, choose the JS tab, quick-add jQuery.
Stephen James
@sjames1958gm
Nov 21 2017 15:11
nvm
AbrisM
@AbrisM
Nov 21 2017 15:11
It's suppose to type out the corresponding phrases/letters that the user puts in from the "Enter Text Here"
Blauelf
@Blauelf
Nov 21 2017 15:12
On CSS tab, choose SCSS preprocessor.
AbrisM
@AbrisM
Nov 21 2017 15:12
Nothing is showing up however, and typing does nothing
Blauelf
@Blauelf
Nov 21 2017 15:13
Works for me after those two changes.
AbrisM
@AbrisM
Nov 21 2017 15:14
Ah no wonder why, okay that works
Rofl it won't work on its on if its purely a website though
Mark
@vinarius
Nov 21 2017 15:16
morning guys
AbrisM
@AbrisM
Nov 21 2017 15:16
@vinarius Morning
Mark
@vinarius
Nov 21 2017 15:17
I deployed my first full stack app last night to a live server
Stephen James
@sjames1958gm
Nov 21 2017 15:20
@vinarius :+1:
Christopher McCormack
@cmccormack
Nov 21 2017 15:24
@vinarius did it take down the network?
Mark
@vinarius
Nov 21 2017 15:25
nope, its live though if you guys want to look. nobleaesthetic.com
Christopher McCormack
@cmccormack
Nov 21 2017 15:28
@vinarius looks good! Are you using the backend for the Connect With Us functionality?
Mark
@vinarius
Nov 21 2017 15:31
yes sir :)
eventually itll be an ecommerce page, but i'm still learning
Christopher McCormack
@cmccormack
Nov 21 2017 15:33
very cool - using node/express?
Blauelf
@Blauelf
Nov 21 2017 15:34
Header lines say "yes".
X-Powered-By: Express
AbrisM
@AbrisM
Nov 21 2017 15:34
nice
Christopher McCormack
@cmccormack
Nov 21 2017 15:35
@Blauelf :D
Mark
@vinarius
Nov 21 2017 15:36
i spent 4 hours at starbucks last night trying to figure out how to redirect from http to https
it was something simple yet extraordinarily difficult for me to google and understand how to look at header info
i was trying to do it via apache with the .htaccess file, but i ended up just doing it through the node app
Blauelf
@Blauelf
Nov 21 2017 15:37
I like how you use CSS instead of jQuery for those border-radius effects :)
Mark
@vinarius
Nov 21 2017 15:38
thanks @Blauelf
CamperBot
@camperbot
Nov 21 2017 15:38
vinarius sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4657 | @blauelf |http://www.freecodecamp.org/blauelf
Christopher McCormack
@cmccormack
Nov 21 2017 15:38
@vinarius if it's node it wouldn't be using apache right? That piece confuses me just a little bit
unless node is just the backend
then you should be able to do htaccess, I was able to do it just fine.
I used this on my server:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Mark
@vinarius
Nov 21 2017 15:40
well
i tried that code and it does work
Blauelf
@Blauelf
Nov 21 2017 15:40

@vinarius The facebook link seems to have some extra. Is this intended?

https://www.facebook.com/Noble-Aesthetic-1433265413459968/ ?view_public_for=1433265413459968

Mark
@vinarius
Nov 21 2017 15:40
however i'm using a shared server, not a vps. therefore i dont have root access and the redirect in htaccess with that code goes to the root level and gives the user a 403 - forbidden status
Christopher McCormack
@cmccormack
Nov 21 2017 15:40
I'm on a shared server as well
Mark
@vinarius
Nov 21 2017 15:41
its probably a difference between the way our hosts have the servers set up in that case
Christopher McCormack
@cmccormack
Nov 21 2017 15:42
/shrug
Mark
@vinarius
Nov 21 2017 15:42
@Blauelf it looks like its just a query for facebook to show that its a public page. im sure it could be omitted, but ill take care of that revision in a future upgrade
Blauelf
@Blauelf
Nov 21 2017 15:43
I think that might be the function "show your profile as somebody else would see it", just that you set it to the profile itself.
Mark
@vinarius
Nov 21 2017 15:44
doesnt seem to be interfering with the ux so it's not a priority. ill put it on my to do list.
Blauelf
@Blauelf
Nov 21 2017 15:44
Looks like others use it, too, so probably correct, I just don't understand its meaning.
Ken Haduch
@khaduch
Nov 21 2017 15:46
@greaneym - have you had success running things like this on CodePen? I see JavaScript code / React code (JSX) in the HTML panel, and I wouldn't be surprised if there was a problem trying to run that in that way on CodePen? :point_up: November 21, 2017 9:25 AM
Mark
@vinarius
Nov 21 2017 16:08
have you guys heard anything about fcc beta progression?
Jason Luboff
@JLuboff
Nov 21 2017 16:16
@vinarius The last thing I read (which was on the FCC forum several months ago) it made it sound like beta would be going live around the end/beginning of the year. From what little I've played with beta...it doesn't seem quite ready..
Mark
@vinarius
Nov 21 2017 16:16
that's what i thought too
Kaz Baig
@kbaig
Nov 21 2017 16:23
Prob agree. Wording needs work in a lot of areas
pocahontas123
@pocahontas123
Nov 21 2017 16:30
Hello, i need help for a regex which split at space, single quote(') and double quote (")
Spyrantis Theodoros
@thodorisanta
Nov 21 2017 16:31
is there a fast way to compare if two arrays have the same values in the same order?
Christopher McCormack
@cmccormack
Nov 21 2017 16:33
@thodorisanta Are these flat arrays? If so you can first compare the length and ensure its the same, then compare each index for equality
Spyrantis Theodoros
@thodorisanta
Nov 21 2017 16:34
@cmccormack they have strings inside
Christopher McCormack
@cmccormack
Nov 21 2017 16:35
Comparing items like strings or numbers in an array should be pretty fast. If your array also contained nested arrays or objects it would take a bit more code
You could also probably cheat and stringify both arrays and compare them as strings
Spyrantis Theodoros
@thodorisanta
Nov 21 2017 16:36
how can i do that?
Christopher McCormack
@cmccormack
Nov 21 2017 16:37
> JSON.stringify(['a', 'b']) === JSON.stringify(['a', 'b'])
true
You said fast, not sure if you mean time to code or execution efficiency
Jason Luboff
@JLuboff
Nov 21 2017 16:38
@cmccormack I think in the wherefore art thou challenge thats how I did it once...stringified everything to compare lol
Christopher McCormack
@cmccormack
Nov 21 2017 16:38
@JLuboff I mean, if it works it works right?
haha
Spyrantis Theodoros
@thodorisanta
Nov 21 2017 16:38
also is it a good idea to make a for to compare the strings and if like add a function call inside my for to stop the loop and go to the function? if(array1[i] !== array2[i]){ function1();}
Jason Luboff
@JLuboff
Nov 21 2017 16:38
@cmccormack Probably not best practice..but ya! lol
Christopher McCormack
@cmccormack
Nov 21 2017 16:40
@thodorisanta that won't stop your loop without a break or a return if your loop is in a function
Spyrantis Theodoros
@thodorisanta
Nov 21 2017 16:40
how can i stop the loop and call the function? also is it a good idea? @cmccormack
Christopher McCormack
@cmccormack
Nov 21 2017 16:40
I personally prefer to put stuff like that into a function like compareArrays(arr1, arr2) or whatever so I can just return out of it, maybe return false if it doesn't match and if the return value is false, run your function
@thodorisanta I can't answer if it's a good idea without knowing what you're doing, but sure, breaking out of a loop early is fine.
@thodorisanta get it working and then you can ask yourself if there is a nicer way to do it
Kaz Baig
@kbaig
Nov 21 2017 16:44
@thodorisanta btw, you don't need the curly brackets around the function call in that if statement if it's in one line ;) just in case you didn't know
Spyrantis Theodoros
@thodorisanta
Nov 21 2017 16:45
@kbaig haha i know that but i always put them. i feel like my code is more readable that way :P
Christopher McCormack
@cmccormack
Nov 21 2017 16:46
IMO you should always use curly braces just so you don't try to expand functionality later and forget you didn't have them. My only exceptions are lines like if (err) throw err; or if (false) return; where it's basically an escape hatch that won't do anything else
AbrisM
@AbrisM
Nov 21 2017 16:55
Isn't a throw err the same as Exception IO in Java?
Christopher McCormack
@cmccormack
Nov 21 2017 16:55
I use it in Node to kill a process if something doesn't work
probably better ways
but fast :)
Jason Luboff
@JLuboff
Nov 21 2017 16:56
Thats the way I always see it done ;)
Kaz Baig
@kbaig
Nov 21 2017 16:57
@cmccormack yeah that's the only place I would do it too
Brian
@BrianCodes33
Nov 21 2017 18:32
var cubeChecker = function(volume, side){
  if (Math.pow(side,3) === volume) {
    return true;
  } 
  return false;
};
this test isn’t passing
Test.assertEquals(cubeChecker(-8,-2), false);
any clues?
Kaz Baig
@kbaig
Nov 21 2017 18:34
@BrianCodes33 -2 cubed is -8 but you can't have negative volume
or negative length in real terms
Brian
@BrianCodes33
Nov 21 2017 18:35
i know
so how do i check for that
got it thx
var cubeChecker = function(volume, side){
  if (volume > 0 && Math.pow(side,3) === volume) {
    return true;
  } 
  return false;
};
Kaz Baig
@kbaig
Nov 21 2017 18:36
return volume > 0 && Math.pow(side, 3) === volume;
You only need to check volume in this case, yeah
Brian
@BrianCodes33
Nov 21 2017 18:38
var cubeChecker = function(v, s){
  return s>0&&v==s*s*s;
};
Jason Luboff
@JLuboff
Nov 21 2017 18:41
@BrianCodes33 You can shorten s*s*s to s**3
Kaz Baig
@kbaig
Nov 21 2017 18:41
oh right forgot about the new operator
:)
Jason Luboff
@JLuboff
Nov 21 2017 18:42
Not sure if its any faster then Math.pow and I would argue makes code a little less readable unless you're really familar with it but its shorter!
Kaz Baig
@kbaig
Nov 21 2017 18:43
@JLuboff it's the same operator in python
Jason Luboff
@JLuboff
Nov 21 2017 18:43
Well if you know python you're good to go!
Markus Kiili
@Masd925
Nov 21 2017 18:45
@JLuboff Still experimantal technology in JS that **.
Kaz Baig
@kbaig
Nov 21 2017 18:45
It's ES7
It'll land soon enough
Jason Luboff
@JLuboff
Nov 21 2017 18:46
@Masd925 It's listed in the MDN?
Kaz Baig
@kbaig
Nov 21 2017 18:46
If it hasn't already
Kaz Baig
@kbaig
Nov 21 2017 18:46
It's implemented in Chrome at least, working in my console
Markus Kiili
@Masd925
Nov 21 2017 18:46
@JLuboff It is ES7 proposal.
Kaz Baig
@kbaig
Nov 21 2017 18:47
ES7 was last year
Joshua Arnett
@josha5
Nov 21 2017 18:47
@JLuboff Any chance you can help me with the simon project almost done but am seriously stuck on my last hump
Jason Luboff
@JLuboff
Nov 21 2017 18:47
@josha5 ...maybe? Post up your question for all to help! (aka @kbaig and @Masd925 too)
And maybe @sjames1958gm if he is lurking. Or perhaps @cmccormack is hiding behind his screen
Joshua Arnett
@josha5
Nov 21 2017 18:50
Basically on a correct click when my replayFlash function is called that replays all the correct clicks, my highLightSquare function that highlights a new square isn't waiting for the replayFlash function to finish before highlighting a new sqaure
Markus Kiili
@Masd925
Nov 21 2017 18:50
@JLuboff It is ES7 operator, yes.
Jason Luboff
@JLuboff
Nov 21 2017 18:51
@josha5 My method was to push my new value to an array (the array that stored all of the previous values) that played all at once
Joshua Arnett
@josha5
Nov 21 2017 18:51
@JLuboff Hopefully that makes sense. my highLightSquare function is highLighting a new square in the middle of the replay sequence. Doesn't happen until the array containing the values is > 3
Jason Luboff
@JLuboff
Nov 21 2017 18:52
@josha5 So maybe have your highLightSquare push its value to your array, then call replayFlash?
Kaz Baig
@kbaig
Nov 21 2017 18:52
@josha5 You prob don't want to separate the new square from the rest of the sequence is @JLuboff said
Joshua Arnett
@josha5
Nov 21 2017 18:52
var clickNum = 0;
function correctClick(buttons) {
  var displayCount = $("#display").text();
  $(".button").on("click", function() {
    var thisClick = $(this).attr("id");
    var matchBut = buttonPressValidate[clickNum];
    if(thisClick == matchBut) {
      clickNum++;
      setTimeout(function() {
        replayFlash(buttonPress);
        if(buttonPressValidate.length === clickNum) {
           setTimeout(function() {
             highLightSquare(simonButtons);
           }, 1500);
        }
      }, 1500);
    }  
  });  
}

correctClick($(simonButtons));

function replayFlash(butPressArr) {
  function eachColor(i) {
    var litColor = $(butPressArr[i]);
    setTimeout(function() {
      litColor.addClass("lit");
      if(litColor.attr("id") === "greenButton") {
         greenButton.play();
      } else if(litColor.attr("id") === "redButton") {
          redButton.play();        
      } else if(litColor.attr("id") === "blueButton") {
          blueButton.play();      
      } else if(litColor.attr("id") === "yellowButton") {
          yellowButton.play();      
      }
      setTimeout(function() {
        litColor.removeClass("lit");
      }, 1000 - (1000 / 3));
    }, 1000 * (i + 1));
  }
  for(var i = 0; i < butPressArr.length; i++) {
    eachColor(i);
  }
}
@JLuboff thats a good idea
Jason Luboff
@JLuboff
Nov 21 2017 18:55
I sure thought so :D
Joshua Arnett
@josha5
Nov 21 2017 18:55
@JLuboff thanks ill give it a try
CamperBot
@camperbot
Nov 21 2017 18:55
josha5 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2271 | @jluboff |http://www.freecodecamp.org/jluboff
Joshua Arnett
@josha5
Nov 21 2017 19:06
@JLuboff Worked like a charm, my god I don't know why I always complicate things lol.
Jason Luboff
@JLuboff
Nov 21 2017 19:07
@josha5 Glad it worked out. Its all about learning. I constantly complicate things, but sometimes you just need an idea or two from someone else :+1:
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:20
hey
Ronique Ricketts
@RoniqueRicketts
Nov 21 2017 19:20
sup
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:20
how's nodejs going @RoniqueRicketts ?
Ronique Ricketts
@RoniqueRicketts
Nov 21 2017 19:21
@tiagocorreiaalmeida it went well :)
I am suppose to do mongo now but someone asked me to help them with a WP site
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:22
uh, you know php or just know how to work with wp in general?
Ronique Ricketts
@RoniqueRicketts
Nov 21 2017 19:22
@tiagocorreiaalmeida lol I know a little php :)
@tiagocorreiaalmeida I know a little wp too with little php
Jason Luboff
@JLuboff
Nov 21 2017 19:24
What up
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:24
still something, I can tell you that wordpress gets me scared cause sounds like confusing but then seems like there's a plugin for everything
Ronique Ricketts
@RoniqueRicketts
Nov 21 2017 19:24
@tiagocorreiaalmeida i think its crappy
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:25
hey @JLuboff almost shooting myself cause of this project :D
Jason Luboff
@JLuboff
Nov 21 2017 19:26
which? Trading app?
It took me a month and half to finish I think
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:26
yeah that one :D
Ronique Ricketts
@RoniqueRicketts
Nov 21 2017 19:27
I partely did my timestamp and stopped
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:28
I will get it to the point that I will ask here to be tested today and then will do the final fixs after, or I hope so im getting a bit bored with this one tough :D
Jason Luboff
@JLuboff
Nov 21 2017 19:28
I actually enjoyed doing it, just was a lot of work
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:30
what got me bored was on start the confusing of what to do tbh but well, time to dive in see you later :D
Jason Luboff
@JLuboff
Nov 21 2017 19:31
See ya
Margaret Greaney
@greaneym
Nov 21 2017 19:38
@sjames1958gm , yes, I agree with you, thanks for checking.
CamperBot
@camperbot
Nov 21 2017 19:38
greaneym sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8704 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Margaret Greaney
@greaneym
Nov 21 2017 19:40
@khaduch , thanks, yes, I need to put the react in the js panel on codepen in the right order. I will keep trying.
CamperBot
@camperbot
Nov 21 2017 19:40
greaneym sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3519 | @khaduch |http://www.freecodecamp.org/khaduch
Daniel Romero
@Ranacode
Nov 21 2017 19:40
How can I achieve this with ES6 modules?
models.forEach(function(model) {
  module.exports[model] = sequelize.import(__dirname + '/' + model);
});
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:44
do you atually say fixs or fixes?
im confused
Kaz Baig
@kbaig
Nov 21 2017 19:45
plural of fix is fixes
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:46
ok thanks @kbaig
CamperBot
@camperbot
Nov 21 2017 19:46
tiagocorreiaalmeida sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 447 | @kbaig |http://www.freecodecamp.org/kbaig
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 19:46
some brownies
Kaz Baig
@kbaig
Nov 21 2017 19:54
@Ranacode could do something like this maybe
const exports = {};
models.forEach(model => {
  exports[model] = sequelize.import(__dirname + '/' + model);
});

export { ...exports };
Kaz Baig
@kbaig
Nov 21 2017 19:59
export Object.assign(
  {},
  ...models.map(model => {
    return { [model]: sequelize.import(__dirname  + '/' + model) };
  })
);
Hey I found a time for Object.assign over spread :D
Daniel Romero
@Ranacode
Nov 21 2017 20:12
Yeah thanks @kbaig
CamperBot
@camperbot
Nov 21 2017 20:12
ranacode sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 448 | @kbaig |http://www.freecodecamp.org/kbaig
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:31
@JLuboff around?
image.png
Jason Luboff
@JLuboff
Nov 21 2017 20:31
Perhaps
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:31
is it possible to push an value from one array
pull*
and then push other values to the same array?
is there any work around for this beside 2 queries?
Jason Luboff
@JLuboff
Nov 21 2017 20:32
@tiagocorreiaalmeida You should be able to do that in one query
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:32
````
   Book.findOneAndUpdate({id:requestData.book_id_selected,"owners.user_id":userInfo["_id"]},
            {$pull: { owners: { user_id: userInfo._id }},$push: {
            owners: {user_id: req.user.id, username: req.user.name}}});
trhows the error that's above
Jason Luboff
@JLuboff
Nov 21 2017 20:34
Have you tested it in the mongo shell? Usually thats what I do
Test it until I have a working solution
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:34
I searched and somehow seems that's atually the atual behavior of mongodb
strange thing
Jason Luboff
@JLuboff
Nov 21 2017 20:35
@tiagocorreiaalmeida Ya...I guess you're right. Thats wierd
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:35
yeah
I got 2 requests like the above
plus 3 more normal requests to check for coexistence
now imagina 1 button that has 7 requests
I know this will be done in seconds
still :D
or less than one but yeah
Jason Luboff
@JLuboff
Nov 21 2017 20:46
7 queries at once? Seems excessive
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:47
need 1 remove the user from the old book push into the new one = 2 queries, that do that for the other user, that makes 4 queries
and there's the others ones that check for coexistence
plus I let a user get requested on the same book n times so after he trade I will to come back and clean all the requests on that user with that book, and the same for the other user
that makes allready 6 queries
Jason Luboff
@JLuboff
Nov 21 2017 20:49
Mmmhm mhmm
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:49
makes sense or not at all?
Jason Luboff
@JLuboff
Nov 21 2017 20:49
Ya I get it
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 20:50
like you get requested 10 timeso n the same book but I only let you offer a book in a request once per time something like that
sadly turns into a big chunk of queries
and thanks god we have promises or this would look funny
:D
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:33
return Book.findOneAndUpdate({id:requestData.book_id_selected,"owners.user_id":userInfo._id});
uh do you see any error on the query above?
does anyone*
image.png
its findone only my bad over there copied an old query
Jason Luboff
@JLuboff
Nov 21 2017 21:34
I do see an error
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:34
uh where?hum
Jason Luboff
@JLuboff
Nov 21 2017 21:34
Actually, hold on
hmm.. I was thinking you need "owners.user_id": ObjectId(userInfo._id)
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:36
sadly that's not the issue let me produce the same thing and copy the powershell error and let see if we can spot it
just returning undefined but I log the value and ask for them on the robomongo and works argg
image.png
image.png
 console.log(requestData.book_id_selected);
            console.log(userInfo._id);
            return Book.findOne({id:requestData.book_id_selected,"owners.user_id":userInfo._id});
Jason Luboff
@JLuboff
Nov 21 2017 21:40
Can you do
console.log(typeof userInfo._id)
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:41
I can allready feel that's the issue can't think why I forgot that :D
returns obj
Jason Luboff
@JLuboff
Nov 21 2017 21:44
mmmhmm... but you're saying encapsulating it inside ObjectId doesn't work?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:45
since in the table its asved as an string
on the one im trying to change
Jason Luboff
@JLuboff
Nov 21 2017 21:45
Ya..I saw that...but..
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:45
you that could maybe do it right?
think*
why not lets find out
:D
Jason Luboff
@JLuboff
Nov 21 2017 21:46
Try it and see
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:47
sadly didnt work
Jason Luboff
@JLuboff
Nov 21 2017 21:48
Hmm. And you have the ObjectId component of mongo available? (const ObjectId = require('mongodb').ObjectId;?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:48
yeah im using it in other palces
places
const express = require("express"),
    router = express.Router(),
    books = require("google-books-search"),
    {ObjectID} = require("mongodb");
  console.log("3------",userPushOne);
        if(userPushOne){

            console.log(requestData.book_id_selected);
            console.log(typeof userInfo._id);
            console.log(userInfo._id);
            return Book.findOne({id:requestData.book_id_selected,"owners.user_id":ObjectID(userInfo._id)});
            /* ,
            {$pull: { owners: { user_id: userInfo._id }}},{new:true} */
        }
    //CHECK IF THE NEW OWNER WAS REMOVED FROM THE PREVIOUS BOOK OWNERS
    }).then((userRemoveTwo)=>{
        console.log("4------",userRemoveTwo);
        if(userRemoveTwo){
            return Book.findOneAndUpdate({id:requestData.book_id_selected},{$push: {
            owners: {user_id: req.user.id, username: req.user.name}}});
        }
Jason Luboff
@JLuboff
Nov 21 2017 21:49
Ok. So lets do this. Try this query
  return Book.findOne({id:requestData.book_id_selected);
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:50
worked
Jason Luboff
@JLuboff
Nov 21 2017 21:52
Ok, so we know that portion of the query is working
So what about:
return Book.findOne({"owners.user_id":userInfo._id});
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:53
worked aswell, cries
:D
will be funny if now I just place all back and it works
Jason Luboff
@JLuboff
Nov 21 2017 21:54
try it and see
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 21:58
image.png
this is what it had to match and those are the values that I console log before the query
no idea what's not being done correctly
Jason Luboff
@JLuboff
Nov 21 2017 21:58
Just for shits and giggles...try find instead of findOne
Margaret Greaney
@greaneym
Nov 21 2017 21:59
@sjames1958gm @kenhaduch, thanks it is starting to work. I have more problems to fix but it is at least starting to show up,https://codepen.io/greaney/pen/jabMov
CamperBot
@camperbot
Nov 21 2017 21:59
greaneym sends brownie points to @sjames1958gm and @kenhaduch :sparkles: :thumbsup: :sparkles:
:star2: 8705 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
api offline
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:00
returned an empty array so its the same as a null
return Book.findOneAndUpdate({ id: requestData.book_id_requested, "owners.user_id": req.user.id }
this one runs
and this one doesnt
return Book.findOne({id: requestData.book_id_selected , "owners.user_id": userInfo._id});
and im here just trying to spot the issue
Jason Luboff
@JLuboff
Nov 21 2017 22:01
req.user.id === userInfo._id?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:01
nah
req.user.id
current user
userInfo._id other user that was involved in the trade
Jason Luboff
@JLuboff
Nov 21 2017 22:02
Oh fucking a...
owners is an array...
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:03
yeah :D
Jason Luboff
@JLuboff
Nov 21 2017 22:03
"owners.$.user_id"
I think thats what you need
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:03
I got queries above that work without it but lets find out
Jason Luboff
@JLuboff
Nov 21 2017 22:03
owners.user_id doesn't exist.
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:05
same result
I got queries like return Book.findOne({ id: bookID, "owners.user_id": req.user.id });
and they work
starting to pull my hairs off jesus
Jason Luboff
@JLuboff
Nov 21 2017 22:07
hmm.. try
return Book.findOne({owners: {$elemMatch: {user_id: userInfo._id}}});
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:08
we tried something like this above but without element mach and it found the doc, this is crazy :D
Jason Luboff
@JLuboff
Nov 21 2017 22:08
I understand, just try it to humor me ;)
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:08
but with the entire query or just this part?
Jason Luboff
@JLuboff
Nov 21 2017 22:09
Try that first
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:09
return Book.findOne({id: requestData.book_id_selected,owners: {$elemMatch: {user_id: userInfo._id}}});
oh ok
sec
worked
time to try the above and see where it goes
Jason Luboff
@JLuboff
Nov 21 2017 22:12
Ok, now try the above (I think its missing a } though)
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:13
didnt worked
time to pick a gun
and solve things
Jason Luboff
@JLuboff
Nov 21 2017 22:14
You may have to use an aggregate then
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:14
but why would this work above exactly the same fields being asked to amtch and below doesnt jesusususu
:D
Jason Luboff
@JLuboff
Nov 21 2017 22:15
I dunno
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:16
you know what im gonna do the decline request method and maybe look later at this but yeah quite confusing cause I print the values before I even do a query on the robomongo for the and it works
anyway thanks @JLuboff always helpfull and ready to help
CamperBot
@camperbot
Nov 21 2017 22:17
tiagocorreiaalmeida sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2272 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Nov 21 2017 22:18
:+1:
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:18
going to learn react mate?
Jason Luboff
@JLuboff
Nov 21 2017 22:19
Ya, I've started going through the FCC beta curriculm for it
Yaroslav
@YariPL
Nov 21 2017 22:22
Hello guys. I have a problem in putting jquery datepicker inside my php code. I already connect all the libraries I found related to this but it doesn;t work. It works like a usual text form, but not as a datepicker
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<script>

$( function() {
    $( "#datepicker" ).datepicker();
  } );

</script>
<form action="../admin/dcodes_action.php" id="new_code">
        <input id="new_code_textfield" type="text" name="newcode" placeholder="Enter new code">    
        <input id="new_code_submit" type="submit" value="Submit">
        <p><input type="text" name="eenddate" id="datepicker"></p>
</form>;
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 22:22
I think the main vantage of programming in a company is that if you are making something wrong or not the most correct way there will be someone poiting you out here will be impossible for every project to be checked so Im never sure if I did things the right way
Kaz Baig
@kbaig
Nov 21 2017 22:23
@YariPL what are you trying to get your JS to do
Jason Luboff
@JLuboff
Nov 21 2017 22:23
@YariPL Why so many different sources for jquery and jquery ui?
Yaroslav
@YariPL
Nov 21 2017 22:23
@kbaig I want to have a datepicker in my form
Kaz Baig
@kbaig
Nov 21 2017 22:24
But what is the JS supposed to do?
Yaroslav
@YariPL
Nov 21 2017 22:24
@JLuboff because I tried one then second and it doesn't work so I connected all I found on forumcs
Kaz Baig
@kbaig
Nov 21 2017 22:24
oh i see it's from jquery ui
Yaroslav
@YariPL
Nov 21 2017 22:25
@kbaig It must open like a calendar to chose the date
@JLuboff I also was trying to connect everything like here https://jqueryui.com/datepicker/ but it doesn't work
Kaz Baig
@kbaig
Nov 21 2017 22:26
it likely has something to do with all the different times you imported jquery and jquery ui
Jason Luboff
@JLuboff
Nov 21 2017 22:27
@YariPL Works on codepen..
https://codepen.io/jluboff/pen/eeMrdM
Kaz Baig
@kbaig
Nov 21 2017 22:28
it also happens to work if you just copy paste your snippet directly into codepen's html
rather than adding jquery via settings
Jason Luboff
@JLuboff
Nov 21 2017 22:29
@kbaig Probably depends on browser? I know the HTML5 datepicker only works in certain browsers
Kaz Baig
@kbaig
Nov 21 2017 22:29
@JLuboff I didn't even know there was one wow
Jason Luboff
@JLuboff
Nov 21 2017 22:30
Yup. Looks like FF finally supports it
Yaroslav
@YariPL
Nov 21 2017 22:31
maybe the problem is because I use it in php file but other js and jquery code worked before
I use chrome
Jason Luboff
@JLuboff
Nov 21 2017 22:31
@kbaig Looks like only IE doesn't support it. Edge, Chrome, and FF all support it
Kaz Baig
@kbaig
Nov 21 2017 22:33
gotcha gotcha
did you logging anything to the console
Yaroslav
@YariPL
Nov 21 2017 22:38
yes.see some problems in console
Yaroslav
@YariPL
Nov 21 2017 22:43
but it seems nothing relates to this
Yaroslav
@YariPL
Nov 21 2017 22:49
I do not see how to solve it.
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:03
@JLuboff
Jason Luboff
@JLuboff
Nov 21 2017 23:03
eh?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:03
image.png
but this is killing me :D
at least found out you can set out debug mode
Jason Luboff
@JLuboff
Nov 21 2017 23:04
What am I looking for?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:04
the problem we talked about and we tried to solve
before the null on the shell there's the query
Jason Luboff
@JLuboff
Nov 21 2017 23:04
Yes, yes
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:04
we have been trying to understand to understand
below the atual document
Jason Luboff
@JLuboff
Nov 21 2017 23:05
uh huh, yes
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:06
any idea? im going nuts on this one :D
so I found out I can't send the value as an objectid but instead turn it into a string might work since in robomongo I removed the objectid part and it worked
Jason Luboff
@JLuboff
Nov 21 2017 23:08
I dunno...I think its time for an aggregate ;)
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:09
image.png
I have no idea what those are ahaha
but will findout after this video
but I might be able to solve it this time and learn it after
Jason Luboff
@JLuboff
Nov 21 2017 23:10
Aggregates are...fun... :P
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:10
sarcasm?:D
Jason Luboff
@JLuboff
Nov 21 2017 23:11
No, they actually are. They're challenging, but very satisfying when you get it working
@tiagocorreiaalmeida Here's an aggregate I used for the stock app
db.collection('symbol').aggregate([
                    { $unwind: '$stockData' },
                    {
                        $match: {
                            datePulled: moment().format('MM-DD-YYYY'),
                            stockData: {
                                $gte: req.params.timeLength,
                                $lte: moment().format('YYYY-MM-DD')
                            }
                        }
                    },
                    { $project: { _id: 1, symbol: 1, stockData: 1, color: 1 } },
                    {
                        $group: {
                            _id: '$_id',
                            symbol: { $push: '$symbol' },
                            color: { $push: '$color' },
                            stockData: { $push: '$stockData' }
                        }
                    },
                    {
                        $project: {
                            symbol: { $arrayElemAt: ['$symbol', 0] },
                            stockData: 1,
                            color: { $arrayElemAt: ['$color', 0] }
                        }
                    }
                ], (err, doc)
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:22
I did a quick read on the call and this looks confusing to me but will find out about it soon :D
Jason Luboff
@JLuboff
Nov 21 2017 23:38
It is confusing at first....but it helps a lot to do it in the shell and piece it together
Less than an hour and a half to go then almost a full month off..
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:39
where you going?:D
btw found one of the issues of the code we have before jesus finally
Jason Luboff
@JLuboff
Nov 21 2017 23:39
No where...taking paternity leave
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:40
that's a good thing :D
Jason Luboff
@JLuboff
Nov 21 2017 23:40
Yup!
What was the issue?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:41
first was related with the part of it being using an objectid and not a normal issue and then I had there a varaible wrong and took me more 40minutes to figure it out :D well you learn by failure
with*
Jason Luboff
@JLuboff
Nov 21 2017 23:41
So you did or did not need Objectid?
Tiago Correia
@tiagocorreiaalmeida
Nov 21 2017 23:44
not need it was creating issues, anyway are you ready to stay away 1 month from code?:D
im starting to get confused 2 much time looking at issues correct me if im wrong
  return Request.remove({
                $or: [{ "from.user_id": req.user.id, "to": req.user.id }],
                $or: [{ "book_id_requested": requestData.book_id_requested, "book_id_selected": requestData.book_id_requested }]
            });
this removes all that has the from.user_id equal to req.user.id or all the "to" equal to req.user.id
and then same below right?
so it only removes if matches 1 at both or?
Jason Luboff
@JLuboff
Nov 21 2017 23:50
Not sure, never used the $or operator