These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Apr 2018
Raghav Mundra
@Raghav17
Apr 02 2018 07:41
Hi!
If I want to change the colour of my div for 3 seconds and change it back to normal how can I do that using javascipt? I tried this but it isn't working.
$("#2").animate({
        "background-color": "white"
    })
    .delay(3000)
    .animate({
        "background-color": "blue"
    }, 1000);
1Mher1
@1Mher1
Apr 02 2018 07:44
@sjames1958gm hi I am found one defect my var b when thy must change background don't worked what can I do?
ZhangHong
@miles-zh
Apr 02 2018 09:01
How do?
How do??https://www.freecodecamp.cn/challenges/profile-lookup#?solution=%2F%2F%E5%88%9D%E5%A7%8B%E5%8C%96%E5%8F%98%E9%87%8F%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUp(firstName%2C%20prop)%7B%0A%2F%2F%20%E8%AF%B7%E6%8A%8A%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81%E5%86%99%E5%9C%A8%E8%BF%99%E6%9D%A1%E6%B3%A8%E9%87%8A%E4%BB%A5%E4%B8%8B%0A%20%20for(i%3D0%3Bi%3Ccontacts.length%3Bi%2B%2B)%7B%0A%20%20%20%20var%20a%3Dcontacts%5Bi%5D.firstName%3B%0A%20%20%20%20if(%20a%20%3D%3D%20firstName)%7B%0A%20%20%20%20%20%20if(contacts%5Bi%5D.hasOwnProperty(prop))%7B%0A%20%20%20%20%20%20%20%20return%20contacts%5Bi%5D.prop%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%7D%7Delse%7B%0A%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%7D%0A%20%20%7D%0A%2F%2F%20%E8%AF%B7%E6%8A%8A%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81%E5%86%99%E5%9C%A8%E8%BF%99%E6%9D%A1%E6%B3%A8%E9%87%8A%E4%BB%A5%E4%B8%8A%0A%7D%0A%0A%2F%2F%20%E4%BD%A0%E5%8F%AF%E4%BB%A5%E4%BF%AE%E6%94%B9%E8%BF%99%E4%B8%80%E8%A1%8C%E6%9D%A5%E6%B5%8B%E8%AF%95%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81%0AlookUp(%22Akira%22%2C%22likes%22)%3B%0A
Stephen James
@sjames1958gm
Apr 02 2018 10:03
@miles-zh You cannot return "No such contact" inside the for loop. Because you will only check contacts[0] before returning.
tundeiness
@tundeiness
Apr 02 2018 13:10

@tundeiness
any help with this?

https://codepen.io/highness/pen/LjBZgr?editors=1111

last challenge is to move all the search result as close as possible to the search icons
class container holds the search output and the wrap class. So what I did was to animate the wrap class so that it will go to the top of the container anytime i press the search icon. but the challenge right now is how to move the result closer to the top like the wrap class. Any heads up?

Jason Luboff
@JLuboff
Apr 02 2018 15:19
:wave:
Ken Haduch
@khaduch
Apr 02 2018 18:47
@JLuboff - hello - Happy Monday!
Adel
@AdelMahjoub
Apr 02 2018 18:52
So for drawing on a screen, If I set a velocity magnitude to a value, which will be set to pixels/frame initially. When the rendering start I can get the delta time between two frames, now I want to set that velocity magnitude to pixel/sec, I multiply that magnitude by the delta time. After that I want to apply an acceleration to that velocity on each frame, so the angle and the magnitude of the velocity will mutate on each frame. Knowing that the delta time is different each frame, is that velocity still mesured by pixel/sec ? or do I need to find a way to aplly that delta time on each frame ?
no need to be very accurate
Jason Luboff
@JLuboff
Apr 02 2018 18:57
@khaduch It's monday, whats so happy about it? :P I guess to be here another day is always a positive :D
Adel
@AdelMahjoub
Apr 02 2018 19:20
I knew posting a question here is 'magic', got the solution, Must store/update the previous delta on each frame, get the base magnitude multiply it by the new dt and set it back to the velocity
Christopher McCormack
@cmccormack
Apr 02 2018 19:26
:rubber_duck:
Kaz Baig
@kbaig
Apr 02 2018 19:32
never lucky rubber ducky
Christopher McCormack
@cmccormack
Apr 02 2018 19:34
I use a crocheted and stuffed final fantasy black mage as my rubber ducky, he's pretty smart :)
Rajat
@rajataudichya
Apr 02 2018 19:36
```js

function chunkArrayInGroups(arr, size) {
  // Break it up.

var fArr= [];

  var i = 0;

  while (i < arr.length){
  fArr.push(arr.splice(i,size));

  i+size;
  }
  return fArr;
}



chunkArrayInGroups(["a", "b", "c", "d"], 2);
isn't this the optimal way to the solution of chunky monkey challenge
Christopher McCormack
@cmccormack
Apr 02 2018 19:37
@rajataudichya optimal? what qualifies as optimal?
Rajat
@rajataudichya
Apr 02 2018 19:37
I am getting a error mark @ line where i+size
Christopher McCormack
@cmccormack
Apr 02 2018 19:38
@rajataudichya you probably want i+=size;
Kaz Baig
@kbaig
Apr 02 2018 19:38
@rajataudichya You're not reassigning i a value of i + size
Christopher McCormack
@cmccormack
Apr 02 2018 19:38
but you want to slice not splice
Kaz Baig
@kbaig
Apr 02 2018 19:38
^
Wait what is the challenge
Christopher McCormack
@cmccormack
Apr 02 2018 19:39
I think you want to return an array of arrays of size size
Kaz Baig
@kbaig
Apr 02 2018 19:39
oh kk
Rajat
@rajataudichya
Apr 02 2018 19:40
@cmccormack smart and least amout of codes required? :P
Kaz Baig
@kbaig
Apr 02 2018 19:41
yeah even after the fix, I think you're going to be returning [['a', 'b']]
Rajat
@rajataudichya
Apr 02 2018 19:41
@cmccormack I completed the challenge using splice as well
but why is there an error mark if i+size is given is it something wrong
Kaz Baig
@kbaig
Apr 02 2018 19:42
Not quite sure though, I don't usually work with mutation
Christopher McCormack
@cmccormack
Apr 02 2018 19:42
@rajataudichya what error
@rajataudichya right now all you are doing is splicing from 0 to size over and over. this will work provided you put something in to handle the case where the array is empty or your splice is larger than what remains (shouldn't happen in the tests in this exercise)
Rajat
@rajataudichya
Apr 02 2018 19:43
image.png
image.png
i resolved the slice thing
Christopher McCormack
@cmccormack
Apr 02 2018 19:44
@rajataudichya hover over the x and see what it says
it's probably telling you that statement is not doing anything
Rajat
@rajataudichya
Apr 02 2018 19:44
but its actually is
Christopher McCormack
@cmccormack
Apr 02 2018 19:44
no it's not
Rajat
@rajataudichya
Apr 02 2018 19:44
image.png
Christopher McCormack
@cmccormack
Apr 02 2018 19:45
exactly
you aren't assigning or incrementing anything with that statement
Rajat
@rajataudichya
Apr 02 2018 19:45
i+=size is not showing me the output
Christopher McCormack
@cmccormack
Apr 02 2018 19:45
so what it's doing is returning the sum of i and size but not assigning it to anything
@rajataudichya correct i+= size is the same as i = i + size which is both an expression (i+size) and an assignment (i = result of expression(i+size))
Rajat
@rajataudichya
Apr 02 2018 19:48
can you tell me where have I mistaken?
and what should i do
Christopher McCormack
@cmccormack
Apr 02 2018 19:48
@rajataudichya what do you have now?
Rajat
@rajataudichya
Apr 02 2018 19:48
the same image which I had before
sent*
Christopher McCormack
@cmccormack
Apr 02 2018 19:49
@rajataudichya you need to assign the result of your expression to the variable
if you want i to increment, you have to store the result of i + size in i
Rajat
@rajataudichya
Apr 02 2018 19:51

function chunkArrayInGroups(arr, size) {
  // Break it up.

var fArr= [];

  var i = 0;

  while (i < arr.length){
  fArr.push(arr.slice(i,size));

  var d = i+size;

     i=d;

    i++;

  }

  return fArr;
}



chunkArrayInGroups(["a", "b", "c", "d"], 2);
??
not working....
Christopher McCormack
@cmccormack
Apr 02 2018 19:53
@rajataudichya stop and ask yourself what you are trying to do
it appears you are just adding new stuff because it fulfills the need to store but consider what you're storing and how it's being used
Rajat
@rajataudichya
Apr 02 2018 19:55
ok @cmccormack
Christopher McCormack
@cmccormack
Apr 02 2018 19:56
@rajataudichya work through it slowly, write out what you want to do maybe in comments, then use console.log() to see the value of your variables at any given point so you can figure out where you're going wrong
I could tell you each mistake but that won't help you learn as quickly as solving it yourself
Rajat
@rajataudichya
Apr 02 2018 19:58
i have atleast try a dozen way to solve this now this is just getting on my nerve and making me frustated
but its fine lets see...
image.png
let me just move on with this solution which i got accidently..
no one in future is going to ask me have you compeleted chunky monkey challenge using the rightway..
Christopher McCormack
@cmccormack
Apr 02 2018 20:02
@rajataudichya so what you can learn from that one is that i+size is doing nothing because you aren't assigning the result of the expression to anything. Therefore, try deleting that line and see if it still works
Rajat
@rajataudichya
Apr 02 2018 20:06
yes
its still working..
actually i was learning strings methods and acidently added splice instead on slice which you pointed out a
and it was working...
Christopher McCormack
@cmccormack
Apr 02 2018 20:08
correct - you were basically shifting the array over size elements to the left every time you used splice, which worked fine. i didn't have to change in that case. @rajataudichya
@rajataudichya check this out when you get a second and see how I didn't even use i to get your result to work, and look at the browser console logs https://codepen.io/cmccormack/pen/EERbYK
Christopher McCormack
@cmccormack
Apr 02 2018 20:14
@rajataudichya you could even just use while (arr.length) { and it will work - once arr is emptied (from splice) it will have 0 length and thus the while conditional will be false, ending the loop
Jason Luboff
@JLuboff
Apr 02 2018 20:17
@cmccormack @kbaig :wave:
Christopher McCormack
@cmccormack
Apr 02 2018 20:17
@JLuboff yo
Rajat
@rajataudichya
Apr 02 2018 20:17
@cmccormack Thanks for helping me out
CamperBot
@camperbot
Apr 02 2018 20:17
rajataudichya sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1387 | @cmccormack |http://www.freecodecamp.org/cmccormack
Jason Luboff
@JLuboff
Apr 02 2018 20:17

@kbaig I think you'll like Glitch's newest update.

Node modules no longer count against the storage limits on your Glitch projects — only your code does.

@cmccormack How was the weekend?
Christopher McCormack
@cmccormack
Apr 02 2018 20:19
@JLuboff good man lots of family stuff, really relaxed after all the wedding stuff the weeks before
@JLuboff yourself?
Kaz Baig
@kbaig
Apr 02 2018 20:22
@JLuboff god bless dude
they must be caching packages
Jason Luboff
@JLuboff
Apr 02 2018 20:26
@cmccormack Not bad. We just did our own thing. Needed some time for ourselves
@kbaig Ya, they're actually officially out of beta. You may have recieved an email from them with all the new updates
Kaz Baig
@kbaig
Apr 02 2018 20:26
@JLuboff Oh I probably did
Jason Luboff
@JLuboff
Apr 02 2018 20:28
New Git GUI interface (or at least I assume its using git), built in devtool with breakpoints, step through, live client/server. Most common npm are cached (or sounds like it is), glitch embed, no more size limits, etc
Seems like a really big and nice update
Christopher McCormack
@cmccormack
Apr 02 2018 20:28
I hope it's easier to troubleshoot packages
Jason Luboff
@JLuboff
Apr 02 2018 20:30
That I'm not sure :D
Christopher McCormack
@cmccormack
Apr 02 2018 20:31
now that I think of it it may have been @kbaig issue that was tough to troubleshoot
Jason Luboff
@JLuboff
Apr 02 2018 20:31
It was lol
Kaz Baig
@kbaig
Apr 02 2018 20:31
I think it was prob just because of my node_modules size
JeremyHaynes310
@JeremyHaynes310
Apr 02 2018 21:34
This chatroom seems much more serious and much less drama
:)
I think I will join you guys
Brad
@bradtaniguchi
Apr 02 2018 21:37
@JeremyHaynes310 This is were the real work happens ;P
Jason Luboff
@JLuboff
Apr 02 2018 21:37
@JeremyHaynes310 Welcome
Christopher McCormack
@cmccormack
Apr 02 2018 21:46
@JeremyHaynes310 that's weird I was just thinking that after reading a couple lines in the main room
Jason Luboff
@JLuboff
Apr 02 2018 21:47
I personally can't stand the main room...
Christopher McCormack
@cmccormack
Apr 02 2018 21:49
@JLuboff agreed good questions/conversations tend to get drowned out by useless side conversations
kind of sad more people don't know about this room when they need help
Brad
@bradtaniguchi
Apr 02 2018 21:52
@JLuboff Ah that's prolly why I never saw you there hu?
JeremyHaynes310
@JeremyHaynes310
Apr 02 2018 21:59
@cmccormack Yep, rather then talk about programming, they want to argue.
Christopher McCormack
@cmccormack
Apr 02 2018 22:02
@bradtaniguchi @JLuboff too busy working! Man is a machine
Jason Luboff
@JLuboff
Apr 02 2018 22:18
@cmccormack Had to go change the lamp in a projector lol
@bradtaniguchi Yup. Always stuck to this room, helpbackend and used to go to helpfrontend but haven't for a while
Christopher McCormack
@cmccormack
Apr 02 2018 22:18
Correction, Man is a working on a machine
Jason Luboff
@JLuboff
Apr 02 2018 22:19
It has been a busy day..unfortunately haven't had to a chance for any programming