These are chat archives for FreeCodeCamp/HelpJavaScript

22nd
Jul 2017
cowCrazy
@cowCrazy
Jul 22 2017 00:22
@MCTwoDigitZero I think you can use this array.filter(function(element, index), filter can take currentElement and currentIndex as properties. Then you can use
then you can check if there is another accourrance of this element which is different from the current index. If it returns true the current element would return from the filter function, so you should remember to pick those that don't appear a second time.
I hope it helps
Nick Janne
@njanne19
Jul 22 2017 00:39
@sjames1958gm thanks for your earlier help, I moved some stuff around and now it's all working. My player is moveable, and I made the logic so it would change it's previous position back to a floor class (so it didn't have a trail), and so that the player couldn't walk through walls. Now I'm either gonna do monsters or health items next
CamperBot
@camperbot
Jul 22 2017 00:39
njanne19 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8131 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Nick Janne
@njanne19
Jul 22 2017 00:57
Is there a simple way to call n components of the same react component
Moisés Man
@moigithub
Jul 22 2017 00:58
what u mean ?
Pete Givens
@petegivens
Jul 22 2017 01:19
howdy all, can somebody help me out with writing a regex that checks for a specific range of multiple digit numbers? I know that if i wanted to match a string that began with 625-629 i could do /^62[5-9]/. But how would I do a larger range, e.g. 65100-65255?
should i do like /^65[12][0-5][0-5]/ or is there a better way?
that wouldn't even work
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:25
@petegivens are you asking if there's a way you could generalize something like this for any given range?
Pete Givens
@petegivens
Jul 22 2017 01:26
yes
i think i figured it out but it seems like a PITA
for that example i gave it would be something like /^651[0-9][0-9]|^652[0-4][0-9]|^6525[0-5]/
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:29
@petegivens https://repl.it/JdKg
Pete Givens
@petegivens
Jul 22 2017 01:30
good idea
so i'd have to take a substring that captured digits 3-5, turn them to a number and then check if they fit inside the range i'm looking at
i'm doing a credit card checking exercise, so it looks at the prefixes of credit card numbers. prefixes vary in length
i'll run with that, thanks @kumquatfelafel
CamperBot
@camperbot
Jul 22 2017 01:31
petegivens sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 517 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:34

@petegivens Actually, I'd use a little caution with this. Consider the following scenario.

you're trying to check that begins with, let's say, something in range of 5000 - 6000. So say the string is "55555". That begins with something in range of 5000-6000. However, 55555 itself is not in range of 5000-6000.

Pete Givens
@petegivens
Jul 22 2017 01:40
that would still match what i'm trying to do with it though
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:40
Now, don't get me wrong... :point_up: ... this is still something that's relatively easy to handle.
Pete Givens
@petegivens
Jul 22 2017 01:40
i would do a substring of the first 4 digits and make sure they were between 5000-6000
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:44
@petegivens so long as you have some kind of strategy in place, really
Pete Givens
@petegivens
Jul 22 2017 01:45
strategy? what's that? i just smash keys until my functions work D:
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:46
Just make sure you remove the keys before you smash them. They break better that way. :o
Pete Givens
@petegivens
Jul 22 2017 01:53
;)
John
@AnonymousLords
Jul 22 2017 01:58
hey guys
kumquatfelafel
@kumquatfelafel
Jul 22 2017 01:59
hello
王想想
@wxxxxxxxx
Jul 22 2017 01:59
hello
John
@AnonymousLords
Jul 22 2017 02:02
@wxxxxxxxx did you change your name :P
王想想
@wxxxxxxxx
Jul 22 2017 02:03
@AnonymousLords no, do not know what's going on
have you experienced 40 degrees Celsius weather?(┬_┬)
John
@AnonymousLords
Jul 22 2017 02:05
?
王想想
@wxxxxxxxx
Jul 22 2017 02:05
40
Degrees Celsius
John
@AnonymousLords
Jul 22 2017 02:06
so why change your name to japaniness
it was wxxxxxxxxxx
Is that your real name?
王想想
@wxxxxxxxx
Jul 22 2017 02:06
I am not a Japanese ... I have not changed
John
@AnonymousLords
Jul 22 2017 02:07
Why did you change your name?
王想想
@wxxxxxxxx
Jul 22 2017 02:07
I did not change! The The The The The
John
@AnonymousLords
Jul 22 2017 02:07
your gitter name
it was wxxxxxxxx
王想想
@wxxxxxxxx
Jul 22 2017 02:08
This is the Chinese name, why do you think it is Japan?
John
@AnonymousLords
Jul 22 2017 02:08
oh :P
I was just asking
王想想
@wxxxxxxxx
Jul 22 2017 02:09
very bad
John
@AnonymousLords
Jul 22 2017 02:09
i never really have seen Japanese or Chinese before
王想想
@wxxxxxxxx
Jul 22 2017 02:10
(┬_┬)
John
@AnonymousLords
Jul 22 2017 02:10
Never mind..
Joel Y.
@zapcannon99
Jul 22 2017 02:10
何?
王想想
@wxxxxxxxx
Jul 22 2017 02:10
not a lattice, a square word
John
@AnonymousLords
Jul 22 2017 02:10
:O
What does that mean :P
王想想
@wxxxxxxxx
Jul 22 2017 02:10
Box
Joel Y.
@zapcannon99
Jul 22 2017 02:11
Except I meant to say what in Japanese
John
@AnonymousLords
Jul 22 2017 02:11
is it a word?
王想想
@wxxxxxxxx
Jul 22 2017 02:11
...
Joel Y.
@zapcannon99
Jul 22 2017 02:11
Hence the confusion.
John
@AnonymousLords
Jul 22 2017 02:11
i only know of one the ways to say 1 to 19 in koren
only other langunge i know
well anything in another alngunge
王想想
@wxxxxxxxx
Jul 22 2017 02:11
Box word Chinese
John
@AnonymousLords
Jul 22 2017 02:11
means what?
王想想
@wxxxxxxxx
Jul 22 2017 02:12
You can not understand
Joel Y.
@zapcannon99
Jul 22 2017 02:13

so if it's Chinese, 何 means box

But if you were Japanese, you'd read that as What

王想想
@wxxxxxxxx
Jul 22 2017 02:13
呵呵!
John
@AnonymousLords
Jul 22 2017 02:13
im american
Joel Y.
@zapcannon99
Jul 22 2017 02:13

box-ish word in Chinese

That's what he's trying to say

John
@AnonymousLords
Jul 22 2017 02:13
okay
i know 1 to 19 in koren :P
the English pronunciations
Joel Y.
@zapcannon99
Jul 22 2017 02:14
Just saying so we can clear the confusion
lol
John
@AnonymousLords
Jul 22 2017 02:14
okay
王想想
@wxxxxxxxx
Jul 22 2017 02:14
okok
John
@AnonymousLords
Jul 22 2017 02:14
hona is 1
王想想
@wxxxxxxxx
Jul 22 2017 02:14
I am in Hangzhou
John
@AnonymousLords
Jul 22 2017 02:15
dul set net
dasoet
yasoet
ilgop
yeodeol
ahop
yeol
王想想
@wxxxxxxxx
Jul 22 2017 02:15
666
John
@AnonymousLords
Jul 22 2017 02:15
uhhh
anyways
back to coding
Joel Y.
@zapcannon99
Jul 22 2017 02:16

liu bai liu shi liu

My pin yin is bad

John
@AnonymousLords
Jul 22 2017 02:16
calculating numbers between hona and yeol-ahop
Joel Y.
@zapcannon99
Jul 22 2017 02:16
lol, agreed, but in English please
John
@AnonymousLords
Jul 22 2017 02:16
1 and 19
Joel Y.
@zapcannon99
Jul 22 2017 02:17
the sum of 1 - 19?
John
@AnonymousLords
Jul 22 2017 02:18
I am learning math.random and math.floor
anyways back to coding
Joel Y.
@zapcannon99
Jul 22 2017 02:19
You need help?
王想想
@wxxxxxxxx
Jul 22 2017 02:19
i need
John
@AnonymousLords
Jul 22 2017 02:20
Well now i do
Joel Y.
@zapcannon99
Jul 22 2017 02:20
oh merp O__O
John
@AnonymousLords
Jul 22 2017 02:20

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  Math.floor(Math.random() * 10);

  return Math.floor();
}
isnt working?
null?
random number 1 to 9
The result of randomWholeNum should be a whole number.
Should i do var randomWholeNum = Math.floor(Math.random() * 10);
nope
Joel Y.
@zapcannon99
Jul 22 2017 02:21
when Math.floor, you need to have a input to that function. Right now, you are return Math.floor of nothing.
John
@AnonymousLords
Jul 22 2017 02:21
doesnt work
okay
I got it
Joel Y.
@zapcannon99
Jul 22 2017 02:22
Math.floor(Math.random() * 10) will give you a random number between 0 and 9
John
@AnonymousLords
Jul 22 2017 02:22
var randomWholeNum = Math.floor(Math.random() * 10); worked
I needed to assign it to a varaible
@zapcannon99 thanks
Joel Y.
@zapcannon99
Jul 22 2017 02:22
yes that will work. So now you need to return that variable and you should be done
John
@AnonymousLords
Jul 22 2017 02:22
return randomWholeNum;
Thanks :D! @zapcannon99
CamperBot
@camperbot
Jul 22 2017 02:22
anonymouslords sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
王想想
@wxxxxxxxx
Jul 22 2017 02:23
🙂
Joel Y.
@zapcannon99
Jul 22 2017 02:23
Yep. Only thing else I have to comment is if you are truely trying to return a number between 1 and 9 excluding 9 but including 1, You'll need to change the expression
John
@AnonymousLords
Jul 22 2017 02:24
Yeah it had to genrate a number 1 to 9
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:24
@AnonymousLords I would also avoid having a variable with the same name as your function.
Joel Y.
@zapcannon99
Jul 22 2017 02:24
so it would be Math.floor(Math.Random() * 8 + 1)
John
@AnonymousLords
Jul 22 2017 02:24
it was really 1 to 10
@kumquatfelafel Yeah i was thinking that
Joel Y.
@zapcannon99
Jul 22 2017 02:24
lol, true dat
so @wxxxxxxxx what do you need help with?
John
@AnonymousLords
Jul 22 2017 02:25
They should make a scrambling program that makes your variables have the same name, but with slightly different spelling to confuse any hackers lol
Joel Y.
@zapcannon99
Jul 22 2017 02:25
@AnonymousLords ok, well Math.floor(Math.Random() * 8 + 1) will generate a random number between 1 and 9
John
@AnonymousLords
Jul 22 2017 02:25
okay
kumquatfelafel @kumquatfelafel is away for a bit
John
@AnonymousLords
Jul 22 2017 02:26
excluding 9 right?
Joel Y.
@zapcannon99
Jul 22 2017 02:26
yeah
John
@AnonymousLords
Jul 22 2017 02:26
Okaythanks
is :point_up: July 21, 2017 10:25 PM a good idea :? :D
Joel Y.
@zapcannon99
Jul 22 2017 02:27
not really, it'd be a good exercise to teach people what NOT to do
Otherwise, it'd be too frustrating for our eyes
John
@AnonymousLords
Jul 22 2017 02:27
It works in reality, but the program scrambles your final code so everything have the same name with different variations
so it might change every variable in your code to a variation that is slightly off from for example randomWholeNum
Joel Y.
@zapcannon99
Jul 22 2017 02:28
Sure it does, but I'd rather not do that kind of exercise. It's already bad enough that I forget the # or . when using jQuery
John
@AnonymousLords
Jul 22 2017 02:29
okay :package:
:P
John
@AnonymousLords
Jul 22 2017 02:35
Guys how does i know what the range is in this equation>? return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
Joel Y.
@zapcannon99
Jul 22 2017 02:36
(ourMax - ourMin + 1)
That's your range
John
@AnonymousLords
Jul 22 2017 02:36
why subtract?
Oh
Joel Y.
@zapcannon99
Jul 22 2017 02:37
though, I'm not sure what the + 1 is for
John
@AnonymousLords
Jul 22 2017 02:37
+1 makes it so it can decide between ourmax and ourmin
Joel Y.
@zapcannon99
Jul 22 2017 02:37
Maybe they want to add one to the range
....
John
@AnonymousLords
Jul 22 2017 02:37
because 1-9 might be 1-8
to prevnt this they add one to keep their max and min
not cut it off
Joel Y.
@zapcannon99
Jul 22 2017 02:38
I'm confused, but okay....
If it works for them, fine for them
John
@AnonymousLords
Jul 22 2017 02:38
Like here
Math.floor(Math.Random() * 8 + 1)
Joel Y.
@zapcannon99
Jul 22 2017 02:38
That is different
John
@AnonymousLords
Jul 22 2017 02:38
You add one so it isnt one to seven, so its really one to 8
But the +1 is still teh same here
Joel Y.
@zapcannon99
Jul 22 2017 02:39
I'm pretty sure order of operations still go into affect
John
@AnonymousLords
Jul 22 2017 02:39
okay
My thing is, why subtarck max and min?
Joel Y.
@zapcannon99
Jul 22 2017 02:40
Math.random() * 8 + 1 != Math.random() * (8+1)
John
@AnonymousLords
Jul 22 2017 02:40
okay
Oh i get it
if Mx is 9 and Min is 1
9-1 is 8
and the number can be 1 to 8
max 27 min 26
it has one possible number
Joel Y.
@zapcannon99
Jul 22 2017 02:41
hold on
John
@AnonymousLords
Jul 22 2017 02:41
@zapcannon99 Thanks for your support
CamperBot
@camperbot
Jul 22 2017 02:41
anonymouslords sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:warning: anonymouslords already gave zapcannon99 points
Joel Y.
@zapcannon99
Jul 22 2017 02:42
if max is 9 and min is 1
and we plug it into Math.floor(Math.random() * (max - min) + offset)
John
@AnonymousLords
Jul 22 2017 02:43
9 - 1 = 8
But what does offset do?
Is it a special command? or just a variable number?
Joel Y.
@zapcannon99
Jul 22 2017 02:43
it's just a variable
max, min, and offset are variables
John
@AnonymousLords
Jul 22 2017 02:43
Oh okay
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:43
@AnonymousLords if offset is 1, then numbers will start from 1. If it's 2, numbers will start from 2, etc
Joel Y.
@zapcannon99
Jul 22 2017 02:44
:point_up:
John
@AnonymousLords
Jul 22 2017 02:44
Math.floor(Math.random() * (9 - 1) + 2)
What would the two do in this equation as a example? i'm confused on teh offset thing
Joel Y.
@zapcannon99
Jul 22 2017 02:45
Think about order of operations
John
@AnonymousLords
Jul 22 2017 02:45
like since a range from 1 to 9 might only be 1 to 8 because 9 is excluded
Joel Y.
@zapcannon99
Jul 22 2017 02:45
Math.random() gives some number from 0 to 1
John
@AnonymousLords
Jul 22 2017 02:45
Okay
Joel Y.
@zapcannon99
Jul 22 2017 02:45
hold on, you're forgetting math.random() gives a number between 0 and 1
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:46
(and 1 is excluded from that range)
Joel Y.
@zapcannon99
Jul 22 2017 02:46
right
parenthesis are usually operated on first
so 9-1 = 8
John
@AnonymousLords
Jul 22 2017 02:46
Okay
Joel Y.
@zapcannon99
Jul 22 2017 02:46
so what is the range of 0 and 1 times 8
John
@AnonymousLords
Jul 22 2017 02:46
so 8
8x times a random decimal
Then its rounded up or down
Joel Y.
@zapcannon99
Jul 22 2017 02:47
right
John
@AnonymousLords
Jul 22 2017 02:47
thanks @zapcannon99 @kumquatfelafel @zapcannon99 @kumquatfelafel
CamperBot
@camperbot
Jul 22 2017 02:47
anonymouslords sends brownie points to @zapcannon99 and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: anonymouslords already gave zapcannon99 points
:cookie: 518 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:47
floor rounds down
John
@AnonymousLords
Jul 22 2017 02:47
Oh
Joel Y.
@zapcannon99
Jul 22 2017 02:47
not rounded, that's the job of Math.floor() which we haven't gotten to yet
John
@AnonymousLords
Jul 22 2017 02:47
Mth.floor rounds down i meant
Whats round up?
Joel Y.
@zapcannon99
Jul 22 2017 02:47
then the 2 (which would be the offset)
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:47
ceil
Joel Y.
@zapcannon99
Jul 22 2017 02:47
ceil()
John
@AnonymousLords
Jul 22 2017 02:48
is it important to round down or up?
or doe sit matter
Joel Y.
@zapcannon99
Jul 22 2017 02:48
depends on how you want to get to your solution, but most people floor it
John
@AnonymousLords
Jul 22 2017 02:48
okay
Joel Y.
@zapcannon99
Jul 22 2017 02:48
using also adds another little more complication, so forget about it for this exercise
John
@AnonymousLords
Jul 22 2017 02:49
okay
Joel Y.
@zapcannon99
Jul 22 2017 02:49
anyways, that 2 is then added to the range of 0-8 transforming it to 2 - 10
John
@AnonymousLords
Jul 22 2017 02:50
okay
Joel Y.
@zapcannon99
Jul 22 2017 02:50
so you will in the end of Math.floor(Math.random() * (9 - 1) + 2) get a number from 2 to 10 not including 10
John
@AnonymousLords
Jul 22 2017 02:50
okay thanks
Joel Y.
@zapcannon99
Jul 22 2017 02:50
Whole number that is
John
@AnonymousLords
Jul 22 2017 02:50
Yes
Joel Y.
@zapcannon99
Jul 22 2017 02:51
Cool
Kervtuza
@Kervtuza
Jul 22 2017 02:55
hey guys! Just working on a FFC challenge to build a wiki viewer...just wondering if you guys to take a second to check it out and let me know what you guys think? here is the link https://codepen.io/Kervtuza/full/owOoew/
Joel Y.
@zapcannon99
Jul 22 2017 02:56
@Kervtuza Good job. Works as intended imo.
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:56

not including 10

@AnonymousLords So just to give it another chance to sink in, the reason for 10 not being included is that the maximum value Math.random() generates is not 1 (as @zapcannon99 mentioned) but 0.99999yadayadayada so only almost 1... and the same pattern holds when you multiply it. So for example if I say Math.random() * 5, the maximum value I can get as a result is not 5, but 4.99999blahblahblah. These values, with floor, round down to 0 and 4 respectively.

John
@AnonymousLords
Jul 22 2017 02:56
Okay
Joel Y.
@zapcannon99
Jul 22 2017 02:57
@Kervtuza Only thing I have against it is being able to hit enter to start the search for my query.
John
@AnonymousLords
Jul 22 2017 02:57
@kumquatfelafel Makes a lot of sense now
But why do i see " + min" on the end of the equation?
Joel Y.
@zapcannon99
Jul 22 2017 02:57
@kumquatfelafel Thanks for clarifying for me
John
@AnonymousLords
Jul 22 2017 02:57
return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
CamperBot
@camperbot
Jul 22 2017 02:57
zapcannon99 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 519 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Joel Y.
@zapcannon99
Jul 22 2017 02:58
@AnonymousLords That, I have no idea why it's there, but it could be that they wanted offset to be placed outside the Math.floor(), which is fine. it doesn't matter when you add the offset, just as long as it doesn't get factored into the range.
John
@AnonymousLords
Jul 22 2017 02:58
var range = Math.floor(Math.random() * (myMax - myMin + 1));
Joel Y.
@zapcannon99
Jul 22 2017 02:59
so again, i'm not sure what the +1 is there for, but it's not supposed to be there
John
@AnonymousLords
Jul 22 2017 02:59
says that "The lowest random number that can be generated by randomRange should be equal to your minimum number, myMin." is wrong?
kumquatfelafel
@kumquatfelafel
Jul 22 2017 02:59
The +1 is there for the aforementioned round down I imagine.
John
@AnonymousLords
Jul 22 2017 03:00
If i do that code, it says my final number cant be equal to to myMin or myMax
Joel Y.
@zapcannon99
Jul 22 2017 03:00
@kumquatfelafel I mean sure, but all the +1 does is add 1 to the available range
John
@AnonymousLords
Jul 22 2017 03:00
Why add the Min?
Joel Y.
@zapcannon99
Jul 22 2017 03:00
so the myMin becomes your offset
John
@AnonymousLords
Jul 22 2017 03:00
why not +1
Does it make it so it can be offset from 0?
like for example 2 to 9
Joel Y.
@zapcannon99
Jul 22 2017 03:01
because that +1 (as it is now) just adds to the range so instead of a range of max-min, you now have a range of max-min+1
John
@AnonymousLords
Jul 22 2017 03:02
but then why after that add min?
Stanley Su
@stanley-su
Jul 22 2017 03:02
function randNum(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}
Joel Y.
@zapcannon99
Jul 22 2017 03:03
you mean like this?
var result = Math.floor(Math.random() * (myMax - myMin)) + myMin;
John
@AnonymousLords
Jul 22 2017 03:03
this was my example code
Joel Y.
@zapcannon99
Jul 22 2017 03:03
cuz that would give you the answer
Moisés Man
@moigithub
Jul 22 2017 03:03
if u wanna get a num between 5 and 10
John
@AnonymousLords
Jul 22 2017 03:03
that allows teh lowest and highets number, to be avaible
return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
you add +1
so you can get 5 and 10
by why add +ourMin?
afetr teh +1
Moisés Man
@moigithub
Jul 22 2017 03:04
put some values on ourMax ourMin variables.. and do math.. pen and paper...
John
@AnonymousLords
Jul 22 2017 03:04
OHHHHHHH
i get it
Joel Y.
@zapcannon99
Jul 22 2017 03:04

yeah but I took out the +1
Ok I see now what you are trying to get
ok yes,

And maybe it'll help if you do what Moises Man says to help you wrap you head around it
it's basic algebra
y=ax + b

sorta
John
@AnonymousLords
Jul 22 2017 03:05
yeah
kumquatfelafel
@kumquatfelafel
Jul 22 2017 03:06

well... let's plug in some numbers to look at it for moment.

Let's assume that myMin is 2 and myMax is 5.

Plugging in, that would give us Math.floor(Math.random() * (5 - 2 + 1)) + 2

Which becomes...

Math.floor(Math.random() * 4) + 2

Now, Math.random()*4 will give us values 0 to 3.9999... Which when we floor, gives us 0 to 3. Adding the 2 (myMin), we get a range of values from 2 to 5.

Which is a perfect match for our myMin and myMax value

Joseph
@revisualize
Jul 22 2017 03:06
Hey.
kumquatfelafel
@kumquatfelafel
Jul 22 2017 03:07
hi
Joel Y.
@zapcannon99
Jul 22 2017 03:07
ni hao
Moisés Man
@moigithub
Jul 22 2017 03:07
:wave:
John
@AnonymousLords
Jul 22 2017 03:08
@kumquatfelafel so it would be 0 - 3 range but now we can raise those by adding + 2 to get 2 - 5
Joel Y.
@zapcannon99
Jul 22 2017 03:09
:thumbsup:
John
@AnonymousLords
Jul 22 2017 03:09
Ik
Okay*
kumquatfelafel
@kumquatfelafel
Jul 22 2017 03:11
@AnonymousLords Yes. The range would only be 0 - 3 if you don't add 2 (myMin) afterwards. By adding myMin to result, you enable the generation of ranges that don't start at 0.
John
@AnonymousLords
Jul 22 2017 03:12
@kumquatfelafel okay guys thanks
CamperBot
@camperbot
Jul 22 2017 03:12
:warning: anonymouslords already gave kumquatfelafel points
anonymouslords sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
John
@AnonymousLords
Jul 22 2017 03:12
:D
Joel Y.
@zapcannon99
Jul 22 2017 03:12
Somehow, I feel like my explanations are way too long winded... T__T
Need to get better at making them shorter
John
@AnonymousLords
Jul 22 2017 03:14
You only get better with more practice :D
Joel Y.
@zapcannon99
Jul 22 2017 03:14
lol
indeed
I like making the other people think for themselves though
王想想
@wxxxxxxxx
Jul 22 2017 03:16
@zapcannon99 你是中国人?
Joel Y.
@zapcannon99
Jul 22 2017 03:16
nope, I'm American
My Chinese sucks . Hahaha.
王想想
@wxxxxxxxx
Jul 22 2017 03:17
@zapcannon99 That you will be Chinese
John
@AnonymousLords
Jul 22 2017 03:18
@zapcannon99 It helps :point_up: July 21, 2017 11:14 PM
王想想
@wxxxxxxxx
Jul 22 2017 03:18
Have you studied Chinese?
Joel Y.
@zapcannon99
Jul 22 2017 03:18
我没有
王想想
@wxxxxxxxx
Jul 22 2017 03:19
你是华侨....
Joel Y.
@zapcannon99
Jul 22 2017 03:19
I'm cheating a little and brute forcing
John
@AnonymousLords
Jul 22 2017 03:19
kinda changing teh topic, but we have to do common core in teh USA
Joel Y.
@zapcannon99
Jul 22 2017 03:19
But if you made me take an elementry school test, I'd fail really badly
John
@AnonymousLords
Jul 22 2017 03:19
Its over compliated
CallMeOrange
@EgnaroDev
Jul 22 2017 03:20
Yeah its complicated lol
John
@AnonymousLords
Jul 22 2017 03:20
Lol
CallMeOrange
@EgnaroDev
Jul 22 2017 03:20
I can solve the equation but drawing?
John
@AnonymousLords
Jul 22 2017 03:20
they taught us this
this year
CallMeOrange
@EgnaroDev
Jul 22 2017 03:20
ah
John
@AnonymousLords
Jul 22 2017 03:20
For solving simple equations
It was insianly stupid
Joel Y.
@zapcannon99
Jul 22 2017 03:20
Common Core has serious issues....
CallMeOrange
@EgnaroDev
Jul 22 2017 03:20
lol
Joel Y.
@zapcannon99
Jul 22 2017 03:20
The idea behind is good, but the material is bad
John
@AnonymousLords
Jul 22 2017 03:20
I dont even use the stupid methods on tests
Joel Y.
@zapcannon99
Jul 22 2017 03:21
Just curious, but what grade are you?
John
@AnonymousLords
Jul 22 2017 03:21
i show my work by doing the equation
uhhh
Joel Y.
@zapcannon99
Jul 22 2017 03:21
or don't answer
Maybe I shouldn't ask
kumquatfelafel
@kumquatfelafel
Jul 22 2017 03:21
20th grade! :o
John
@AnonymousLords
Jul 22 2017 03:21
its between 7th and 9th
Joel Y.
@zapcannon99
Jul 22 2017 03:21
forget it
kumquatfelafel
@kumquatfelafel
Jul 22 2017 03:21
I mean... A
王想想
@wxxxxxxxx
Jul 22 2017 03:21
so weird。。。
John
@AnonymousLords
Jul 22 2017 03:22
That leaves on grade :P..
Kervtuza
@Kervtuza
Jul 22 2017 03:22
@zapcannon99 thanks for the feedback joel! Ill add the enter button feature:)
CamperBot
@camperbot
Jul 22 2017 03:22
kervtuza sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Joel Y.
@zapcannon99
Jul 22 2017 03:22
middle school good enough, I think it's awesome you are getting into programming so early!
John
@AnonymousLords
Jul 22 2017 03:22
Yeah
Joel Y.
@zapcannon99
Jul 22 2017 03:22
@wxxxxxxxx I am
John
@AnonymousLords
Jul 22 2017 03:22
Wanted to learn it while everyone else rotted playing Overwatch
Like tehy played Over watch 24/7
Joel Y.
@zapcannon99
Jul 22 2017 03:22
@Kervtuza Just to clarify, I mean hitting the enter key on the keyboard
John
@AnonymousLords
Jul 22 2017 03:22
Thats all people play in my school, is Overwatch
Nothing useful later in life.
Joel Y.
@zapcannon99
Jul 22 2017 03:23
And it used to be LoL for me, and before that WoW
Stanley Su
@stanley-su
Jul 22 2017 03:23
used to be CS for me xd
Joel Y.
@zapcannon99
Jul 22 2017 03:23
or SCII
CSgo yeah
John
@AnonymousLords
Jul 22 2017 03:23
lol
王想想
@wxxxxxxxx
Jul 22 2017 03:23
@AnonymousLords
China is the same, the university is playing
John
@AnonymousLords
Jul 22 2017 03:23
Okay
The common core teaches you no to learn
It make syou
王想想
@wxxxxxxxx
Jul 22 2017 03:24
Are playing lol
John
@AnonymousLords
Jul 22 2017 03:24
rely off the govrment
I play FH3
manily
Joel Y.
@zapcannon99
Jul 22 2017 03:24
FH3....
FH3....
Trying to remember what that is....
....
John
@AnonymousLords
Jul 22 2017 03:24
Common core teaches thing, so you can rely on the government for answers.
They had to teach us in school to love transgenders and gays
im a catholic so...
Forza Horizon 3
Joel Y.
@zapcannon99
Jul 22 2017 03:25
ah driving
game
John
@AnonymousLords
Jul 22 2017 03:25
Yep
You play it?
Joel Y.
@zapcannon99
Jul 22 2017 03:25
no wonder I don't know the short hand, I don't play it
王想想
@wxxxxxxxx
Jul 22 2017 03:25
...
Stanley Su
@stanley-su
Jul 22 2017 03:26
You ever played Gran Turismo 3?
Joel Y.
@zapcannon99
Jul 22 2017 03:26
btw @wxxxxxxxx, you still need help?
王想想
@wxxxxxxxx
Jul 22 2017 03:26
Gay is not good
John
@AnonymousLords
Jul 22 2017 03:26
exactly
@stanley-su Nope
王想想
@wxxxxxxxx
Jul 22 2017 03:26
@zapcannon99 There is no time
John
@AnonymousLords
Jul 22 2017 03:26
I wish they put the Buagatii Vsion GT in FH3 :P
Joel Y.
@zapcannon99
Jul 22 2017 03:26
o ok
John
@AnonymousLords
Jul 22 2017 03:28
This is a common core vs reailty
Joel Y.
@zapcannon99
Jul 22 2017 03:28
Imma go float around and do some other stuff. GL on your stuff guys!
John
@AnonymousLords
Jul 22 2017 03:28
bye
王想想
@wxxxxxxxx
Jul 22 2017 03:29
bye 拜拜
Joel Y.
@zapcannon99
Jul 22 2017 03:29
Oh and as for that pic, yeah, and I remember a much different way of getting taught addition.... Yikes....
John
@AnonymousLords
Jul 22 2017 03:30
Yep
They let us use calculators on tests
王想想
@wxxxxxxxx
Jul 22 2017 03:31
😨
John
@AnonymousLords
Jul 22 2017 03:32
luckly i ignore all teh common core crap, i sit back and day dream all class because i already know how to do all of it
and get good grades
王想想
@wxxxxxxxx
Jul 22 2017 03:33
(๑•̀ㅂ•́)و✧
@AnonymousLords
You will use qq or micro letter?
John
@AnonymousLords
Jul 22 2017 03:35
?
王想想
@wxxxxxxxx
Jul 22 2017 03:36
communication tools
John
@AnonymousLords
Jul 22 2017 03:36
?
王想想
@wxxxxxxxx
Jul 22 2017 03:36
do not understand?
John
@AnonymousLords
Jul 22 2017 03:36
liek what are you talking about>
micro letter? communication tools?
王想想
@wxxxxxxxx
Jul 22 2017 03:36
qq
Joel Y.
@zapcannon99
Jul 22 2017 03:36
qq is a messaging app, he's seeing if he uses qq
John
@AnonymousLords
Jul 22 2017 03:36
micro letter?
Joel Y.
@zapcannon99
Jul 22 2017 03:37
probably another app
John
@AnonymousLords
Jul 22 2017 03:37
i use neither
王想想
@wxxxxxxxx
Jul 22 2017 03:41
@AnonymousLords What is your communication app?
John
@AnonymousLords
Jul 22 2017 03:43
phone? gitter?
why?>
why does this output 2?
var testString = "There are 3 cats but 4 dogs.";

var expression = /\d+/g;  

var digitCount = testString.match(expression).length;
王想想
@wxxxxxxxx
Jul 22 2017 03:44
So hard to communicate, I admit defeat
John
@AnonymousLords
Jul 22 2017 03:44
just use gitter
Joel Y.
@zapcannon99
Jul 22 2017 03:44
@AnonymousLords your regex match returns an array of two
John
@AnonymousLords
Jul 22 2017 03:45
why not 3 and 4?
Is it saying 2 numbers?
Joel Y.
@zapcannon99
Jul 22 2017 03:45
testString.match(expression) returns an array
The array has a length of 2
王想想
@wxxxxxxxx
Jul 22 2017 03:45
yes
John
@AnonymousLords
Jul 22 2017 03:46
@zapcannon99 Oh so it is 3, 4
but it has a length of 2?
liek theirs 2 numbers
how about this, try this code out and look at the console
Stanley Su
@stanley-su
Jul 22 2017 03:46
@AnonymousLords The array is like this:
[3, 4];
Joel Y.
@zapcannon99
Jul 22 2017 03:47
var testString = "There are 3 cats but 4 dogs.";

var expression = /\d+/g;  

console.log(testString.match(expression));
look at the console in jsfiddle or codepen
John
@AnonymousLords
Jul 22 2017 03:47
So its saying their is 2 numbers?
Joel Y.
@zapcannon99
Jul 22 2017 03:47
you have 2 results rather
John
@AnonymousLords
Jul 22 2017 03:48
Okay
2 results of numbers
How i display that array?
oh numbers
like 3, 4
when i call it
Joel Y.
@zapcannon99
Jul 22 2017 03:48
The question should be "how do you access an array?"
John
@AnonymousLords
Jul 22 2017 03:49
Oh
Okay'
Joel Y.
@zapcannon99
Jul 22 2017 03:50
although, that's only if you want to access each individual result
If you want to display the whole array you just need to call that array, and best store it in a variable.
John
@AnonymousLords
Jul 22 2017 03:50
okay
Joel Y.
@zapcannon99
Jul 22 2017 03:50
sorta like you had before
var results = testString.match(expression);
results now has the array of matches that were made in the testString.match(expression)
John
@AnonymousLords
Jul 22 2017 03:52
okay
Brad
@bradtaniguchi
Jul 22 2017 03:57
Hey for the weather app, whats the best/most useful api to get the users weather based on location
oh and free :P
and oops might be wrong channel, but the question still stands
Joel Y.
@zapcannon99
Jul 22 2017 03:58
hmmm....
maybe this?
https://www.apixu.com/api.aspx
Stanley Su
@stanley-su
Jul 22 2017 03:59
@bradtaniguchi Did you see the keyless api that freecodecamp supplied?
Brad
@bradtaniguchi
Jul 22 2017 03:59
@stanley-su thanks, maybe I should read the prompt more lol
CamperBot
@camperbot
Jul 22 2017 03:59
bradtaniguchi sends brownie points to @stanley-su :sparkles: :thumbsup: :sparkles:
:cookie: 57 | @stanley-su |http://www.freecodecamp.com/stanley-su
Joel Y.
@zapcannon99
Jul 22 2017 04:00
@stanley-su
Which keyless api?
Stanley Su
@stanley-su
Jul 22 2017 04:01
Joel Y.
@zapcannon99
Jul 22 2017 04:01
@stanley-su Yeah, that's not in the original material. I couldn't sign up for the beta, so I had to make do with using their original stuff.
Stanley Su
@stanley-su
Jul 22 2017 04:02
@zapcannon99 It is now.
Joel Y.
@zapcannon99
Jul 22 2017 04:02
what is now? I can sign up for the beta?
Confused.
Stanley Su
@stanley-su
Jul 22 2017 04:05
@zapcannon99 The link I sent is in the original material now.
Joel Y.
@zapcannon99
Jul 22 2017 04:06
I legit don't see it
image.png
Stanley Su
@stanley-su
Jul 22 2017 04:08

@zapcannon99 Yeah it’s strange, that happened with someone else who I tried to tell. Probably a glitch with FCC. For me, I have this message regarding API usage:

Note: Many internet browsers now require an HTTP Secure (https://) connection to obtain a user's locale via HTML5 Geolocation. For this reason, we recommend using HTML5 Geolocation to get user location and then use the freeCodeCamp Weather API https://fcc-weather-api.glitch.me which uses an HTTP Secure connection for the weather. Also, be sure to connect to CodePen.io via https://.

Joel Y.
@zapcannon99
Jul 22 2017 04:09
Must be a versioning issue, or maybe something in my settings
I've got mine working, but of course it uses a key, which someone may steal, but at that point, let me just cancel my subscription
Stanley Su
@stanley-su
Jul 22 2017 04:10
Same. If you’re using darksky you can reset the key.
Joel Y.
@zapcannon99
Jul 22 2017 04:11
I'll change it in the future, I remember reading in the github forums that somebody got it to work well with https://www.apixu.com/api.aspx I think
John
@AnonymousLords
Jul 22 2017 04:12
Just finsihed Basic JS thanks for all your helps guys
Joel Y.
@zapcannon99
Jul 22 2017 04:12
Congrats!
John
@AnonymousLords
Jul 22 2017 04:12
I took 80 pages of notes in my composition book, currently at 107 pages of total notes on coding.
is Object Oriented and Functional Programming hard or?
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:13
I'm going mad, why is .slice not preventing the original array from being modified?
John
@AnonymousLords
Jul 22 2017 04:13
it says 2 hours
Joel Y.
@zapcannon99
Jul 22 2017 04:13
OOP shouldn't be hard
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:13
does anyone know why arr.slice() would not work?
Joel Y.
@zapcannon99
Jul 22 2017 04:13
it's teaching you a programming structure that is very useful
John
@AnonymousLords
Jul 22 2017 04:13
@zapcannon99 okay
Marcus Parsons
@marcusparsons
Jul 22 2017 04:13
@Giveback007, what's your code?
Joel Y.
@zapcannon99
Jul 22 2017 04:14
:point_up:
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:14
it's 150 lines @marcusparsons
ill try to summarize it
const filler = [];
...
function futureState(currentState) {
    var cst = currentState.slice();
    var score = filler.slice();
...
John
@AnonymousLords
Jul 22 2017 04:15
I started Basic JS on June 30th, and ended today]
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:16
every time I run function futureState filler gets updated also, and I can't use filler to reset my array with premade arrays of 0
John
@AnonymousLords
Jul 22 2017 04:16
i started my front end devolpment projects on june 20th
Joel Y.
@zapcannon99
Jul 22 2017 04:18
@Giveback007 All I can say is filler is being modified somewhere else. Can you put a console.log(filler) right before and after the slice to prove that it's being changed?
@AnonymousLords Keep up the good work!
Marcus Parsons
@marcusparsons
Jul 22 2017 04:19
@Giveback007, when you slice an array without parameters, it just returns a copy of the array. I would say Joel is correct that filler is being modified elsewhere
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:20
@marcusparsons @zapcannon99
https://codepen.io/giveback007/pen/ZJzOjq?editors=0010
I set up the console.log
I checked I don't call filler anywhere else
besides the first time when I fill it with zeros, but I don't want to mutate it, I want it as a base score array
Marcus Parsons
@marcusparsons
Jul 22 2017 04:22
Why do you have passScore embedded within futureState? futureState is missing an ending } for the function
Joel Y.
@zapcannon99
Jul 22 2017 04:23
I also checked the state of filler before and after the slice, and there is no change to filler after slicing
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:24
@marcusparsons I don't want it as a global function
@marcusparsons the } is on line *121
@zapcannon99 so where could it be mutating?
Joel Y.
@zapcannon99
Jul 22 2017 04:29
your future state seems to be called 3 times after I load the page. Is that intentional?
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:29
@Giveback007 i found it it's at line 65
Joel Y.
@zapcannon99
Jul 22 2017 04:29
futureState()*
really ln 65?
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:30
@zapcannon99 no I log current state, score, and new state so it looks like it gets loged 3 times
Joel Y.
@zapcannon99
Jul 22 2017 04:30
ok fair enough.
makes sense
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:31
@zapcannon99 shouldn't .slice() prevent me from having this problem?
line 65 is the first time I'm altering score, and it's altering filler as well
Joel Y.
@zapcannon99
Jul 22 2017 04:33
I thought it should, let me see something really quick
@Giveback007 Sorry, but I have no idea why this is happening. Maybe somebody more experienced can help you.
Dovydas Stirpeika
@Giveback007
Jul 22 2017 04:37
@zapcannon99 ahh tnx anyways for trying
CamperBot
@camperbot
Jul 22 2017 04:37
giveback007 sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Ragnorak
@Rrak
Jul 22 2017 05:07
Thanks @SkyC0der
CamperBot
@camperbot
Jul 22 2017 05:07
rrak sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2183 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Jul 22 2017 05:09
@Rrak :) :+1: Good job on the quote machine, now for weather :)
Ragnorak
@Rrak
Jul 22 2017 05:09
@SkyC0der Yep weather, i would be happy if you help me in it!!
Gulsvi
@gulsvi
Jul 22 2017 05:11
I'm usually around @Rrak, happy to help if I can
Joel Y.
@zapcannon99
Jul 22 2017 05:14

@Giveback007 I think I've figured out the problem

When you spice, you are making a copy of the arrays' references that are being stored inside filler

slice*
@Giveback007
Replace this snippet right after futureState and you'll see what I'm talking about
        var cst = currentState.slice();
    var score = filler.clone();
    var test = filler.clone();
    console.log(test[0], 'test[0]');
    console.log(filler[0], 'filler[0]');
    test[0] = 1; test[1] = 1; test[2] = 1;
    console.log(test == filler);
    console.log(test[0], 'test[0]');
    console.log(filler[0], 'filler[0]');
    var ht = cst.length - 1;
    var lh = cst[0].length - 1;
Dovydas Stirpeika
@Giveback007
Jul 22 2017 05:16
@zapcannon99 hmm interesting
well I found a hacky solution:
var score = JSON.parse(JSON.stringify(filler));
@zapcannon99 oh like the arrays inside the array
Joel Y.
@zapcannon99
Jul 22 2017 05:17
yeah the arrays inside the arrays are actually references I think
so like I tried t change the whole "row" to see what happened and it did not affect filler.

This is just a guess, and somebody else can chime in

I need sleep before I mouth off too much
Maybe you can make your own clone function

Dovydas Stirpeika
@Giveback007
Jul 22 2017 05:18
@zapcannon99 yeah I think you're right
var score = JSON.parse(JSON.stringify(filler));
did the trick so I just what ever
I was so pissed :D
Joel Y.
@zapcannon99
Jul 22 2017 05:21
Lol, if you are still interested in what I did though
Array.prototype.clone = function() {
    var clone = [];
    this.forEach(function(row) {
        clone.push(row.slice());
    });
    return clone;
}

// </main>
function futureState(currentState) {
    var cst = currentState.slice();
    var score = filler.clone();
    var ht = cst.length - 1;
    var lh = cst[0].length - 1;
See if this helps I think it should
and if it doesn't, well, at least you have something that works
Dovydas Stirpeika
@Giveback007
Jul 22 2017 05:22
@zapcannon99 ahh good
I'll try it tomorow
Joel Y.
@zapcannon99
Jul 22 2017 05:22
tell me if it works tomorrow
I need zzzzzzzzzzzzzzzz
Dovydas Stirpeika
@Giveback007
Jul 22 2017 05:22
I should go to sleep now i've been up for 30 hours now
Ryan Williams
@Ryanwfile
Jul 22 2017 05:43
Can someone with React experience explain where is the best lifecycle method to put the this.setState method if I want to constantly re render the state every second, one codepen I found uses the renderNext method which I can't find anywhere in the React documentation.
Jianhao Tan
@jaanhio
Jul 22 2017 06:06

May i know what is the difference between the 2 statements below?

class Login extends Component

vs

class Login extends React.Component
Ryan Williams
@Ryanwfile
Jul 22 2017 06:08
@jaanhio I'm not sure but I think only the class Login extends React.Component is valid, I've never seen the first version used
Jianhao Tan
@jaanhio
Jul 22 2017 06:08
@Ryanwfile im actually using the first version and its working fine. hence the confusion :worried:
wondering if theres any differences under the hood that im not aware of
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:16
If I click a button, does that action remains in memory of the button? that is if I press the button again the instructions in the button will be executed twice instead of once??
Ogundele Olumide
@Lumexralph
Jul 22 2017 06:19
@shubhamsrkdev it's not in memory, there's an event loop, that keeps track of events in the program, if you click a button, a click event is added to the event loop, then executed with the handler attached to it. if you click more than once, that event is added to the event queue and executed one after the other
@jaanhio depends if you're referring to react or VanillaJS
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:21
@Lumexralph Is there any way I can make sure that if i a press a button the instruction on it are executed only once, so that I can reuse the button?
Ogundele Olumide
@Lumexralph
Jul 22 2017 06:22
@shubhamsrkdev you want the button to only execute once?
@shubhamsrkdev and what do you mean by reusing the button ?
JustCodeItBen
@JustCodeItBen
Jul 22 2017 06:23

https://beta.freecodecamp.com/en/challenges/basic-javascript/record-collection

Not sure what is causing an error on the second test

function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== "") {
    collection[id][prop] = value;
  } else if (prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  } else if (prop === "tracks" && !collection[id].hasOwnProperty(prop)) {
    collection[id][prop] = [];
    collection[id][prop].push(value);
  } else {
    delete collection[id][prop];
  }

  return collection;
}
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:26
@Lumexralph I am making the simon game, the problem is when the player press the button for the first time it works fine, but when it is pressed again, the instruction in the button are executed twice instead of once. I want to reuse the buttons in the sense, If i press a button the instructions in it are executed only once, independent of how many times the button was pressed before.
Ogundele Olumide
@Lumexralph
Jul 22 2017 06:27
@shubhamsrkdev what do you want the button to do exactly? only to execute an instruction once, right?
nothing more?
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:30

See this is the code:

$("#1").on("click", function() {
      smarray.push(1);
      count = count + 1;
      alert(smarray);
      valor();
    });
    $("#2").on("click", function() {
      smarray.push(2);
      count = count + 1;
      alert(smarray);
      valor();
    });
    $("#3").on("click", function() {
      smarray.push(3);
      count = count + 1;
      alert(smarray);
      valor();
    });
    $("#4").on("click", function() {
      smarray.push(4);
      count = count + 1;
      alert(smarray);
      valor();
    });

You see when the button 1 is pressed once the the instruction are executed once (count=1),but when its is pressed again the instruction is executed twice(count=3), I want them to execute the instruction only once(count=2).

Ogundele Olumide
@Lumexralph
Jul 22 2017 06:32
@shubhamsrkdev you need to add a conditional statement in the button 1 event handler, saying if count is more than 1 to return undefined or simply return, nothing happens that way
@shubhamsrkdev something like this
$("#1").on("click", function() {
      if(count > 1) return;   // won't do anything
      smarray.push(1);
      count = count + 1;
      alert(smarray);
      valor();
    });
@shubhamsrkdev remember what return does ? gives a value on it's right or undefined if no value is provided and exits the function
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:35
@Lumexralph But I want the count to increase atleast once i.e. count may increase to 20 but the increase in count must be only 1 per click.
Ogundele Olumide
@Lumexralph
Jul 22 2017 06:38
@shubhamsrkdev how will count get to 20 if you want them to work only once and you have how many buttons?
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:41
I want them to work only once "per click" there will be several clicks on the same button
Ogundele Olumide
@Lumexralph
Jul 22 2017 06:45
@shubhamsrkdev i'm not getting you, the button will always happen once per click cos the they're all queued up in the event queue and executed one at a time by the event loop, probably there's something you're saying I'm not getting
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 06:46
You can try playing the game you will get ton know what is wrong: https://codepen.io/shubhamsrkdev/full/xrveEV/
Ogundele Olumide
@Lumexralph
Jul 22 2017 06:48
@shubhamsrkdev i'm sorry bro I'm in the middle of something and might not have the time required to analyze your code, but you can still try to expatiate what you want to exactly happen
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 07:09
I think I am unable to explain the problem @Lumexralph Thank you for helping !
CamperBot
@camperbot
Jul 22 2017 07:09
shubhamsrkdev sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2043 | @lumexralph |http://www.freecodecamp.com/lumexralph
Max
@maxiwer
Jul 22 2017 07:11

Good morning to everyone. I'm stuck in "Truncate a string" task. What's wrong with my code?
function truncateString(str, num) {
var res;
if (num >= str.length) {
return res = str;
} else {
res = str.slice(0, num);
}
return res + "...";
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

Johnny
@JohnnyBizzel
Jul 22 2017 07:32
@maxiwer I think you are missing a case. What does it fail on?
Max
@maxiwer
Jul 22 2017 07:40
@JohnnyBizzel I don't know.
Johnny
@JohnnyBizzel
Jul 22 2017 07:44
@maxiwer What tests does it fail on?
Johnny
@JohnnyBizzel
Jul 22 2017 07:58
@maxiwer I can't find a problem.
Johnny
@JohnnyBizzel
Jul 22 2017 07:59
@maxiwer I ran your code and it works :+1:
@maxiwer Проблем не найдено
Viktor Tiutiun
@vittorioVT
Jul 22 2017 08:05
@JohnnyBizzel the first two points of the task do not pass @maxiwer
show for me
Johnny
@JohnnyBizzel
Jul 22 2017 08:06
@vittorioVT Which tests?
@JohnnyBizzel code displayed two characters more
Johnny
@JohnnyBizzel
Jul 22 2017 08:11
@maxiwer On the first test, the whole string should add to 11 chars "A-tisket...".
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:11
@maxiwer if the string is 3 characters or under, then they want you to display full string + the ...
actually, lemme recheck instructions fast
Johnny
@JohnnyBizzel
Jul 22 2017 08:12
@maxiwer
if(str.length > num) {
    str = str.slice(0, num -3 );
@kumquatfelafel correct
Dan Couper
@DanCouper
Jul 22 2017 08:14
Also, you're adding the ... every time, that's not what it asks for @maxiwer
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:15
small correction to what I said, won't necessarily be full string. However, the ... itself is not counted in string length for truncation purposes (when num <= 3)
Max
@maxiwer
Jul 22 2017 08:15
OK.)
@JohnnyBizzel BTW how do you know Russian?
Johnny
@JohnnyBizzel
Jul 22 2017 08:16
@maxiwer ya chitaiu po-Russky yizik
Viktor Tiutiun
@vittorioVT
Jul 22 2017 08:16
з гуглом наверное? :smile:
Johnny
@JohnnyBizzel
Jul 22 2017 08:18
Niet. Ja idiot ha klase, dlya 2 let.
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:19
@DanCouper look closer. In case of num being greater than string length they weren't adding ... Which is what's needed here. That being said, the assignment in the return statement wasn't necessary.
Viktor Tiutiun
@vittorioVT
Jul 22 2017 08:19
@JohnnyBizzel don't be offended
Johnny
@JohnnyBizzel
Jul 22 2017 08:20
@vittorioVT Still learning! ;)
Max
@maxiwer
Jul 22 2017 08:24
@kumquatfelafel But anyway it's worked when I added three dots.
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:24
@maxiwer Essentially, you need to handle num is <= 3 differently than when num > 3. When num > 3, you include the ... in the length of the new string. So for example if num was 5, and you had the string "Hello World", the truncated version would be `"He..."
Dan Couper
@DanCouper
Jul 22 2017 08:24
@kumquatfelafel I maybe didn't describe that quite right but: truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket".
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:27
if (num >= str.length) {
  return res = str;
}
I know. Their code handled this scenario :point_up:
It looks a bit like just an assignment, but it's a return statement.
Dan Couper
@DanCouper
Jul 22 2017 08:30
Oh crap you're right I missed the return. That's p bad code, but fair enough
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:30
I skipped over it at first as well. The res = bit should not be in there even though it doesn't technically break anything. :p
Dan Couper
@DanCouper
Jul 22 2017 08:31
How does that not return undefined?
Can't figure out the logic of why that works
Pieter Stokkink
@forkerino
Jul 22 2017 08:33
Maybe for the same reason a = b = 1 works?
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:36

you can actually use assignment operator all over the place. Here's not many examples, but a couple, because I am lazy.

https://repl.it/Jd0l

Dan Couper
@DanCouper
Jul 22 2017 08:36
But that's still assignment - here it's returning assignment it looks like, but obviously isn't otherwise it wouldn't work.
Pieter Stokkink
@forkerino
Jul 22 2017 08:37
Dan Couper
@DanCouper
Jul 22 2017 08:38
I wish it would just error on those examples, is confusing as hell
Pieter Stokkink
@forkerino
Jul 22 2017 08:40
the short answer is that the assignment returns the right hand value upon (successful) evaluation.
Dan Couper
@DanCouper
Jul 22 2017 08:45
Yeah that makes sense. Suppose needed in certain circumstances,
kumquatfelafel
@kumquatfelafel
Jul 22 2017 08:52
To make it throw errors in certain instances, but not others where you are essentially doing the same thing, is to invite over-complication/inconsistency into the definition of the assignment operator.
shivam gupta
@shivamg11000
Jul 22 2017 08:58

why

const reducer = (state=[],action) => {
  return state;
}

console.log(reducer(undefined,"lol"));

gives -> []
and

const reducer = (state,action) => {
  return state;
}

console.log(reducer(undefined,"lol"));

gives -> undefined

Dan Couper
@DanCouper
Jul 22 2017 08:59
You're saying if the the state is undefined, use [] in the first one
shivam gupta
@shivamg11000
Jul 22 2017 09:01
I am saying why first one gives empty array on the console
and
second one gives undefined on consol
Dan Couper
@DanCouper
Jul 22 2017 09:01
You're saying if the the state is undefined, use [] in the first one
shivam gupta
@shivamg11000
Jul 22 2017 09:01
well second one is clear but not the first one
Dan Couper
@DanCouper
Jul 22 2017 09:01
state = []
shivam gupta
@shivamg11000
Jul 22 2017 09:02
but undefined is passed
Dan Couper
@DanCouper
Jul 22 2017 09:02
If the state is undefined, use []
shivam gupta
@shivamg11000
Jul 22 2017 09:02
it should give undefined
Dan Couper
@DanCouper
Jul 22 2017 09:02
If the state is undefined, use []
shivam gupta
@shivamg11000
Jul 22 2017 09:02
and when passed null or NaN as argument it gives the null, NaN respectively
Dan Couper
@DanCouper
Jul 22 2017 09:03
Yes, but if it is undefined, it uses []
shivam gupta
@shivamg11000
Jul 22 2017 09:03
why not same for NaN or null
Dan Couper
@DanCouper
Jul 22 2017 09:05
Because that is what it is designed to do? Also note NaN should never get passed as an explicit parameter, it is always caused by something else, so you always want to see NaN of islt has happened
Why would you expect NaN to have the same behavior as undefined btw?
shivam gupta
@shivamg11000
Jul 22 2017 09:07
all means nothing in some way
null, NaN
Dan Couper
@DanCouper
Jul 22 2017 09:09
NaN doesn't, means something not nothing.
shivam gupta
@shivamg11000
Jul 22 2017 09:09
like
Pieter Stokkink
@forkerino
Jul 22 2017 09:11
null is an intentional absence of a value. So at least there's something intentional there.
kumquatfelafel
@kumquatfelafel
Jul 22 2017 09:11
@shivamg11000 NaN and null are values that must be explicitly assigned or reached by playing with something else that has been defined. undefined is the value of any variable that has not been initialized (though it can also be explicitly assigned as well).
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:13
@shivamg11000 you understand how default parameters work right?
Hello Everybody :wave:
kumquatfelafel
@kumquatfelafel
Jul 22 2017 09:13
hey
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:13
@forkerino Bro!
@kumquatfelafel what's up?
Dan Couper
@DanCouper
Jul 22 2017 09:14
:point_up: just because they are falsey values doesn't mean they have the same behaviour. undefined triggers default values, this how they are designed to work @shivamg11000
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:14
@forkerino to be honest, the fun part of JS is actually out of the browser environment in my opinion
kumquatfelafel
@kumquatfelafel
Jul 22 2017 09:14
@Lumexralph Well... I just realized it's 5 am.... but at least it's saturday :laughing:
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:15
@kumquatfelafel i know what that means
Pieter Stokkink
@forkerino
Jul 22 2017 09:26
@Lumexralph :wave: It is mindblowing to realize you can do server side too. It is also mindblowing to know you can build native cross platform desktop apps that can run independent of the user's browser (Atom was build with Electron, as are VSCode, Slack and a bunch of other great apps)
Kelechi Chinaka
@ke1echi
Jul 22 2017 09:31
hi guys
what logic can i use to remove numbers that includes 5 [1,2,5,7,15] ==> [1,2,7]
:wave: @Lumexralph @forkerino
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:34
@forkerino wow! seriously?
@kelechy you mean any that contains 5? i think modulo will help
@kelechy filter the array using modulo, though your question is not very clear, if it's number divisible by 5 ? i'll say use modulo with filter
@kelechy except there's more to it
Pieter Stokkink
@forkerino
Jul 22 2017 09:37
@kelechy you also want to remove '52' for example?
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:37
@forkerino anything close in JS to list comprehension in Python ?
Pieter Stokkink
@forkerino
Jul 22 2017 09:41
@Lumexralph I don't think so
Ogundele Olumide
@Lumexralph
Jul 22 2017 09:43
@forkerino I'm thinking what list comprehension could do in Python was broken down to map, reduce, filter in JS :smile:
Pieter Stokkink
@forkerino
Jul 22 2017 09:44
I guess so
Bashir Harrell
@bookofbash
Jul 22 2017 10:02
I have some information from my API, I want to use that information to append html to different divs, but instead it appends a list of information to the div.
Driving me nuts
heroiczero
@heroiczero
Jul 22 2017 10:06
@bookofbash what information are you looking from in twitch?
@bookofbash are you looking for a description?
Bashir Harrell
@bookofbash
Jul 22 2017 10:07
Looking for json.stream==null
So I can append Online or offline into my details div
heroiczero
@heroiczero
Jul 22 2017 10:10
@bookofbash it should be data.stream==null since you are using function(data)
@bookofbash anddata.url for your second getJSON
Bashir Harrell
@bookofbash
Jul 22 2017 10:13
    $.getJSON("https://wind-bow.glitch.me/twitch-api/streams/"+streamers[i], function(data){
        console.log(data);
            if(data.stream==null){
        $(".details").append("<p class=offline>Offline</p>")
            }    else{
        $(".details").append("<a href="+json.url+">Online</a>")    
            }
        })
Thats what I originally had
pilling json.url from the first api call
shivam gupta
@shivamg11000
Jul 22 2017 10:14

why

{} === {}

gives false

Pieter Stokkink
@forkerino
Jul 22 2017 10:14
@shivamg11000 each object stands on its own.
shivam gupta
@shivamg11000
Jul 22 2017 10:14
what
Bashir Harrell
@bookofbash
Jul 22 2017 10:14
@heroiczero because there is no data.url
Pieter Stokkink
@forkerino
Jul 22 2017 10:15
@shivamg11000 If you assign an object to two variables, you can compare:
var a = {}
var b = a
a === b // true
@shivamg11000 but normally every single object is unique
even if their contents are the same
shivam gupta
@shivamg11000
Jul 22 2017 10:17
js is crap language
Bashir Harrell
@bookofbash
Jul 22 2017 10:19
hahahah
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:20
In @forkerino 's case, the references are being compared. Not the values of the object.
If you make changes to a, they will reflect in b and vice versa
shivam gupta
@shivamg11000
Jul 22 2017 10:20
yeah
how am I supposed to check for empty object
Pieter Stokkink
@forkerino
Jul 22 2017 10:25
@shivamg11000 One way is to use Object.getOwnPropertyNames(obj) and see if the resulting array has length 0
or Object.keys(obj)
shivam gupta
@shivamg11000
Jul 22 2017 10:31
ok
Bashir Harrell
@bookofbash
Jul 22 2017 10:31
@heroiczero I figured out my issue, kind of. But I dont have a solution. the .data, does not know where to append. It is appending everything on details, but what I want it to do is to append only on the correct <div class="details> which is related to .json
How can I make the code in the second API call understand where to .append
I know I am kind of talking to myself. Getting my ideas out
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:34
Object.prototype.isEmpty = function(){
  return Object.keys(this).length === 0 && this.constructor === Object
}

let a = {};
let b = {a};
console.log(a.isEmpty()) // true
console.log(b.isEmpty()) // false
console.log(b.a.isEmpty()) // true
@bookofbash You have codepen for this?
Pieter Stokkink
@forkerino
Jul 22 2017 10:37
@SweetCodingInc nice. Can you explain to me why the this.constructor === Object is necessary?
Bashir Harrell
@bookofbash
Jul 22 2017 10:37
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:37
@forkerino Hold on...
Bashir Harrell
@bookofbash
Jul 22 2017 10:37
Im making slow progresss
Pieter Stokkink
@forkerino
Jul 22 2017 10:37
I got time @SweetCodingInc
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:42
@forkerino So, if you, subclass something, and don't have that constructor check, it will return true
Example
let X  = new Object();

function Y(){

}

Y.__proto__ = X;
we're subclassing with X
Now, you've extended Y, so prototype of X has become prototype of Y
This, although doesn't have it's OwnProperties is not a representative of true empty object
it belongs to something.
Object.prototype.isEmpty = function(){
  return Object.keys(this).length === 0 && this.constructor === Object
}

let X = new Object();

function Y(){

}

Y.__proto__ = X;

let y = new Y;

let a = {};
let b = {a};
console.log(a.isEmpty()) // true
console.log(b.isEmpty()) // false
console.log(b.a.isEmpty()) // true

console.log(X.isEmpty()) //true

console.log(y.isEmpty()) // false
if you remove the constructor check, the last statement would yield to true
back to @bookofbash
can you give some more info on what are you trying to achieve?
Pieter Stokkink
@forkerino
Jul 22 2017 10:46
@SweetCodingInc ty, I will study this a bit.
CamperBot
@camperbot
Jul 22 2017 10:46
forkerino sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 146 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
Bashir Harrell
@bookofbash
Jul 22 2017 10:50
@SweetCodingInc I want to display online/offline depending the info i get back from data.stream. I have a div with the class ="details", I want the online/offline displayed there
Jianhao Tan
@jaanhio
Jul 22 2017 10:51

May i know what is the difference between the 2 statements below?

class Login extends Component

vs

class Login extends React.Component
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:51
@bookofbash First thing, this is wrong
$("this").append("<p class=offline>Offline</p>");
Bashir Harrell
@bookofbash
Jul 22 2017 10:51
It seems that because I use two API calls I have no reference of where to put online/offline. SO I am getting it displayed in a list for each
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:51
it will query your DOM to look for <this></this>
I was playing with stuff this is here i am now
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:52
Second thing is. this will be instance of $.getJSON in your case
I see.. I got your problem
hold on...
@bookofbash

get rid of this part

$("#names").append(
                "<div class=card><div id=names><p><a href=" +
                    json.url +
                    ">" +
                    json.name +
                    "</a></p></div><div id=logos><img src=" +
                    json.logo +
                    "></div><div class=details>Detail</div></div>"
            );

and refactor it to

var newContent = $("<div class=card><div id=names><p><a href=" +
                    json.url +
                    ">" +
                    json.name +
                    "</a></p></div><div id=logos><img src=" +
                    json.logo +
                    "></div><div class=details>Detail</div></div>")
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 10:58
then inside your 2nd $.getJSON, update this part
if (data.stream == null) {
  $(".details").append("<p class=offline>Offline</p>");
} else {
  $(".details").append("<p><a href=" + json.url + ">Online</a></p>");
}
to
if (data.stream == null) {
    newContent.find(".details").append("<p class=offline>Offline</p>");
} else {
    newContent
        .find(".details")
        .append("<p><a href=" + json.url + ">Online</a></p>");
}
$("#names").append(newContent);
I forked your pen and updated it to reflect these changes
Take a look
Bashir Harrell
@bookofbash
Jul 22 2017 11:00
Wow, so readable too. I learned a few things today
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:00
:+1:
Bashir Harrell
@bookofbash
Jul 22 2017 11:01
You have a link for .find?
@SweetCodingInc Thank you!
shivam gupta
@shivamg11000
Jul 22 2017 11:05

how to put

     todoApp
     |_todos
     | |_todo
     |_visibilityFilter

in HTML exactly

WAINGOR
@WAINGOR
Jul 22 2017 11:06
HI all, I have a question : if I were to write the function below, and nest 10 functions within that function ( thus with the 10th function having 10 parents): will the deepest function still be able to use the parameters "testPara1" and "testPara2"?
var X  = function (testPara1, testPara 2) {
}
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:10
@bookofbash jQuery.find
@WAINGOR Yes. Definitely

only thing is, this code

var X  = function (testPara1, testPara 2) {
}

wiil throw a syntax error

testPara 2 should be testPara2
Without a space
WAINGOR
@WAINGOR
Jul 22 2017 11:11
@SweetCodingInc so basically no matter how much the "distance" in ancestry, parameters will always be passed on? Yeah good one :D
Pieter Stokkink
@forkerino
Jul 22 2017 11:11
@WAINGOR one proviso would be that none of the functions in between have parameters that share the same name
obviously
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:12
Yeah.. You're right @forkerino
WAINGOR
@WAINGOR
Jul 22 2017 11:12
@forkerino thnx, I am beginning to wonder if you are not a bot built into gitter
CamperBot
@camperbot
Jul 22 2017 11:12
waingor sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2887 | @forkerino |http://www.freecodecamp.com/forkerino
WAINGOR
@WAINGOR
Jul 22 2017 11:12
btw
Pieter Stokkink
@forkerino
Jul 22 2017 11:12
@WAINGOR dude, we met
WAINGOR
@WAINGOR
Jul 22 2017 11:12
:D
Pieter Stokkink
@forkerino
Jul 22 2017 11:12
you simply cannot shake hands with a bot
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:13
dating?
Pieter Stokkink
@forkerino
Jul 22 2017 11:13
lol
WAINGOR
@WAINGOR
Jul 22 2017 11:13
@forkerino well, cyborgs are already a fact so who says U aren't one ;)
Pieter Stokkink
@forkerino
Jul 22 2017 11:13
coding meetup
@WAINGOR the salmon I just ate
WAINGOR
@WAINGOR
Jul 22 2017 11:13
I will give you the benefit of the doubt XD
Pieter Stokkink
@forkerino
Jul 22 2017 11:16
@SweetCodingInc one more question re: the __proto__ of earlier. If you subclass a class, how would that make the object not empty? i.e. why should your last line console.log(y.isEmpty()) output false?
@WAINGOR thanks
CamperBot
@camperbot
Jul 22 2017 11:16
forkerino sends brownie points to @waingor :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @waingor |http://www.freecodecamp.com/waingor
WAINGOR
@WAINGOR
Jul 22 2017 11:16
OMG MY PILE OF BROWNY DOUGH IS HUGE, @forkerino EAT YOUR HEART OUT WHILE I BAKE MYSELF SOME :D :D
Pieter Stokkink
@forkerino
Jul 22 2017 11:17
:P
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:24
@forkerino Consider this example where we're implementing prototype chain kinda inheritance (that is without using __proto__)
Object.prototype.isEmpty = function(){
  return Object.keys(this).length === 0 && this.constructor === Object
}


function Base(){
  this.test = 'Test';
}

var base = new Base();

console.log(base.test);

function Child(){

}

Child.prototype = new Base();

var child = new Child();

console.log(child.test);

console.log(base.isEmpty()) // false 
console.log(child.isEmpty()) // false
now, although the Child class constructor is empty, we are inheriting, test property from Base
so, the child which is an instance of Child is not truly empty
console.log(child.test); still yields Test
which is defined in Base constructor
If you get rid of && this.constructor === Object then console.log(child.isEmpty()) will be true
which should not be the case
Pieter Stokkink
@forkerino
Jul 22 2017 11:26
yeah, gotcha!
Ragnorak
@Rrak
Jul 22 2017 11:27
@SweetCodingInc I dont need any weed to get high, you example is enough :smile:
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:27
aww
Ragnorak
@Rrak
Jul 22 2017 11:29
What does .prototype does exactly and how is that diffrent from new
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:30
That sounds like a tricky question because new and prototype have nothing in common to begin the comparison :D
Pieter Stokkink
@forkerino
Jul 22 2017 11:30
@SweetCodingInc thanks for elaborating. I understand what you wrote, but still find it strange that in the previous example it would say that y is not empty, because the prototype X is also empty in that case. Would it be an option to recursively call isEmpty to test if the prototype is Empty?
CamperBot
@camperbot
Jul 22 2017 11:30
forkerino sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: forkerino already gave sweetcodinginc points
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:31
@forkerino Yeah.. My bad.. I should not have brought up that __proto__ thing the way I did
I could have come up with clearer example.. but my bad
@forkerino the constructor check is put in place precisely to avoid recursive traversal up the prototype chain
Pieter Stokkink
@forkerino
Jul 22 2017 11:43
@SweetCodingInc ok, but the question I asked is: is it possible for an object to be empty, when its constructor is not Object. Your first example suggested that this can be the case (when the prototype doesn't have any properties). I understand one rarely has an empty prototype if specifically assigned so it might be mere intellectual masturbation, but perhaps you can give a theoretical answer... ?
WAINGOR
@WAINGOR
Jul 22 2017 11:46
Hi all, can someone see what's wrong with my syntax? I am at wherefore art thou , intermediate algo challenges
function whatIsInAName(collection, source) {
  // "What's in a name? that which we call a rose
  // By any other name would smell as sweet.”
  // -- by William Shakespeare, Romeo and Juliet

  var sourceKeys = Object.keys(source);
  var newAr = collection.filter(function(obj){
    return sourceKeys.map(function(i){
       return obj.hasOwnProperty(i) && collection[i] === source[i];   
       })
        .reduce(function(accu,current){
        return accu && current;
            });
  });
  return newAr;
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:47

Theoretically, you're right. An object can be empty when it's constructor is not "directly" Object.

But then again, practically speaking, if the properties are not to be shared, why bother implementing prototype chain in the first place.

@WAINGOR missing the last } perhaps
WAINGOR
@WAINGOR
Jul 22 2017 11:49
@SweetCodingInc Im afraid thats not it...
Pieter Stokkink
@forkerino
Jul 22 2017 11:51
@SweetCodingInc understood
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 11:53
@WAINGOR There is no syntax error that I can see
WAINGOR
@WAINGOR
Jul 22 2017 11:54
@SweetCodingInc the silly thing is, I passed this challenge with a for in loop and this is actually the code that I tried to memorize from the hints... Even when I compare the 2 I cant find an error
it just returns an empty array idk why
the .map seems to function it returns an array full of booleans
as it should
would you mind elaborating?
Pieter Stokkink
@forkerino
Jul 22 2017 11:57
@WAINGOR maybe use .every instead of your .map
@WAINGOR btw I think I see the error
WAINGOR
@WAINGOR
Jul 22 2017 11:58
: o
Pieter Stokkink
@forkerino
Jul 22 2017 11:59
no I don't
:smile:
WAINGOR
@WAINGOR
Jul 22 2017 11:59
its a tricky one
Pieter Stokkink
@forkerino
Jul 22 2017 11:59
I see the error in my ways
Jianhao Tan
@jaanhio
Jul 22 2017 11:59
anyone able to help me with React questions?
Pieter Stokkink
@forkerino
Jul 22 2017 11:59
blah
Moisés Man
@moigithub
Jul 22 2017 12:00
collection is an array of objects
i is a object property name like "name" ?
u doing myCollectionArray["name"] i think (to access array elements it uses numeric indices)
return obj.hasOwnProperty(i) && obj[i] === source[i]; <-- should be ? @WAINGOR
Jianhao Tan
@jaanhio
Jul 22 2017 12:02
class Calculator extends React.Component {
  constructor(props) {
    super(props);
    this.handleChange = this.handleChange.bind(this);
    this.state = {temperature: ''};
  }

  handleChange(e) {
    this.setState({temperature: e.target.value});
  }

  render() {
    const temperature = this.state.temperature;
    return (
      <fieldset>
        <legend>Enter temperature in Celsius:</legend>
        <input
          value={temperature}
          onChange={this.handleChange} />
        <BoilingVerdict
          celsius={parseFloat(temperature)} />
      </fieldset>
    );
  }
}

i am slightly confused as to how the data flows. i understand that whenever there is an input, onChange will trigger handleChange(), which will in turn set the state based on the target.value.

my question is, wouldn’t target.value be getting the value, which will in turn be equal to the {temperature}, which will be equals to the this.state.temperature which is ‘’?

telepylus
@telepylus
Jul 22 2017 12:04

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === name) {
   if (contacts[i].hasOwnProperty(prop)) {
  return contacts[i][prop];     
} 
    if (contacts[i].firstName !== name) {
    return "no such contact";
  }

  if (contacts[i].prop !== prop) {
   return ("no such property");
 }
 }
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Pieter Stokkink
@forkerino
Jul 22 2017 12:04
@WAINGOR @moigithub has a point. collection is the array
telepylus
@telepylus
Jul 22 2017 12:04
I have half of it right, but am confused what is wrong with the second half of it.
Pieter Stokkink
@forkerino
Jul 22 2017 12:07
@jaanhio e is the event, so you can think of it like the value it has after the event of typing in a letter. It will then put this in the state and on the next render the value of the input box will be the new value.
@telepylus what will your function return if the first contact doesn't match?
Roxroy
@roxroy
Jul 22 2017 12:08
@telepylus , for "no such contact"; you don't need the if condition. If it goes through the loop without finding a the name then it is not in the list.
@telepylus, move if (contacts[i].prop !== prop) logic in the for loop. If the name matches then check for the property.
Jianhao Tan
@jaanhio
Jul 22 2017 12:10
@forkerino ok am i right to say the flow of info goes like this?
setState with e.target.value -> const temperature will then hold the new value that is set-> value will then hold the new temperature value?
Vivek Ranjan
@vivekranjan92
Jul 22 2017 12:11
hi anyone know about kibana??
Pieter Stokkink
@forkerino
Jul 22 2017 12:11
@jaanhio yeah, kind of. The thing you mustn't forget is that the DOM will be updated. The value of the input box will be the same as temperature, but when you change it, it fires of the sequence you just mentioned.
Jianhao Tan
@jaanhio
Jul 22 2017 12:12
@forkerino i see. thank you so much!
CamperBot
@camperbot
Jul 22 2017 12:12
jaanhio sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2888 | @forkerino |http://www.freecodecamp.com/forkerino
Jianhao Tan
@jaanhio
Jul 22 2017 12:13

oh yes one more question, is there any difference between

class Login extends React.Component

VS

class Login extends Component

?

i used the first method in codepen and second method when building via atom with the import React, {Component} from “react” "

Pieter Stokkink
@forkerino
Jul 22 2017 12:14
@jaanhio well, in the second case you have to make sure to import { Component } from 'react'
Jianhao Tan
@jaanhio
Jul 22 2017 12:15
@forkerino ok got it. cant thank you enough @forkerino . really
Pieter Stokkink
@forkerino
Jul 22 2017 12:15
no problem
@jaanhio in codepen you cannot really use import properly, so it only automatically imports the default (React in this case)
AmelZekovic
@AmelZekovic
Jul 22 2017 12:17
hi, can somebody please tell me what am i doing wrong here https://jsfiddle.net/2jt0o7xx/2/
it should take the user input and calculate the volume of cuboid, but for some reason it is not working
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 12:18
@forkerino Actually, In 2nd case, it should be import React, { Component } from 'react'
Jianhao Tan
@jaanhio
Jul 22 2017 12:18
@SweetCodingInc does it work if its
import React from ‘react;
import {Component} from ‘react’;
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 12:19
@jaanhio Correct...
You must have React and Component imported (in some way) to use 2nd method
Pieter Stokkink
@forkerino
Jul 22 2017 12:20
@SweetCodingInc yeah, I was just brief
Jasper
@Jasperaine
Jul 22 2017 12:21
Hello please could somebody help me. I cant get the random search to work on my wiki API app https://codepen.io/Jasperaine/pen/RgyReB
Pieter Stokkink
@forkerino
Jul 22 2017 12:22
@AmelZekovic your function parameters mask the global variables. If you don't want to pass in the variables, you can either leave them out, or get them dynamically inside the function.
Also do something with the return value
Now you return it, but what do you do with it?
@Jasperaine you don't have an event handler for that button, so I don't really know what you expect to happen.... Most people just use a regular link to the random article page
AmelZekovic
@AmelZekovic
Jul 22 2017 12:25
@forkerino and how do i do that?
Benjamin Pitts
@Darkweld
Jul 22 2017 12:26
Does a Promise return instantly on a resolve?
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 12:26
@Darkweld Nope. Promise resolves only when you call resolve
Pieter Stokkink
@forkerino
Jul 22 2017 12:27
@AmelZekovic I see the fiddle also doesn't recognize the function, not sure why that is happening.
Sweet Coding :)
@SweetCodingInc
Jul 22 2017 12:27
@Darkweld And promise returns instantly, without resolving
AmelZekovic
@AmelZekovic
Jul 22 2017 12:28
@forkerino got it working, thanks anyway
CamperBot
@camperbot
Jul 22 2017 12:28
amelzekovic sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2889 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jul 22 2017 12:29
@AmelZekovic ah, ok
me too
Manish Chandra
@chandrajob365
Jul 22 2017 12:38
Hi All
WAINGOR
@WAINGOR
Jul 22 2017 12:38
@moigithub you're dead right. Thank you!
CamperBot
@camperbot
Jul 22 2017 12:38
waingor sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3523 | @moigithub |http://www.freecodecamp.com/moigithub
Manish Chandra
@chandrajob365
Jul 22 2017 12:39
module.exports = class Server {
  constructor () {
    this.ROUTES = {
      GET: {},
      POST: {}
    }
  }
  getHandler (request, response) {
    this.ROUTES['GET'][request.header.URI](request, response)
  }
}
Now when I’m calling this.ROUTES[‘GET’] inside getHandler function , I’m getting ROUTES as undefined . Can someone please clarify above issue ?
Pieter Stokkink
@forkerino
Jul 22 2017 12:41
@chandrajob365 three `s
each on their own line
Manish Chandra
@chandrajob365
Jul 22 2017 12:42
@forkerino Still its not formated in multiline :(
Pieter Stokkink
@forkerino
Jul 22 2017 12:42
```
your code
```
Manish Chandra
@chandrajob365
Jul 22 2017 12:43
@forkerino :+1: :smile:
Shubham Sharma
@shubhamsrkdev
Jul 22 2017 12:52
What do you guys suggest, I have completed my front end certification, should I move to backend challenges (as Data visualization challenges are unavailable)?
_
Diego Mayer
@Chrono79
Jul 22 2017 12:59
@AmelZekovic
  function myFunction() {
  var x = parseInt(document.getElementById("h").value);
  var z = parseInt(document.getElementById("w").value);
  var y = parseInt(document.getElementById("l").value);

    alert( x * y * z);
  }

    var button = document.getElementById("result");
  button.onclick = myFunction;
Note that using parseInt you'll only get int results
Pieter Stokkink
@forkerino
Jul 22 2017 13:02
@chandrajob365 you mean when you call it from an instance of Server?
Manish Chandra
@chandrajob365
Jul 22 2017 13:02
Yes
Pieter Stokkink
@forkerino
Jul 22 2017 13:02
did you use the new keyword when creating the instance?
Manish Chandra
@chandrajob365
Jul 22 2017 13:02
Yes
Basically getHandler is not directly called from server
Pieter Stokkink
@forkerino
Jul 22 2017 13:03
no
@chandrajob365 I need to brush up on my class syntax.
Manish Chandra
@chandrajob365
Jul 22 2017 13:03
ok
Pieter Stokkink
@forkerino
Jul 22 2017 13:06
@chandrajob365 do you have the code online somewhere?
Manish Chandra
@chandrajob365
Jul 22 2017 13:06
1 sec , I will push it
Moisés Man
@moigithub
Jul 22 2017 13:11
@chandrajob365 chekc what the value of this
context might vary
Manish Chandra
@chandrajob365
Jul 22 2017 13:11
Yeah , checking that in all the function traces
Moisés Man
@moigithub
Jul 22 2017 13:13
u using ROUTE (line 91)
and this.ROUTE
Manish Chandra
@chandrajob365
Jul 22 2017 13:14
Sorry that was a typo
But after making it this.ROUTE(line 91) —> getting error Cannot read property 'GET' of undefined
I checked value of this in all the top function (trace) and its equall to <methodHandler> this = Server { ROUTES: { GET: { '/': [Function: print] }, POST: {} } }
But in getHandler log is <getHandler> this = { GET: [Function: getHandler], POST: [Function: postHandler] }
Pieter Stokkink
@forkerino
Jul 22 2017 13:17
so this seems to refer to the ROUTES object
Manish Chandra
@chandrajob365
Jul 22 2017 13:18
updated git repo with logs for this
@forkerino : yes but only in getHandler function not in its callee function (method and other top level functions)
Pieter Stokkink
@forkerino
Jul 22 2017 13:19
@chandrajob365 where do you call getHandler?
in requestHandler?
no
Manish Chandra
@chandrajob365
Jul 22 2017 13:20
getHandler<--methodHandler <— requestHandler
Pieter Stokkink
@forkerino
Jul 22 2017 13:24
@chandrajob365 I cannot get a Handle on it (pun intended).
and I gotta go soon
sorry
Manish Chandra
@chandrajob365
Jul 22 2017 13:25
@forkerino have to fight alone with this :(
Moisés Man
@moigithub
Jul 22 2017 13:25
maybe u trying to access a unexistant property name ?
Pieter Stokkink
@forkerino
Jul 22 2017 13:25
@chandrajob365 wait, it seems this inside the getHandler function refers to the METHODS object being passed into methodHandler
Manish Chandra
@chandrajob365
Jul 22 2017 13:25
yes
Pieter Stokkink
@forkerino
Jul 22 2017 13:26
because you call it on METHODS
Manish Chandra
@chandrajob365
Jul 22 2017 13:26
addRoute (method, path, func) {
    console.log('this =====> ', this)
    this.ROUTES[method][path] = func
  }
Pieter Stokkink
@forkerino
Jul 22 2017 13:26
@chandrajob365 maybe you can bind this in the requestHandler function? GET: this.getHandler.bind(this)
ok
gotta go
:wave:
Moisés Man
@moigithub
Jul 22 2017 13:29
this seems OK
but probably the "method/path" u adding on addRoute
DONT match the one u using on getHandler
Moisés Man
@moigithub
Jul 22 2017 13:37

ie:
addRoute('GET', 'a', ()=>{})

  getHandler (request, response) {
    console.log('request== ', JSON.stringify(request) ); // << check this n verify if exist on ur this.ROUTES.GET
    ROUTES.GET[request.header.URI](request, response)
  }

test.getHandler({header:{URI: 'a'}}, {}) //ok
test.getHandler({header:{URI: '/a'}}, {}) //fail @chandrajob365

Guderian Raborg
@hypercuber
Jul 22 2017 13:43
How do I get fib sequence up to a certain number:
function fib(n) {
  let arr = [1,1];
  while (arr[arr.length - 2] + arr[arr.length - 1] < n) {
    arr.push(arr[arr.length - 1] + arr[arr.length - 1]);
  }
  return arr;
}
console.log(fib(7)); // 1, 1, 2, 4, 8
I want to use while loop. I can make it work with for loop
@hypercuber I see my type. it should be arr.length - 2
typo
Stephen James
@sjames1958gm
Jul 22 2017 14:03
@hypercuber Are you supposed to include n?
makalohri
@makalohri
Jul 22 2017 14:03
@knrt10 thanks man
CamperBot
@camperbot
Jul 22 2017 14:03
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 465 | @knrt10 |http://www.freecodecamp.com/knrt10
madankumar sm
@madanamigo
Jul 22 2017 14:28
Guys anyone tell how to get twichtv API
Guderian Raborg
@hypercuber
Jul 22 2017 14:39
@sjames1958gm no
Look, guys, I can solve this problem: https://projecteuler.net/problem=10
Thing is my code is slow
function pArr(n) {
  let arr = [2];
  for (let i = 3; i < n; i++) {
    if (arr.every(p => i % p !== 0)) arr.push(i);
  }
  return arr.reduce((a,b) => a + b);
}
console.log(pArr(10)); //17
Manish Chandra
@chandrajob365
Jul 22 2017 14:40
@forkerino @moigithub : Git the issue . Need to bind getHandler in constructor this.getHandler = this.getHandler.bind(this)
Guderian Raborg
@hypercuber
Jul 22 2017 14:41
If anyone have a tip to make it faster I am all ears
Manish Chandra
@chandrajob365
Jul 22 2017 14:43
@moigithub : right now its static so whatever route u r adding , u need to put same as URL in browser like localhost:3000/a
Guderian Raborg
@hypercuber
Jul 22 2017 14:47
I have a question for a prime algorithm. Every positive number is either prime or a product of primes. If the number is odd do the products of primes repeat?
UnkyKong
@UnkyKong
Jul 22 2017 14:49
hello everyone
Dan Couper
@DanCouper
Jul 22 2017 14:50
@hypercuber Dont push then reduce, just add up along the way. Don't use every, find a different way; you're checking everything every time the loop runs. Basically, if you want to do math operations that have the potential to be enormously memory intensive (eg primes stuff, factorials etc) try to do everything in a single loop, mutate as much as possible. Don't use immutable array methods, just use for/while loops
Also, yes, you should get repetition unless it specifies unique factors
UnkyKong
@UnkyKong
Jul 22 2017 14:58
I'm looking for some help. I'm trying to convert two different twitch api calls into custom objects so that I can render all my elements at the same time.
Guderian Raborg
@hypercuber
Jul 22 2017 15:00
@DanCouper but I need to find all the arrays to check for next numbers
Dan Couper
@DanCouper
Jul 22 2017 15:01
@hypercuber Edit, just read what the challenge is, if you meant for that one, no repetition at all, you're just finding all primes below a number. Prime factorisation, that you get repeats for (like 40 is 2 × 2 × 2 × 5)
@hypercuber yes, but that way is very slow (checking every single time)
Guderian Raborg
@hypercuber
Jul 22 2017 15:08
@DanCouper If you can show me some code please.
I tried to skip iteration as soon as i % p === 0 but I think I need another method.
function pArr(n) {
  let arr = [2];
  for (let i = 3; i < n; i += 2) {
    if (arr.some(p => i % p === 0)) continue;
    arr.push(i);
  }
  return arr.reduce((a,b) => a + b);
}
madankumar sm
@madanamigo
Jul 22 2017 15:23
Tq@ Krishna biradar
Dan Couper
@DanCouper
Jul 22 2017 15:24
@hypercuber so first thing, the highest the prime (so the highest i should be able to get to in the loop) can go to is √n, so there are a whole lot of wasted iterations. Also you can prefill a lot more primes, which will change the condition; eg 3, 5, 7 etc. You are gonna need more code here; efficient solutions won't be 8 lines long - you shouldn't be looking for elegant
Feck
Sorry, was looking at factorisation again, ignore the √n bit
Guderian Raborg
@hypercuber
Jul 22 2017 15:28
@DanCouper Okay, thanks for all your feedback.
CamperBot
@camperbot
Jul 22 2017 15:28
hypercuber sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 843 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
Jul 22 2017 15:35
The main problem you have is you need a better alternative to that some chec
Stephen James
@sjames1958gm
Jul 22 2017 16:17
@UnkyKong You will need to use nested API calls where you can build the object in the callback for the second API call
@hypercuber Compute the sum as you go along and you won't have to have another loop (reduce).
arr.some seems fine in that you are checking if any existing prime divides into i, and that should stop and the first one that does.
UnkyKong
@UnkyKong
Jul 22 2017 16:22
@sjames1958gm isn't there a way to store the information I want from each api call into a custom object that I can iterate on later?
Stephen James
@sjames1958gm
Jul 22 2017 16:30
@UnkyKong If each API call puts data into a different property, then sure. But, if you have several API calls at once, say for different users, you will
need to keep track of the responses, waiting to iterate when all have returned
UnkyKong
@UnkyKong
Jul 22 2017 16:31
@sjames1958gm I already have promises set up
Siphils
@Siphils
Jul 22 2017 16:34

Falsy Bouncer

function bouncer(arr) {
    return arr.filter(function(val) {
        return (val !== false && val !== null && val !== 0 && val !== "" && val !== undefined && (!isNaN(val)));
    });
}

What's the wrong with it?

UnkyKong
@UnkyKong
Jul 22 2017 16:34
@sjames1958gm the actual problem I'm trying to solve is that my divs are being overwritten, leaving me with just the last on that is rendered
Stephen James
@sjames1958gm
Jul 22 2017 16:35
@Siphils isNaN wont' work, because isNaN("string") is true. Try Number.isNaN()
@UnkyKong YOu should be using create element for each user and then append to the divs.
Siphils
@Siphils
Jul 22 2017 16:37
@sjames1958gm Is isNaN used to judge a number ? Ok, I will try it later.
Stephen James
@sjames1958gm
Jul 22 2017 16:38
@Siphils isNaN is is Not a Number while Number.isNaN test is NaN
Siphils
@Siphils
Jul 22 2017 16:39
@sjames1958gm I got it. Thx :)
CamperBot
@camperbot
Jul 22 2017 16:39
siphils sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8134 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 22 2017 16:40
@Siphils :+1:
UnkyKong
@UnkyKong
Jul 22 2017 16:44
@sjames1958gm how and where would I do that?
Stephen James
@sjames1958gm
Jul 22 2017 16:46
@UnkyKong onlineUserBlock in this function, instead of updating the element you created at the top.
Create the elements here, and append the created elements to your HTML
UnkyKong
@UnkyKong
Jul 22 2017 16:47
ok I did that to make my code DRY lol
UnkyKong
@UnkyKong
Jul 22 2017 16:58
@sjames1958gm sigh, I am now getting an error saying newLink not defined.
Siphils
@Siphils
Jul 22 2017 17:00
@sjames1958gm I've worked out Falsy Bouncer
function bouncer(arr) {
    return arr.filter(function(val) {
        return Boolean(val);
    });
}
:sparkles:
Ghulam Shabir
@ghulamshabir
Jul 22 2017 17:02
@Siphils you could just pass Boolean constructor as filter callback
Siphils
@Siphils
Jul 22 2017 17:04
@ghulamshabir you're right... :worried: Maybe I'm a little stupid..
Ghulam Shabir
@ghulamshabir
Jul 22 2017 17:05
@Siphils don't worry, your solution is also good, I gave just another possibility
Stephen James
@sjames1958gm
Jul 22 2017 17:05
@UnkyKong Moving code into functions is another way to make code DRY
@Siphils :+1:
Ghulam Shabir
@ghulamshabir
Jul 22 2017 17:06
@sjames1958gm hi :smile:
Stephen James
@sjames1958gm
Jul 22 2017 17:06
@ghulamshabir :wave:
Siphils
@Siphils
Jul 22 2017 17:06
@ghulamshabir yeah, I will try different solutions.
Stephen James
@sjames1958gm
Jul 22 2017 17:07
@UnkyKong newLink is not newlink
UnkyKong
@UnkyKong
Jul 22 2017 17:09
herp
Ghulam Shabir
@ghulamshabir
Jul 22 2017 17:09
@Siphils you can also just return val, filter itself will coerce it to a boolean instead of using Boolean(val)
UnkyKong
@UnkyKong
Jul 22 2017 17:10
@sjames1958gm thank you
CamperBot
@camperbot
Jul 22 2017 17:10
unkykong sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8135 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Siphils
@Siphils
Jul 22 2017 17:13
@ghulamshabir I've tried it just now. Better solution val => val
Ghulam Shabir
@ghulamshabir
Jul 22 2017 17:13
@Siphils yeah arrow functions neat and clean
Siphils
@Siphils
Jul 22 2017 17:13
@ghulamshabir :smile: :clap: