These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jul 2017
silver537
@silver537
Jul 20 2017 00:01
You have to send it in as an object. @artoodeeto
David Darby
@AzFalconer
Jul 20 2017 00:02
@artoodeeto $(selector).css({property:value, property:value, ...})
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:03
@AzFalconer You are defining the 2d array with the same row array each time
ergo, when you change one, you change them all.
David Darby
@AzFalconer
Jul 20 2017 00:04
@kumquatfelafel Ugh, I knew it was something stupid. Thank you.
CamperBot
@camperbot
Jul 20 2017 00:04
azfalconer sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 499 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:05
np. It's those little logic errors that are the worst. :p
David Darby
@AzFalconer
Jul 20 2017 00:07
@kumquatfelafel Yes... :persevere:
@kumquatfelafel Wow, I would never have caught that. I thought I was filling grid with 10 arrays of [0,0,0,0,0,0,0,0,0,0], but I was really feeling it with 'row' ten times... It's now fixed. Thank you again.
CamperBot
@camperbot
Jul 20 2017 00:11
azfalconer sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: azfalconer already gave kumquatfelafel points
Maximino V. Jardin III
@ma5one1
Jul 20 2017 00:16
Halp pls. What does (?) in this code.. function largestOfFour(arr) {
return arr.map(function(group){
return group.reduce(function(prev, current) {
return (current > prev) ? current : prev;
});
});
}
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:16
@ma5one1 are you asking what ? means?
k
Maximino V. Jardin III
@ma5one1
Jul 20 2017 00:17
@kumquatfelafel yes
Gary
@bluefishmarine
Jul 20 2017 00:18
@ma5one1 I think thats the ternary operator. it works like an if/else statement. if condition 1 is true, do current. else do prev
so if current>prev is true, return = current. else return prev
Maximino V. Jardin III
@ma5one1
Jul 20 2017 00:20
@kumquatfelafel so is it exclusive only when using .map/.reduce functions???
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:20
@ma5one1 You can think of it a bit like... normally current > prev would evaluate to either true or false. When you have ternary (aka conditional) operator, like so...
return current > prev ? current : prev; if true, evaluated as current.// if false, evaluated as prev.
Gary
@bluefishmarine
Jul 20 2017 00:20
it can be used anywhere
Maximino V. Jardin III
@ma5one1
Jul 20 2017 00:21
@kumquatfelafel Thank you.
CamperBot
@camperbot
Jul 20 2017 00:21
ma5one1 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 500 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Maximino V. Jardin III
@ma5one1
Jul 20 2017 00:22
I've been sitting on this challenge for quite some time.
@bluefishmarine Thank you.
CamperBot
@camperbot
Jul 20 2017 00:22
ma5one1 sends brownie points to @bluefishmarine :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @bluefishmarine |http://www.freecodecamp.com/bluefishmarine
Gary
@bluefishmarine
Jul 20 2017 00:23
no prob
John
@AnonymousLords
Jul 20 2017 00:26
Guys what doe sthsi code do? Im having Trouble UNderstand It
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
   console.log(arr[i]);
}
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:27

@AnonymousLords well, let's start off simple.

What is the value of arr[0]?

John
@AnonymousLords
Jul 20 2017 00:27
Does it add 1 - 5 too arr
0,6,7,8,9,10
.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:29
Are you saying the value of arr[0] is 0,6,7,8,9,10?
John
@AnonymousLords
Jul 20 2017 00:30
wait
[0]
It replaces all of those numbers with 0?
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:31
You're jumping the gun. You're not going to be able to understand what's going on if you can't answer my question first.
John
@AnonymousLords
Jul 20 2017 00:32
@kumquatfelafel Ye sit is 0,6,7,8,9,10
Considiering it has a global value of 6 to 10
it adds arr with i
Gary
@bluefishmarine
Jul 20 2017 00:34
@AnonymousLords I think you may be confused. Do you know how to access a value inside an array?
John
@AnonymousLords
Jul 20 2017 00:34
Yes, but im slightely confused.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:35
How would you access the first value inside an array arr?
John
@AnonymousLords
Jul 20 2017 00:35
Ik push adds to teh array
Gary
@bluefishmarine
Jul 20 2017 00:35
var list = ["cat", "dog", "mouse"];
what is value of list[0]?
John
@AnonymousLords
Jul 20 2017 00:36
0
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:36
nope.
John
@AnonymousLords
Jul 20 2017 00:36
0 with list
That is the part im confused about
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:36
0 refers to which element of the list you are trying to access.
John
@AnonymousLords
Jul 20 2017 00:36
OH
Okay
Gary
@bluefishmarine
Jul 20 2017 00:36
yeah
John
@AnonymousLords
Jul 20 2017 00:37
Thanks, got it mixed up, @bluefishmarine @kumquatfelafel @kumquatfelafel @bluefishmarine
CamperBot
@camperbot
Jul 20 2017 00:37
anonymouslords sends brownie points to @bluefishmarine and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @bluefishmarine |http://www.freecodecamp.com/bluefishmarine
:cookie: 501 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:37
and element numbers (aka index) start at 0.
John
@AnonymousLords
Jul 20 2017 00:37
So it wouldprint 6 threw 10 right?
@kumquatfelafel hello?
Gary
@bluefishmarine
Jul 20 2017 00:39
@AnonymousLords pay attention to the order of the list. what is the intial value of i?
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:39
Are you asking if it would print 6 then 7 then ... then 10?
John
@AnonymousLords
Jul 20 2017 00:39
It would print 6 to 10
@bluefishmarine I is 0
So it would add
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:39
and what is arr[0]?
Gary
@bluefishmarine
Jul 20 2017 00:39
right. what is the number at position 0
John
@AnonymousLords
Jul 20 2017 00:40
It would print nothing, because its only 6 to 10
Gary
@bluefishmarine
Jul 20 2017 00:41
0 1 2 3 4 5
[a,b,c,d,e]
John
@AnonymousLords
Jul 20 2017 00:41
Oh
a it would print
Gary
@bluefishmarine
Jul 20 2017 00:41
minus the 5
John
@AnonymousLords
Jul 20 2017 00:42
I was gettingmixed up with "0" and 0
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:42
@bluefishmarine or plus the f. :p
John
@AnonymousLords
Jul 20 2017 00:42
Now i understand
Gary
@bluefishmarine
Jul 20 2017 00:42
yeah, that just an example. the numbers above represent the index
every array starts with an index of 0
John
@AnonymousLords
Jul 20 2017 00:42
0 prints the first number, because 0 is really 1
Gary
@bluefishmarine
Jul 20 2017 00:42
@kumquatfelafel ya if you wanna add that in
John
@AnonymousLords
Jul 20 2017 00:42
because JS starts at 0
So thsi equation prints 6 teh first loop,then 7 teh second, all teh way up to 10
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:43

general sorta syntax for accessing element of an array:

arrayName[indexNumber]

John
@AnonymousLords
Jul 20 2017 00:43
Okay :P
Thanks so much :P
Gary
@bluefishmarine
Jul 20 2017 00:44
also, don't get confused by the numbers being there. the number is just data. it can be "9" it can be "xyz" , a function, or an object
John
@AnonymousLords
Jul 20 2017 00:44
Sometimes i forget a basic thing, and people will say that i don't know what i am doing and that coding isn't for me. Thanks for helping and being a decent person.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:44
@AnonymousLords close. Let's take another look at what we have.
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
   console.log(arr[i]);
}
Which element comes first here?
John
@AnonymousLords
Jul 20 2017 00:45
@bluefishmarine Okay
the first element is 10
Whoops i meant it would print 10 down to six
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:45
aye. ;)
Gary
@bluefishmarine
Jul 20 2017 00:46
:+1:
John
@AnonymousLords
Jul 20 2017 00:46
Didn't look a the code when i wrote that :P
ahve you guys
ever made a game @bluefishmarine @kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:46
figured a bit of time gone by so might not remember. Wanted to be sure though :p
John
@AnonymousLords
Jul 20 2017 00:47
:)
:shipit:
It would be cool to learn Lua
just to try it
Its similar to JS
Like print("Hello") is console.log("hello")
Gary
@bluefishmarine
Jul 20 2017 00:47
nope, never made any games. still learning the basics
John
@AnonymousLords
Jul 20 2017 00:47
about @bluefishmarine
CamperBot
@camperbot
Jul 20 2017 00:47
:cookie: 304 | @bluefishmarine |http://www.freecodecamp.com/bluefishmarine
John
@AnonymousLords
Jul 20 2017 00:48
about @AnonymousLords
CamperBot
@camperbot
Jul 20 2017 00:48
:warning: no user found for anonymouslords
kumquatfelafel
@kumquatfelafel
Jul 20 2017 00:48
gonna log for now. too warm for thinking/being near heat-producing machine :laughing:
John
@AnonymousLords
Jul 20 2017 00:48
:D
Gary
@bluefishmarine
Jul 20 2017 00:48
@kumquatfelafel good luck to ya
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:07

I can't figure out how to delete the last recipe:
https://codepen.io/giveback007/pen/dRrgqO

it just throws errors
and I don't know how to properly manage state here

AHHHHH!!! STATE MANAGEMENT!!!!!
John
@AnonymousLords
Jul 20 2017 01:08
Is their a typo in teh code? I why wouldnt it work?
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:09
@AnonymousLords what kind of typo?
try pressing the X button on all 3
John
@AnonymousLords
Jul 20 2017 01:09
Im not sure, the last elemnt left no matter which one it is doesnt delete
If you mix the order on which you delete the items, no matter which box it is, it will stay up
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:10
I know
John
@AnonymousLords
Jul 20 2017 01:10
Ask @kumquatfelafel is he knows anything abut this.
Wait he isnt on
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:10
It tries to read the object (which when deleted is not there) and rather then rendering nothing it throws out an erros
Lord @kumquatfelafel chipmunk plz helps
John
@AnonymousLords
Jul 20 2017 01:11
Ask @SkyC0der or @MCTwoDigitZero about this
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:11
Avengers @SkyC0der or @MCTwoDigitZero helps
CallMeOrange
@EgnaroDev
Jul 20 2017 01:11
..
Is it react?
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:12
@MCTwoDigitZero yes
CallMeOrange
@EgnaroDev
Jul 20 2017 01:12
Sorry, I don't know react :/
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:13
if this continues I will rewrite this whole damb ting using stateless functional components and global variables
John
@AnonymousLords
Jul 20 2017 01:13
does skycoder know react?
Manish Giri
@Manish-Giri
Jul 20 2017 01:13
@Giveback007 name={this.state.recipes[objNum].name}
I think the problem is here
yep it is there
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:14
if (this.state.recipes === []) { return null }
    var objNum = this.state.focusedRecipeNum;

    var mapedRecepies = this.state.recipes.map((x, i) =>
      <Recipe
        focusOn={() => this.focusOn(i)}
        name={x.name}
        img={x.img}
        delete={() => {this.delete(i)}}
      />
    );

    return(
how come it tries it when I ask it to return null
Manish Giri
@Manish-Giri
Jul 20 2017 01:15
xxd.png
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:15
@Manish-Giri I want the software you are using!
Manish Giri
@Manish-Giri
Jul 20 2017 01:16
software?
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:16
yeah i like how it visualy*located the error
Manish Giri
@Manish-Giri
Jul 20 2017 01:16
it's the chrome developer tools
no software
__mifflin__
@cdrainxv
Jul 20 2017 01:16
lol
Nick Janne
@njanne19
Jul 20 2017 01:17
Can anyone see why my key functions aren't doing anything? https://codepen.io/njanne19/pen/WOPVZj?editors=0011
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:17
@Manish-Giri how do I open that particular window?
oh nwm
Manish Giri
@Manish-Giri
Jul 20 2017 01:18
@Giveback007 ctrl shift I if on windows
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:18
@Manish-Giri anyways how do I circumvent this bug?
if (this.state.recipes === []) { return null } how come this doesn't stop the second return statement from running
Gary
@bluefishmarine
Jul 20 2017 01:20
@njanne19 maybe try using the keycodes?
left = 37
up = 38
right = 39
down = 40
Nick Janne
@njanne19
Jul 20 2017 01:21
@bluefishmarine still not working, hmm
Manish Giri
@Manish-Giri
Jul 20 2017 01:21
@Giveback007 done
change if (this.state.recipes === []) to if (!this.state.recipes.length)
John
@AnonymousLords
Jul 20 2017 01:22
Is their anything on PC where you can enter and make programs?
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:22
@Manish-Giri you are my hero!!!!!!!
@Manish-Giri thank you
CamperBot
@camperbot
Jul 20 2017 01:22
giveback007 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6282 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jul 20 2017 01:22
:+1:
John
@AnonymousLords
Jul 20 2017 01:22
:+1:
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:22
but how does this work?
Gary
@bluefishmarine
Jul 20 2017 01:23
@njanne19 i don't know anything about react, so not sure how "key" works, but i read somewhere that the arrow keys only work using "onkeydown" not keypress
Manish Giri
@Manish-Giri
Jul 20 2017 01:23
@Giveback007 if (this.state.recipes === [])
when you write this
it's like you're comparing the references to two array objects
both of which are physically present in different locations in memory
Nick Janne
@njanne19
Jul 20 2017 01:24
@bluefishmarine I have onkeydown, and the key method is just something I made up it didn't need to be called key
Gary
@bluefishmarine
Jul 20 2017 01:24
@njanne19 ah ok, gotcha
Manish Giri
@Manish-Giri
Jul 20 2017 01:24
in case of objects(called reference types in some languages), comparing two objects like that only compares their physical memory addresses
not the actual contents
王想想
@wxxxxxxxx
Jul 20 2017 01:25
hello
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:25
@Manish-Giri you are a magician and I will gladly sacrafice my first born child for your evil magic, thank you
CamperBot
@camperbot
Jul 20 2017 01:25
giveback007 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: giveback007 already gave manish-giri points
Manish Giri
@Manish-Giri
Jul 20 2017 01:25
lol
王想想
@wxxxxxxxx
Jul 20 2017 01:25
lol
John
@AnonymousLords
Jul 20 2017 01:26
about @wxxxxxxxx
CamperBot
@camperbot
Jul 20 2017 01:26
:warning: no user found for wxxxxxxxx
John
@AnonymousLords
Jul 20 2017 01:27
? how
about @camperbot
CamperBot
@camperbot
Jul 20 2017 01:27
:star2: 3373 | @camperbot |http://www.freecodecamp.com/camperbot
王想想
@wxxxxxxxx
Jul 20 2017 01:27
@AnonymousLords ?
John
@AnonymousLords
Jul 20 2017 01:27
wanted to see cookies
王想想
@wxxxxxxxx
Jul 20 2017 01:28
Do not understand
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:28
@AnonymousLords his account might not be linked with fcc
@Manish-Giri here's what I want to know
in that case .length returns 0
how can you use the ! on 0 to return true
Manish Giri
@Manish-Giri
Jul 20 2017 01:31
anything that returns 0 is a falsy value in JS
if you say if(this.state.recipe.length)
that means length is greater than 0
put up a ! in front, means it's 0
王想想
@wxxxxxxxx
Jul 20 2017 01:32
Who can teach me javascript
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:32
@Manish-Giri is that with non strict operators only?
Joel Korcsmaros
@lossness
Jul 20 2017 01:32
I can pay me 10k
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:32
ill do it for 8K
Joel Korcsmaros
@lossness
Jul 20 2017 01:32
7.5
王想想
@wxxxxxxxx
Jul 20 2017 01:32
Even the money
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:32
6
Joel Korcsmaros
@lossness
Jul 20 2017 01:32
7
5
王想想
@wxxxxxxxx
Jul 20 2017 01:32
....
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:32
2
Joel Korcsmaros
@lossness
Jul 20 2017 01:33
1
final
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:33
0.1 cents
Joel Korcsmaros
@lossness
Jul 20 2017 01:33
pssh
王想想
@wxxxxxxxx
Jul 20 2017 01:33
You are too much
Joel Korcsmaros
@lossness
Jul 20 2017 01:33
you're too much dovy
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:33
but you have to wire the money trough my business and it has a 10k convenience fee
Brian
@BrianCodes33
Jul 20 2017 01:34
function findDeletedNumber(arr, mixArr) {
 let result = [];
 for (var i=0; i<arr.length; i++) {
   if (arr[i] !== mixArr[i]) {
     result.push(arr[i]);
   }
 }
 return result;
}

(findDeletedNumber([1,2,3,4,5], [3,4,1,5]), 2, 'Deletion')
having trouble any help
王想想
@wxxxxxxxx
Jul 20 2017 01:34
Foreigners say nothing about money, I still self-study it
John
@AnonymousLords
Jul 20 2017 01:35
Why doesnt this work? its in my for loop
total++
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:35
@wxxxxxxxx we can all help you with JS at wearying levels
just let us know where you are at
John
@AnonymousLords
Jul 20 2017 01:35
This message was deleted
nvm is not related to that
different error
王想想
@wxxxxxxxx
Jul 20 2017 01:36
@Giveback007 Do not tell you
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:38
@wxxxxxxxx :smile: ok
John
@AnonymousLords
Jul 20 2017 01:38
@wxxxxxxxx FCC teaches it
@wxxxxxxxx once you finish front end
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:39
@wxxxxxxxx I don't mean where you live, I mean where you are in your learning
Gary
@bluefishmarine
Jul 20 2017 01:39
@BrianCodes33 what is the assignment? to compare arr1 and arr2 and find the number thats missing from arr2?
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:39
I'm still a newb myself
John
@AnonymousLords
Jul 20 2017 01:39
about @Giveback007
CamperBot
@camperbot
Jul 20 2017 01:39
:cookie: 317 | @giveback007 |http://www.freecodecamp.com/giveback007
John
@AnonymousLords
Jul 20 2017 01:39
still more cookies then me
about @AnonymousLords
CamperBot
@camperbot
Jul 20 2017 01:39
:warning: no user found for anonymouslords
John
@AnonymousLords
Jul 20 2017 01:39
Im linked to github ?
王想想
@wxxxxxxxx
Jul 20 2017 01:40
@Giveback007 fcc
Brian
@BrianCodes33
Jul 20 2017 01:40
@bluefishmarine yea
Gary
@bluefishmarine
Jul 20 2017 01:40
@BrianCodes33 Ok....is arr1 always going to have all the numbers?
John
@AnonymousLords
Jul 20 2017 01:40
my cookies are 264 btw
Whats your cookies @wxxxxxxxx
Brian
@BrianCodes33
Jul 20 2017 01:41

An ordered sequence of numbers from 1 to N is given. One number might have deleted from it, then the remaining numbers were mixed. Find the number that was deleted.

Example:

The starting array sequence is [1,2,3,4,5,6,7,8,9]
The mixed array with one deleted number is [3,2,4,6,7,8,1,9]
Your function should return the int 5.

Gary
@bluefishmarine
Jul 20 2017 01:41
ah ok. im just wondering if the starting array is always the first argument
王想想
@wxxxxxxxx
Jul 20 2017 01:42
@AnonymousLords 113
John
@AnonymousLords
Jul 20 2017 01:42
Lol that time when you tried to runa code and you get "infinite loop created, will crash browser"
@wxxxxxxxx Not bad
Gary
@bluefishmarine
Jul 20 2017 01:42
if so, maybe try to loop thru argument 1, and simply test if arr2 includes the value
John
@AnonymousLords
Jul 20 2017 01:43
Guys can someone define NaN, i forgot :P
王想想
@wxxxxxxxx
Jul 20 2017 01:43
@AnonymousLords
Yesterday only brush the title, just write javascript
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:43
@Manish-Giri again tnx :)
CamperBot
@camperbot
Jul 20 2017 01:43
giveback007 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: giveback007 already gave manish-giri points
John
@AnonymousLords
Jul 20 2017 01:43
?
Gary
@bluefishmarine
Jul 20 2017 01:43
maybe with .includes() method.
"The includes() method determines whether an array includes a certain element, returning true or false as appropriate."
John
@AnonymousLords
Jul 20 2017 01:43
@wxxxxxxxx
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:43
you da best
John
@AnonymousLords
Jul 20 2017 01:43
Are you doing front end currently?
Manish Giri
@Manish-Giri
Jul 20 2017 01:44
@Giveback007 :sparkles:
王想想
@wxxxxxxxx
Jul 20 2017 01:44
@AnonymousLords vue
Manish Giri
@Manish-Giri
Jul 20 2017 01:44
good luck with react!
John
@AnonymousLords
Jul 20 2017 01:44
vue>?
王想想
@wxxxxxxxx
Jul 20 2017 01:44
Now in review js
yes
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:44
@Manish-Giri it's not easy. I think ill try to make make stuff stateless in the future
it's much easier that way
John
@AnonymousLords
Jul 20 2017 01:44
@wxxxxxxxx okay
anyways guys whats NaN mean @Giveback007 @Manish-Giri @wxxxxxxxx @bluefishmarine
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:45
not a number
John
@AnonymousLords
Jul 20 2017 01:45
thanks @Giveback007
CamperBot
@camperbot
Jul 20 2017 01:45
anonymouslords sends brownie points to @giveback007 :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @giveback007 |http://www.freecodecamp.com/giveback007
王想想
@wxxxxxxxx
Jul 20 2017 01:45
@AnonymousLords
Yesterday wrote 100 questions in the company
Dovydas Stirpeika
@Giveback007
Jul 20 2017 01:45
yay cookies :D
John
@AnonymousLords
Jul 20 2017 01:45
:D
@wxxxxxxxx lucky
王想想
@wxxxxxxxx
Jul 20 2017 01:45
How do biscuits make?
John
@AnonymousLords
Jul 20 2017 01:45
...
王想想
@wxxxxxxxx
Jul 20 2017 01:45
😄
John
@AnonymousLords
Jul 20 2017 01:46
:ear_of_rice:
王想想
@wxxxxxxxx
Jul 20 2017 01:46
My connection
John
@AnonymousLords
Jul 20 2017 01:46
:camera:
Gary
@bluefishmarine
Jul 20 2017 01:46
@AnonymousLords I recommend you read a series of books called "You don't know Javascript" they are open source, has a lot of very good info on javascript. I am currently on book 4 in the series
王想想
@wxxxxxxxx
Jul 20 2017 01:46
...
John
@AnonymousLords
Jul 20 2017 01:46
@bluefishmarine Is it free?
Brian
@BrianCodes33
Jul 20 2017 01:47
open source === free
John
@AnonymousLords
Jul 20 2017 01:47
:O
no its == free
Gary
@bluefishmarine
Jul 20 2017 01:47
yes, free to read
Brian
@BrianCodes33
Jul 20 2017 01:47
function findDeletedNumber(arr, mixArr) {
  for (var i = 0; i < arr.length; i++) {
    if (arr[i].includes(mixArr) {
      return 'No deletion';
    }
  }
}
王想想
@wxxxxxxxx
Jul 20 2017 01:47
@AnonymousLords Which person
Brian
@BrianCodes33
Jul 20 2017 01:47
like this gary?
Gary
@bluefishmarine
Jul 20 2017 01:47
you can also search pdf format
abraham anak agung
@padunk
Jul 20 2017 01:48
Good Morning Everyone :coffee:
John
@AnonymousLords
Jul 20 2017 01:48
@wxxxxxxxx ??
@padunk its 9:48 pm
王想想
@wxxxxxxxx
Jul 20 2017 01:48
Where to live
John
@AnonymousLords
Jul 20 2017 01:48
Why doesnt this work? ```
Gary
@bluefishmarine
Jul 20 2017 01:48
@BrianCodes33 hmm...if you do a return like that I think it it will end the loop on the first "true" value
John
@AnonymousLords
Jul 20 2017 01:49
// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
for (var total = 0; total < myArr.length; total + 1) {
  total += myArr[20];
}
abraham anak agung
@padunk
Jul 20 2017 01:49
@AnonymousLords then we have 11 hours difference time zone
what is myArr[20] ?
John
@AnonymousLords
Jul 20 2017 01:50
it goes up to the 20th spot right?
well 21st
The challange needs to list all items from myArr up to 20
abraham anak agung
@padunk
Jul 20 2017 01:51
yes but your arr length only 5
John
@AnonymousLords
Jul 20 2017 01:51
total should equal 20
abraham anak agung
@padunk
Jul 20 2017 01:52
ah, you need to sum it.
John
@AnonymousLords
Jul 20 2017 01:52
okay
each number
abraham anak agung
@padunk
Jul 20 2017 01:52
@AnonymousLords myArr[0] will return 2 myArr[1] will return 3 and so on
John
@AnonymousLords
Jul 20 2017 01:53
why
abraham anak agung
@padunk
Jul 20 2017 01:53
so you need to sum up each number in the array
John
@AnonymousLords
Jul 20 2017 01:53
thought it started at 0
Gary
@bluefishmarine
Jul 20 2017 01:54
@BrianCodes33 also, when you use .includes() you are comparing your 2nd argument to the first one mixArr.includes(arr[i])
abraham anak agung
@padunk
Jul 20 2017 01:54
yes the index start at 0. which one you think start at 0?
John
@AnonymousLords
Jul 20 2017 01:54
2
Got confused their for a seck
Thought it started at 1 :P
for the array
thought teh array was 1 to 6
abraham anak agung
@padunk
Jul 20 2017 01:55
No, 2 is the value of your array and you call the value 2 with myArr[0]
John
@AnonymousLords
Jul 20 2017 01:55
not 2 to 6
okay
humm how am i going to do this :P
ill go try
abraham anak agung
@padunk
Jul 20 2017 01:56
myArr = [2,3,4,5,6] // index is [0,1,2,3,4,5] the example above pretty give you everything
@AnonymousLords if you do for loop you could access each value of myArr with myArr[i]
John
@AnonymousLords
Jul 20 2017 01:58
thanks @padunk
CamperBot
@camperbot
Jul 20 2017 01:58
anonymouslords sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @padunk |http://www.freecodecamp.com/padunk
John
@AnonymousLords
Jul 20 2017 01:59
@padunk okay
abraham anak agung
@padunk
Jul 20 2017 01:59
wow....
John
@AnonymousLords
Jul 20 2017 02:00
this is only 9?
```
for (var total = 0; total < myArr.length; total++) {
  total += myArr[total];
}
abraham anak agung
@padunk
Jul 20 2017 02:01
@AnonymousLords you should separate var total and var i. They are two different things
John
@AnonymousLords
Jul 20 2017 02:02
i need to use total as var
total + 1 = 6
abraham anak agung
@padunk
Jul 20 2017 02:02
take a look at example above. No. total will be total sum of you array while i is the iterator
John
@AnonymousLords
Jul 20 2017 02:02
total++ is 9
i thought i could be anything
like the name
abraham anak agung
@padunk
Jul 20 2017 02:04
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}
see var ourTotal is not var i
John
@AnonymousLords
Jul 20 2017 02:05
okay
```
doesnt work?
// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

var total = 0;

for (var i = 0; total < myArr.length; i++) {
  total += myArr[i];
}
doesnt work?
abraham anak agung
@padunk
Jul 20 2017 02:07
@AnonymousLords be consistent with i i< myArr.length
John
@AnonymousLords
Jul 20 2017 02:08
Oh
thanks for your help @padunk
CamperBot
@camperbot
Jul 20 2017 02:08
anonymouslords sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:warning: anonymouslords already gave padunk points
abraham anak agung
@padunk
Jul 20 2017 02:08
@AnonymousLords np. but you need to understand this for loop. it is a powerful method
John
@AnonymousLords
Jul 20 2017 02:08
How to you memeorize everything
not forget anything when learning
abraham anak agung
@padunk
Jul 20 2017 02:09
code everyday ? :smile:
John
@AnonymousLords
Jul 20 2017 02:09
:D
__mifflin__
@cdrainxv
Jul 20 2017 02:10
Also learn how to find resources and read documentations.
John
@AnonymousLords
Jul 20 2017 02:10
okay
__mifflin__
@cdrainxv
Jul 20 2017 02:11
There’s no point in remembering everything… just the basics and most things you’ll learn/remember by application.
John
@AnonymousLords
Jul 20 2017 02:12
okay
this aloud?
GradStudent27
@GradStudent27
Jul 20 2017 02:14
Please ignore my message or delete it if such requests are not permitted. Thank you!
abraham anak agung
@padunk
Jul 20 2017 02:14
ah, Amazon, so far away for shipment :smile:
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:15
Hey guys, I'm trying to learn ES6 via freecodecamp(beta) any ideas how to apply the rest function?

function sum(x, y, z) {
    const array = [ x, y, z ];
    return array.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3)); // 6
Rest operator not rest function, my bad
Bryan Reese
@breese8009
Jul 20 2017 02:16
@GradStudent27 u get banned for posting that fyi
abraham anak agung
@padunk
Jul 20 2017 02:16
rest operator syntax is ...rest @aliahmad-code
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:17
Ohhh, I had no idea
GradStudent27
@GradStudent27
Jul 20 2017 02:17
@breese8009 do you think posting survey is not permitted by Gitter? I am a grad student requesting info from developers, not at all trying to spam
Berkeley Martinez
@BerkeleyTrue
Jul 20 2017 02:18
@GradStudent27 Do not post links to surveys or outside (unrelated) resources in our chatrooms.
Bryan Reese
@breese8009
Jul 20 2017 02:18
@GradStudent27 ^^ theres ur answer
John
@AnonymousLords
Jul 20 2017 02:18
@GradStudent27 you joined joined
and posted a link
to a scam
Bryan Reese
@breese8009
Jul 20 2017 02:18
he deleted it
its over yo
;)
Moisés Man
@moigithub
Jul 20 2017 02:18
function sum(...numbers){
     console.log(numbers)
}
sum(1,2,3,4)
//[1, 2, 3, 4]
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:18
Quick question, how exactly would the rest operator be applied in this situation?

function sum(...args) {
    const array = args.length;
    return array.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3)); // 6
John
@AnonymousLords
Jul 20 2017 02:18
@breese8009 I still have it ona recording just inase
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:19
@padunk thanks for pointing out what a rest operator is :)
CamperBot
@camperbot
Jul 20 2017 02:19
aliahmad-code sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 379 | @padunk |http://www.freecodecamp.com/padunk
Manish Giri
@Manish-Giri
Jul 20 2017 02:19
@aliahmad-code 1, 2 and 3 would be packed into an array
that's what rest does
Bryan Reese
@breese8009
Jul 20 2017 02:19
i didnt think bout using spread operator in param
interesting
Manish Giri
@Manish-Giri
Jul 20 2017 02:19
that's the only place rest is used
in func params
Bryan Reese
@breese8009
Jul 20 2017 02:20
...?
Manish Giri
@Manish-Giri
Jul 20 2017 02:20
rest anywhere it's spread
Bryan Reese
@breese8009
Jul 20 2017 02:20
thaT?
Manish Giri
@Manish-Giri
Jul 20 2017 02:20
yup
abraham anak agung
@padunk
Jul 20 2017 02:20
@aliahmad-code np, but your reduce ,0 is weird
Manish Giri
@Manish-Giri
Jul 20 2017 02:20
... is both spread and rest
Bryan Reese
@breese8009
Jul 20 2017 02:20
Math.max(...arr)
abraham anak agung
@padunk
Jul 20 2017 02:20
why they give it the same ...?
Moisés Man
@moigithub
Jul 20 2017 02:20
@padunk reduce second parameter.. its for "initial value"
Manish Giri
@Manish-Giri
Jul 20 2017 02:20
that's spread
Math.max(...arr)
Bryan Reese
@breese8009
Jul 20 2017 02:20
its not same?
Manish Giri
@Manish-Giri
Jul 20 2017 02:20
you're spreading out an array into a "list"
Bryan Reese
@breese8009
Jul 20 2017 02:20
whats rest?
Manish Giri
@Manish-Giri
Jul 20 2017 02:21
function sum(...args) {
this is opposite of spread -> rest
abraham anak agung
@padunk
Jul 20 2017 02:21
@moigithub oh yes, it is an ES 6 arrow. my bad
Manish Giri
@Manish-Giri
Jul 20 2017 02:21
packs a list of args into an array
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:21
You guys are helpful. Thank you, it just made sense. I was so lost LOL

```

function sum(...args) {
const array = args;
return array.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3)); // 6

``` this worked

function sum(...args) {
const array = args;
return array.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3)); // 6
Bryan Reese
@breese8009
Jul 20 2017 02:22
interesting
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:22
Thank you @Manish-Giri
CamperBot
@camperbot
Jul 20 2017 02:22
aliahmad-code sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6283 | @manish-giri |http://www.freecodecamp.com/manish-giri
Bryan Reese
@breese8009
Jul 20 2017 02:22
@Manish-Giri ya thanks man
CamperBot
@camperbot
Jul 20 2017 02:22
breese8009 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6284 | @manish-giri |http://www.freecodecamp.com/manish-giri
Bryan Reese
@breese8009
Jul 20 2017 02:22
jesus
Manish Giri
@Manish-Giri
Jul 20 2017 02:22
:fire:
Bryan Reese
@breese8009
Jul 20 2017 02:22
@Manish-Giri look ur points bro!
lol
ur rich!
Manish Giri
@Manish-Giri
Jul 20 2017 02:22
lol
haha
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:23
@Manish-Giri You helped me wayyy back when like in late May. You're a great help man!
Manish Giri
@Manish-Giri
Jul 20 2017 02:23
@aliahmad-code happy to help!
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:30
Am I supposed to use a loop with a if function to check if the number is an integer than square it and push the result into squaredintergers?
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
// change code below this line
var squaredIntegers = realNumberArray;
// change code above this line
// test your code
console.log(squaredIntegers);
All that in a ES6 one liner?
kumquatfelafel
@kumquatfelafel
Jul 20 2017 02:40
@aliahmad-code if your goal is to do it in one line here, then it's not as bad as it sounds. Try and think of any functions that might be able to do what you're attempting
monkeyfingerz
@monkeyfingerz
Jul 20 2017 02:40

function translatePigLatin(str) {
var changed = str.split();
var firstLetter = changed[0].toUpperCase() ;
  if(firstLetter=== 'A' ||firstLetter === 'E' || firstLetter === 'I' || firstLetter === 'O' ||firstLetter ===  'U'){
 return str.concat("way");
 }
  else{

    return str.substr(1,str.length).push(changed[0],"ay");
  }
}

translatePigLatin("consonant");
it's saying in my console that substr is not a function?
Ali Ahmad
@aliahmad-code
Jul 20 2017 02:42
@kumquatfelafel Cool, I'll give it shot. Thanks!
CamperBot
@camperbot
Jul 20 2017 02:42
aliahmad-code sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 502 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 20 2017 02:43
@monkeyfingerz you're trying to call array's push function on a string. There is no push for strings. What can be try instead?
monkeyfingerz
@monkeyfingerz
Jul 20 2017 02:44
well now i know that... Thank you!
@kumquatfelafel thanks
CamperBot
@camperbot
Jul 20 2017 02:44
monkeyfingerz sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 503 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Kevin Anderson
@LemonStain
Jul 20 2017 02:45
good evening campers!
Gulsvi
@gulsvi
Jul 20 2017 02:45
@JLuboff Thanks for your awesome API :)
CamperBot
@camperbot
Jul 20 2017 02:45
skyc0der sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2087 | @jluboff |http://www.freecodecamp.com/jluboff
Gulsvi
@gulsvi
Jul 20 2017 02:46
Good evening @LemonStain
vincent5460
@vincent5460
Jul 20 2017 02:47
Generate Random Fractions with JavaScript
i wrote:function myFunction() {
Math.random();
return (myFunction);}
but it was wrong
Kevin Anderson
@LemonStain
Jul 20 2017 02:48
Anyone have a minute to check out my code and guide me so I can access my object with data after my function runs? (trying to use a nested function? to let my ajax call run before i access my data)
Ken Haduch
@khaduch
Jul 20 2017 02:49
@vincent5460 - Math.random(); generates the number. You could either save that value in a variable and return the variable, or directly return Math.random();, if all you need is to return the value that is returned by calling that function.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 02:53
@vincent5460 :point_up:
Currently you're returning a function reference and the Math.random() result is lost in the æther.
Gulsvi
@gulsvi
Jul 20 2017 02:54
@LemonStain There are lots of ways to do this, since you're going the route with pushing data to an array so you can access the data in a format you prefer later...you probably want to use a callback counter. When you've processed the final person in your users array, call a function to process your new playerList array.
So, your second success function will have something like:
counter++
if(counter === users.length) processAllTheData();
Ken Haduch
@khaduch
Jul 20 2017 02:55
@LemonStain - it looks like you are getting data back, so that's good. The problem is that you don't know when you can finally access all of the data, since the information from each request is returned at some time later. Looks like @SkyC0der is giving you some answers while I'm typing, so I'll defer to that info....
Gulsvi
@gulsvi
Jul 20 2017 02:55
The more options the merrier ^^ :)
John
@AnonymousLords
Jul 20 2017 02:55
Guys why doesnt this work
Kevin Anderson
@LemonStain
Jul 20 2017 02:55
thanks @khaduch @SkyC0der - let me try that
CamperBot
@camperbot
Jul 20 2017 02:55
lemonstain sends brownie points to @khaduch and @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2164 | @skyc0der |http://www.freecodecamp.com/skyc0der
:star2: 3123 | @khaduch |http://www.freecodecamp.com/khaduch
John
@AnonymousLords
Jul 20 2017 02:56

function multiplyAll(arr) {
  var product = 1;

  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr.length; j++) {
     product *= arr[i];
    }
  }
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Gulsvi
@gulsvi
Jul 20 2017 02:57
@AnonymousLords I'm terrible at these lol :p but if I can try to help, I think your second loop needs to look at the length of the subarray rather than the initial (main) array.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 02:57
With 2d array, length of "inner" arrays is not necessarily the same as that of the outer array.
John
@AnonymousLords
Jul 20 2017 02:57
whoops typo
okay ehres the new code
Ogundele Olumide
@Lumexralph
Jul 20 2017 02:57
@AnonymousLords if your outer loop is to index the inner array, then the inner loop should be for (var j = 0; j < arr[i].length ......)
John
@AnonymousLords
Jul 20 2017 02:58

function multiplyAll(arr) {
  var product = 1;

  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
     product *= arr[i];
    }
  }
  return product;
}
Ogundele Olumide
@Lumexralph
Jul 20 2017 02:58
@AnonymousLords then you need to access all the elements of the sub-arrays
Gulsvi
@gulsvi
Jul 20 2017 02:58
now it would help to console.log arr[i] and see what you're trying to multiply :)
Ogundele Olumide
@Lumexralph
Jul 20 2017 02:58
@AnonymousLords arr[i][j]
John
@AnonymousLords
Jul 20 2017 02:58
Oh
Thanks guys @Lumexralph @SkyC0der @kumquatfelafel
CamperBot
@camperbot
Jul 20 2017 02:59
anonymouslords sends brownie points to @lumexralph and @skyc0der and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 504 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 2165 | @skyc0der |http://www.freecodecamp.com/skyc0der
:star2: 2039 | @lumexralph |http://www.freecodecamp.com/lumexralph
kumquatfelafel
@kumquatfelafel
Jul 20 2017 02:59
also arr[i] in a 2d array refers to an entire subarray, not a specific element of subarray
Ogundele Olumide
@Lumexralph
Jul 20 2017 02:59
@AnonymousLords i understand that feeling :wink:
John
@AnonymousLords
Jul 20 2017 02:59
i amde a typo :P
Gulsvi
@gulsvi
Jul 20 2017 02:59
llo
:)
John
@AnonymousLords
Jul 20 2017 03:00
llo
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:01
function mutation(arr) {
  /* here inside the loop i make everyword into lower case for sake
  of comparison, then i split it into individual words
  then i sort them and join them back into their original
  place of the array */
  for (var i = 0; i < arr.length; i++) {
    arr[i] = arr[i].toLowerCase().split("").sort().join(""); 
  }
  console.log(arr);

  /* here what im trying to do is to check if the letters on one
  side are the same as in the other side*/

  if (arr[0].indexOf(arr[1]) == arr[1].indexOf(arr[1])) {
    return true;
  } else {
    return false;
  }

}

mutation(["hello", "hey"]);
hey people
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:01
hiya
John
@AnonymousLords
Jul 20 2017 03:01
Hiya
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:01
im having some problem with this challenge
John
@AnonymousLords
Jul 20 2017 03:02
Im logging off, @kumquatfelafel @SkyC0der can help you :P
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:02
dw
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:02
@mauriciodeleonc as soon as you returnfunction is halted and returns with that value.
John
@AnonymousLords
Jul 20 2017 03:02
I did 5 challanges today and learned a lot about loops
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:03
actually, gimme a little more time to look at code. didn't see for loop
p.s. you can make comments look like... well... comments by adding js after first set of back ticks like so
```js
code here
```
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:04
ohhh okay okay haha
didnt know that
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:05
yeah... certain things are only clarified over time :p
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:06
@mauriciodeleonc you need to check if every character in arr[1] exists in arr[0] before you can conclude there's a mutation
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:07
well thats what im trying to do in my if else
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:08
@mauriciodeleonc doing this if (arr[0].indexOf(arr[1]) == arr[1].indexOf(arr[1])) will take a whole string and check if its index exists in arr[0] it should be each characters
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:08
tbh im not sooo sure how the indexOf works
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:08

Okay, yeah. :point_up:

so what you are doing here... arr[0].indexOf(arr[1]) == arr[1].indexOf(arr[1]) is wrong.

Consider : Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".

mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:09
yeah thats why im first sorting them in alphabetic order
since always the [1] will be the shortest then thats where i´ll be comparing from
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:10
@mauriciodeleonc line becomes eiln, which is index 1 of Aeiln, which !== index 0
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:11
you have ["Alien","line"]
then sorting them in the for loop gives
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:11
arr[1].indexOf(arr[1]) basically searches for word in itself. Which gives you index 0
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:11
@mauriciodeleonc what i'll suggest is use a loop, index each characters of the second element in arr that's arr[1][index] to get each character , then you check it's index in arr[1]
if(arr[0].indexOf(arr[1][loop iterator]) === -1)  {
   say there's no mutation
}
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:11
["aeiln","eiln"]
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:12
@mauriciodeleonc yes. And the index of eiln in aeiln and eiln is not the same.
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:12
yeah but indexOf looks for what it does have in common doesnt it?
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:13
@mauriciodeleonc indexOf returns the index where the given string you're searching for starts, or -1 if isn't present.
So "Hello World".indexOf("lo") would return 3, e.g.
and "Hello World".indexOf("Hello World") would return 0
and "Hello World".indexOf("Hello Worlds") would return -1
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:17
if (arr[0].includes(arr[1])) {
  console.log(arr[0].includes(arr[1]));
    return true;
  } else {
    return false;
  }
i changed the .includes
now it gives me all the "trues" but not the "false"
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:18
@mauriciodeleonc the best way to tackle this is, in the loop check if any of the characters is not present in arr[0] return false
@mauriciodeleonc then out of the loop, return true....which means once the loop is done and all the characters exists, the branch/conditiional statement will not be executed, then you return true
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:20
and how i check if the characters are present?
like...which is the function?
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:20
@mauriciodeleonc includes is okay, you can use indexOf too
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:22
but for example...the code i posted above, is it missing something?
as in, missing in the statement
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:22
@mauriciodeleonc just some logic
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:22
but it doesnt require a:
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:23
@mauriciodeleonc it needs a kind of looping too
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:23
if (arr[0].includes(arr[1]) == true) {
  console.log(arr[0].includes(arr[1]));
    return true;
  } else {
    return false;
  }
like that true at the beginning?
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:25
@mauriciodeleonc true is not needed if() runs if the expression in the brackets returns true and doesn't if it's false
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:26
okay okay
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:27
@mauriciodeleonc let me know what you come up with
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:27
still trying to put some logic into that comparing in the if statement you told me
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:28
In code above, you are checking entire words. all the characters in for are found in floor, but floor.includes("for") would return false. So as @Lumexralph says, best to check character by character.
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:28
i mean, i get you..but still thinking how to write it
@kumquatfelafel but why would it return false if i already sorted them out
oohhhh
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:29
@mauriciodeleonc what do you think sorting does?
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:29
because flo != for
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:29
yeah
@kumquatfelafel just noticed that
hahaha
@Lumexralph from what i understood sort "rewrites" in alphabetical order for letters or from small to big in numbers
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:31
@mauriciodeleonc so why were you sorting initially ? when all you need to check was if the character was present, so I don't think order of the characters matters here
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:31
@mauriciodeleonc another thing is, if you're checking character by character, no reason to really bother sorting anymore
Manish Giri
@Manish-Giri
Jul 20 2017 03:31
@Lumexralph wanna help me with some regex?
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:32
@Manish-Giri not my strength but I can give it a shot
shoot
Manish Giri
@Manish-Giri
Jul 20 2017 03:32
haha
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:32
@Lumexralph i sorted because i didnt know of the existance of .includes
and didnt know how to solve it with indexOF
Jean-Paul Sauve
@jp-sauve
Jul 20 2017 03:32
I'm working on Intermediate challenge "Spinal Tap Case", and I'm almost done. I can code a loop to do what I want, but it's a workaround for something I don't seem to be getting. Why is my code returning empty strings in between the words?

function spinalCase(str) {
  var spinalString = "";
  var myRegX = new RegExp(/[A-Z]?[a-z]*/,'g');
  var tempArr = str.match(myRegX).forEach;

  console.log(str.match(myRegX));
  return spinalString;
}

spinalCase('This Is Spinal Tap');
mauriciodeleonc
@mauriciodeleonc
Jul 20 2017 03:32
existence*
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:33
@Manish-Giri yeah.... but doesn't mean I won't solve it or be close
Manish Giri
@Manish-Giri
Jul 20 2017 03:33
given a string, I need to remove all occurrences of ! except at the end
@Lumexralph
like "Hi! Hi!" should give "Hi Hi!"
I tried [^!]$, won't work
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:33
@mauriciodeleonc with indexOf you can essentially take advantage of the knowledge that if what you're searching for isn't present, it will return -1 (and this is only time it will return -1)
Jean-Paul Sauve
@jp-sauve
Jul 20 2017 03:34
oops sorry I forgot. remove the var tempArray line.
@Manish-Giri look for the word boundary regex
Manish Giri
@Manish-Giri
Jul 20 2017 03:34
\b
I wanted to know why this won't work
Jean-Paul Sauve
@jp-sauve
Jul 20 2017 03:35
because it will match any non ! at the end of the input.
instead of any ! except for one followed by end of input
Manish Giri
@Manish-Giri
Jul 20 2017 03:36
yeah doesn't work either
Moisés Man
@moigithub
Jul 20 2017 03:36
positive/negative look ahead ?
Manish Giri
@Manish-Giri
Jul 20 2017 03:36
aw crap
those are complicated
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:37
yeah... feel relatively comfortable with regex except for those :p
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:37
@Manish-Giri :laughing: see I told you... still an area i need to improve on
Manish Giri
@Manish-Giri
Jul 20 2017 03:37
!(?!\b) - negative lookahead, doesn't work either
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:38
@Manish-Giri back to my book..... call when it's regex free
Manish Giri
@Manish-Giri
Jul 20 2017 03:38
lol
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:39
@Manish-Giri https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf followed by global replace followed by adding one back in at index - (old length - new length)? :laughing:
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:40
@Manish-Giri I think I have greatly improved in that aspect but hopefully will get free time to take it by the horns soon
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:40
@Manish-Giri wait what were you trying to do again?
Manish Giri
@Manish-Giri
Jul 20 2017 03:40
@kumquatfelafel I need to remove all occurrences of ! from a string, except the one at the end..
like "Hi! Hi!" should give "Hi Hi!"
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:41
@Manish-Giri what i'm thinking is using match gives you all the occurrences including the last in array, that information can give you a way to do it, not tried it though
Manish Giri
@Manish-Giri
Jul 20 2017 03:41
I tried the non regex way
function remove(s){
  //coding and coding....
  let chars = s.split('');
  for(let i = 0; i < chars.length;i++) {
    if(chars[i] === '!') { 
      if(i !== chars.length -1) {
         chars[i] = '';
      }
    }
  }
  return chars.join('');
}
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:42
@Manish-Giri did it work?
Manish Giri
@Manish-Giri
Jul 20 2017 03:42
dunno why it won't work
nope
Test Passed: Value == '\'Hi!\''
Test Passed: Value == '\'Hi!\''
Expected: '\'Hi!\'', instead got: '\'Hi\''
Test Passed: Value == '\'Hi!\''
Test Passed: Value == '\'Hi Hi!\''
Expected: '\'Hi!\'', instead got: '\'Hi\''
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:44
@Manish-Giri running code you posted on repl.it works at first glance. Is there a particular test case where it breaks? https://repl.it/JaAq
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:44
@Manish-Giri maybe you count the occurences of ! then you'll know which to avoid, the last... i don't like my suggestion but think there's a shot
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:44
ah. ok
Kevin Anderson
@LemonStain
Jul 20 2017 03:44
Hi
Manish Giri
@Manish-Giri
Jul 20 2017 03:44
@kumquatfelafel i don't even know why it removes the ! at the end , like from here - '\'Hi!\''
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:45
@Manish-Giri nah. still working on repl.it. Hi! got me Hi!
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:45
@Manish-Giri so what I can see from the test result is if ! is not more than 1 the ! should not removed
Manish Giri
@Manish-Giri
Jul 20 2017 03:45
obviously ! is not the last char here
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:45
oh wait. misread that sorry haha
Manish Giri
@Manish-Giri
Jul 20 2017 03:46
@Lumexralph @kumquatfelafel here's the challenge link
copy my code in there and run tests, I hve no idea why it fails
Jean-Paul Sauve
@jp-sauve
Jul 20 2017 03:46
Aside from being incomplete, why is match returning empty strings in the array for this regex?
function spinalCase(str) {
  var spinalString = "";
  var myRegX = new RegExp(/[A-Z]?[a-z]*/,'g');
  return spinalString;
  console.log(str.match(myRegX);
}

spinalCase('This Is Spinal Tap');
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:46
@Manish-Giri please don't take me there.... i might not get out sooner than I thought :worried:
Manish Giri
@Manish-Giri
Jul 20 2017 03:46
lol
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:47
@Manish-Giri okay for you i'll go
Manish Giri
@Manish-Giri
Jul 20 2017 03:47
:heart:
ooh I think I got it
@Lumexralph @kumquatfelafel got it!!
function remove(s){
  //coding and coding....
  let chars = s.split('');
  for(let i = 0; i < chars.length;i++) {
    if(chars[i] === '!') { 
      if(i !== chars.length -1) {
         chars[i] = '';
      }
    }
  }
  if(chars[chars.length -1] !== '!') {
   // append !
     chars[chars.length] = '!';
   }
  return chars.join('');
}
notice the last if at the end
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:52
@Manish-Giri was already digging and got an idea of how to solve, let me try my method if it does.... coming
Manish Giri
@Manish-Giri
Jul 20 2017 03:52
these guys really need to make their description clearer
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:53
@Manish-Giri :joy: good for you sggggggggggggm :smiling_imp:
Manish Giri
@Manish-Giri
Jul 20 2017 03:53
lol
Kevin Anderson
@LemonStain
Jul 20 2017 03:53
questions - how do I get into a CodePen that just froze (i think I created a bad loop) - each time i try it freezes
Ogundele Olumide
@Lumexralph
Jul 20 2017 03:53
@Manish-Giri that's why I hate some of their challenges, the test results and the question don't go 100% together at times
Manish Giri
@Manish-Giri
Jul 20 2017 03:54
@Lumexralph exactly
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:55

@Manish-Giri yeah... we were overcomplicating. Even this works fine.

return s.replace(/!/g,'') + '!'

Manish Giri
@Manish-Giri
Jul 20 2017 03:55
aha replace all ! then add one at the end
nice
Jean-Paul Sauve
@jp-sauve
Jul 20 2017 03:56
@LemonStain go to your profile and turn off auto update
kumquatfelafel
@kumquatfelafel
Jul 20 2017 03:57
@Manish-Giri I kinda want to get it to work for putting the final ! back in original location now though :p
Manish Giri
@Manish-Giri
Jul 20 2017 03:58
:smile:
Netrunner21
@Netrunner21
Jul 20 2017 04:00
I have a question about FCC policy. I found this smooth scroll js on stackoverflow. It's pretty short and does the trick for my portfolio. Am I supposed to credit the author?
$(document).on('click', 'a', function(event){
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $( $.attr(this, 'href') ).offset().top
    }, 500);
});
heroiczero
@heroiczero
Jul 20 2017 04:01
@Netrunner21 yes
@Netrunner21 probably a small footer to state your source maybe
Huỳnh Trần Khanh
@khanh2003
Jul 20 2017 04:01
@Netrunner21 no, as Stack Overflow code is MIT licensed.
Dovydas Stirpeika
@Giveback007
Jul 20 2017 04:02

heres a fun one

  function removeIngrd(num) {
    var elem = document.getElementsByClassName('ingrd-parent')[num];
    elem.parentNode.removeChild(elem);
  }

why the hell is me removing one element wrecks everything?
here's the pen:
https://codepen.io/giveback007/pen/dRrgqO

line 28 to 31
if you comment it out everything will work fine except removing elms
kumquatfelafel
@kumquatfelafel
Jul 20 2017 04:03

Alright, well... I'm sure it's not the best way, but it seems to work :laughing:

https://repl.it/JaAq/1

Ogundele Olumide
@Lumexralph
Jul 20 2017 04:05

@Manish-Giri

function remove(s){
  //coding and coding....  
    return `${s.replace(/!/g, "")}!`;  
}

that's my solution

Kevin Anderson
@LemonStain
Jul 20 2017 04:06
@SkyC0der I added the counter and it seems to work, but fail at one name for some reason. https://codepen.io/LemonStain/pen/eRqOYW?editors=0011
Ogundele Olumide
@Lumexralph
Jul 20 2017 04:07
@Manish-Giri or ES 6 way
const remove = (s) => `${s.replace(/!/g, "")}!`;
@Manish-Giri takes for taking me to that forest, I don't want to go back anytime soon, thanks
CamperBot
@camperbot
Jul 20 2017 04:09
lumexralph sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6285 | @manish-giri |http://www.freecodecamp.com/manish-giri
Dovydas Stirpeika
@Giveback007
Jul 20 2017 04:09
nwm I found another way to do it
Netrunner21
@Netrunner21
Jul 20 2017 04:10
@khanh2003 @heroiczero thanks. I'll add a little footer just in case.
CamperBot
@camperbot
Jul 20 2017 04:10
:cookie: 97 | @khanh2003 |http://www.freecodecamp.com/khanh2003
netrunner21 sends brownie points to @khanh2003 and @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1507 | @heroiczero |http://www.freecodecamp.com/heroiczero
Netrunner21
@Netrunner21
Jul 20 2017 04:11
This is it so far. I'm still learning design, so be easy on me. Still some work to do in the header area for sure
Kevin Anderson
@LemonStain
Jul 20 2017 04:13
Can someone guide me in the right direction - why am I getting the error that the prop is not available? https://codepen.io/LemonStain/pen/eRqOYW?editors=0010
everything is console.log'd
Huỳnh Trần Khanh
@khanh2003
Jul 20 2017 04:16
@LemonStain you are overstepping the array.
change i <= playerList.length to i < playerList.length
Kevin Anderson
@LemonStain
Jul 20 2017 04:20
@khanh2003 thanks. but i have 8 users in my list, and only 7 showing in my final data
CamperBot
@camperbot
Jul 20 2017 04:20
lemonstain sends brownie points to @khanh2003 :sparkles: :thumbsup: :sparkles:
:cookie: 98 | @khanh2003 |http://www.freecodecamp.com/khanh2003
Yuserah Din
@YuserahN
Jul 20 2017 04:31
What do you guys think of my Wikipedia Viewer?
https://codepen.io/Yuserah/full/EXzaNv/
Nick Gray
@nicholasnbg
Jul 20 2017 04:41
works well Yuserah, one little thing, it would be good to be able to hit 'enter' to search
M-C-Haker
@M-C-Haker
Jul 20 2017 04:47
blob
why wont codepend allow me to escape apostrophe?
heroiczero
@heroiczero
Jul 20 2017 04:48
@M-C-Haker there are two quotation in the begining
@M-C-Haker gotta escape the first one to escape the next one
" \"..... gotta escape that one i assume
M-C-Haker
@M-C-Haker
Jul 20 2017 04:50
@heroiczero oh right on thanks
CamperBot
@camperbot
Jul 20 2017 04:50
m-c-haker sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1509 | @heroiczero |http://www.freecodecamp.com/heroiczero
M-C-Haker
@M-C-Haker
Jul 20 2017 04:50
something so assinine just wasted 10 min of my life looking for a solution lol
__mifflin__
@cdrainxv
Jul 20 2017 04:53
If it was so asinine I would think you would have only wasted 9 minutes. :smile:
M-C-Haker
@M-C-Haker
Jul 20 2017 04:55
@cdrainxv you know how it is, getting lost in those stack overflow questions that people have to problems that are way more complex, but more interesting than the one's i have ha
Abhinav Mishra
@abhinav-m
Jul 20 2017 05:04
@Netrunner21 Wow, this is really good :)
M-C-Haker
@M-C-Haker
Jul 20 2017 05:14
@Netrunner21 your green simon button has no sound :smile:
surferpilgrim
@surferpilgrim
Jul 20 2017 05:20
does anyone know how to filter out even numbers of an array and only keep the odd values, shouold I use splice?
abraham anak agung
@padunk
Jul 20 2017 05:21
@surferpilgrim use modulo and filter method
kumquatfelafel
@kumquatfelafel
Jul 20 2017 05:22
@surferpilgrim What is 5%2?
M-C-Haker
@M-C-Haker
Jul 20 2017 05:23
@surferpilgrim yeah filter
surferpilgrim
@surferpilgrim
Jul 20 2017 05:23
@kumquatfelafel 2.5
M-C-Haker
@M-C-Haker
Jul 20 2017 05:24
@surferpilgrim try again..
surferpilgrim
@surferpilgrim
Jul 20 2017 05:24
@M-C-Haker the modulo gives the remainder right
kumquatfelafel
@kumquatfelafel
Jul 20 2017 05:25

5%2?
Nay. % gives you the remainder.

So if I were to say 12%10, 10 goes into 12 (fully) once, with a remainder of 2.

So 12%10 would be 2.

surferpilgrim
@surferpilgrim
Jul 20 2017 05:25
@kumquatfelafel so you filter based on the remainder
M-C-Haker
@M-C-Haker
Jul 20 2017 05:28
@surferpilgrim yeah
anyone else hate codepen like me? just seems so user-unfriendly
Netrunner21
@Netrunner21
Jul 20 2017 05:30
@M-C-Haker what browser are you using? Works fine in Chrome and Firefox.
Thanks! @abhinav-thinktank
CamperBot
@camperbot
Jul 20 2017 05:30
netrunner21 sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:cookie: 408 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
prakash chandra yadav
@prakashyadav008
Jul 20 2017 05:31
hey everyone
cam anyone help me out
M-C-Haker
@M-C-Haker
Jul 20 2017 05:32
@Netrunner21 i'm on chrome. works fine, don't get me wrong. It's just the layout for me
prakash chandra yadav
@prakashyadav008
Jul 20 2017 05:32
i am not able to assign the latitude and longitude value to the global variables
Netrunner21
@Netrunner21
Jul 20 2017 05:33
@M-C-Haker it's cool if you don't like the layout. Was curious why specifically the green button sound isn't working.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 05:33
@prakashyadav008 why are you redeclaring latitude and longitude?
Nick Gray
@nicholasnbg
Jul 20 2017 05:33
I do find working in codepen is annoying on my 13" screen, keep having to resize all the tabs/preview window constantly. I prefer to build locally and alt tab to a browser to preview
M-C-Haker
@M-C-Haker
Jul 20 2017 05:34
@Netrunner21 oh man i'm really sorry for the confusion! I had just mentioned i didn't like codepend and you happened to reply right after that. Codepen layout is what i was referring to fyi.
Netrunner21
@Netrunner21
Jul 20 2017 05:34
It's all good lol. Green button still not working?
M-C-Haker
@M-C-Haker
Jul 20 2017 05:35
Your portfolio page rocks man. I am on chrome though but am not getting any green simon button sound, just thought I'd let you know. if it's working for you might be something on my end
Netrunner21
@Netrunner21
Jul 20 2017 05:35
I gotcha. Thanks @M-C-Haker I've put a lot of time into it. Figured I'd do it last after I finished all my projects.
CamperBot
@camperbot
Jul 20 2017 05:35
:cookie: 266 | @m-c-haker |http://www.freecodecamp.com/m-c-haker
netrunner21 sends brownie points to @m-c-haker :sparkles: :thumbsup: :sparkles:
M-C-Haker
@M-C-Haker
Jul 20 2017 05:36
@Netrunner21 good idea, thought mine looked okay when i finished it but after seeing your definitely going to put a little more work into it
Nick Gray
@nicholasnbg
Jul 20 2017 05:37
@Netrunner21 can you link me your portfolio too?
M-C-Haker
@M-C-Haker
Jul 20 2017 05:37
wasn't ever really finished, i guess so i'll just "continue" working on it once i finish the others
Nick Gray
@nicholasnbg
Jul 20 2017 05:37
I'm getting close to the end of my front end cert and am going to build mine next
all good, found it, nice work man
Nick Gray
@nicholasnbg
Jul 20 2017 05:41
How long has it take you to finish the front end stuff?
Netrunner21
@Netrunner21
Jul 20 2017 05:41
It's not finished by any means. I'm going to dump some content into the main header area.
Nick Gray
@nicholasnbg
Jul 20 2017 05:41
your projects look a lot more presentable than mine haha, I really don't have an eye for design
Netrunner21
@Netrunner21
Jul 20 2017 05:41
I used to say that
haha
I even quit my Ad Agency job because of that
Nick Gray
@nicholasnbg
Jul 20 2017 05:42
I guess it's the same as anything else, learn and practice
Netrunner21
@Netrunner21
Jul 20 2017 05:42
I ran from design, but when I was making my portfolio page I realized I can't avoid design
I spend about 2 hours a day looking at websites to try to get some kind of feel for design
The front end projects took around 6 hours a piece.
though tic tac toe and simon took longer, in the 10 to 12 range.
I've spent 12 on the portfolio page so far.
Nick Gray
@nicholasnbg
Jul 20 2017 05:45
That's pretty good, yeah tic tac toe was pretty brutal for me haha, so far I've got 2 seperate ones, a working computer player one, and a 2 human player one, but still need to merge the two
Netrunner21
@Netrunner21
Jul 20 2017 05:45
Very cool.
Nick Gray
@nicholasnbg
Jul 20 2017 05:45
well they all look great man
Netrunner21
@Netrunner21
Jul 20 2017 05:45
Thanks man. Is your Tic Tac Toe intelligent?
I really enjoyed making that one.
Nick Gray
@nicholasnbg
Jul 20 2017 05:46
nah just random, that's still on the list, I need to get better at finishing what I start too.
Netrunner21
@Netrunner21
Jul 20 2017 05:46
That's such a double edged sword man
Finishing is important, but make sure what you're finishing is important.
hah
I have a ton of unfinished books and video games that drove me crazy for years, but they don't really matter, so I don't worry too much anymore
kumquatfelafel
@kumquatfelafel
Jul 20 2017 05:47
I need to get better at starting what I've started. :o
M-C-Haker
@M-C-Haker
Jul 20 2017 05:48
@kumquatfelafel lol samsies
Nick Gray
@nicholasnbg
Jul 20 2017 05:48
yeah I mean I want to get the front end cert without having half arsed my projects, so they are all important to me, but I'm also wanting to learn so many other things in webdev, react, vue, wordpress just to name a few
Netrunner21
@Netrunner21
Jul 20 2017 05:49
My advice would be to take your time and dont try and learn too many different things. You can get a mile wide and an inch deep really quick. The agency had me doing camera work, audio production, t-shirt designs, billboards, acting, voice over, web development, social media management, sales, etc.
I never felt like I could "stack" knowledge there because it was always something different.
prakash chandra yadav
@prakashyadav008
Jul 20 2017 05:52
@kumquatfelafel i changed it still not working ..how do i wait for the async geolocation call to complete
Netrunner21
@Netrunner21
Jul 20 2017 05:54
Thanks everyone for the comments, it's much appreciated.
Markus Kiili
@Masd925
Jul 20 2017 06:00
@prakashyadav008 You need to use the response inside the callback function.
Owais Ahmed
@owaisehmed
Jul 20 2017 06:05
Can someone please explain reduce method?
I'm not getting it
Markus Kiili
@Masd925
Jul 20 2017 06:06
@owaisehmed Sure. Have you looked at examples on MDN reduce page?
Owais Ahmed
@owaisehmed
Jul 20 2017 06:06
@Masd925 sorry which page?
MDN is the best JS source for specific topics.
Owais Ahmed
@owaisehmed
Jul 20 2017 06:08
@Masd925 thanks for this, ill try to go through it
CamperBot
@camperbot
Jul 20 2017 06:08
owaisehmed sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4315 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 20 2017 06:08
@owaisehmed If you don't get it, paste one example and we can go through it.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:12

@prakashyadav008

$(document).ready(function(){
    navigator.geolocation.getCurrentPosition(function(position) {
      latitude = position.coords.latitude;    
      longitude = position.coords.longitude;
      console.log(latitude);
      console.log(longitude);
      alert(latitude);
    });
});

Note that inside here, latitude and longitude are guaranteed to have value (assuming user allows to get location)

prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:17
i need t to asiggn the values to global variables
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:17
and?
Pieter Stokkink
@forkerino
Jul 20 2017 06:18
@prakashyadav008 be that as it may, but the values are only available in the callback.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:18
:point_up:
Pieter Stokkink
@forkerino
Jul 20 2017 06:19
Good morning, btw
Markus Kiili
@Masd925
Jul 20 2017 06:19
Morning.
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:19
oh shoot, it's 2:30am lol
Pieter Stokkink
@forkerino
Jul 20 2017 06:19
Hahaha
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:19
g'night. :laughing:
Pieter Stokkink
@forkerino
Jul 20 2017 06:19
Bedtime
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:20
its only available in callback but is there a way to wait for the async geolocation call
and then assign the values
i changed it ...using promises but still not working
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:20
@prakashyadav008 this seems like a lot of effort for not much reward
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:20
its about learning new concepts more or less
aim1909
@aim1909
Jul 20 2017 06:21
wrap it in a promise and use async/await
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:21
still not working though
Pieter Stokkink
@forkerino
Jul 20 2017 06:21
@prakashyadav008 there are a few ways. But a simple callback is the easiest way.
aim1909
@aim1909
Jul 20 2017 06:22
codepen is so buggy for me, unusable at times
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:22
is there any way to assign it to global variables
because then i could use it many times for different ajax calls
@forkerino
aim1909
@aim1909
Jul 20 2017 06:23
assigning to window will make them global
Markus Kiili
@Masd925
Jul 20 2017 06:23
@prakashyadav008 You are assigning to globals, but that doesn't work. You need to use the response inside the callback and perhaps make the second call there too.
Pieter Stokkink
@forkerino
Jul 20 2017 06:24
@prakashyadav008 you can assign all you want, but you need to use them at a point when you know they have a value
If you use a Promise you have to resolve the data that comes back, not pass resolve into the geolocation method
aim1909
@aim1909
Jul 20 2017 06:28
guess im retarded enough not bein able to use codepen. how on earth can i re-execute it??
Markus Kiili
@Masd925
Jul 20 2017 06:29
@aim1909 Doesn't it update automatically?
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:29
@aim1909 are you playing around with @prakashyadav008 code pen? if so, it should rerun automatically if you change it.
王想想
@wxxxxxxxx
Jul 20 2017 06:30
anyone there
aim1909
@aim1909
Jul 20 2017 06:31
yeah it actually does update automatically and i was looking for the setInterval in codepen silly me LOL
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:31
take a look
kumquatfelafel
@kumquatfelafel
Jul 20 2017 06:32
@prakashyadav008 latitude comes back undefined still.
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:32
ya .i am using the callback now
but still its undefined
Pieter Stokkink
@forkerino
Jul 20 2017 06:33
@prakashyadav008 yeah, with promise the data will still only be in the .then
王想想
@wxxxxxxxx
Jul 20 2017 06:33
@kumquatfelafel hello
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:33
@forkerino so i cant use .then to assign data to the global values
.?
aim1909
@aim1909
Jul 20 2017 06:34
i dont see the point of using a promise here anyways its going to throw on error i think
Pieter Stokkink
@forkerino
Jul 20 2017 06:34
@prakashyadav008 you can, but the alert will run before the value is assigned
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:35
@forkerino but the promise will the async finish first right and return the data
?
Pieter Stokkink
@forkerino
Jul 20 2017 06:36
@prakashyadav008 no. The code won't wait until the promise resolves.
王想想
@wxxxxxxxx
Jul 20 2017 06:37
switch usage
Pieter Stokkink
@forkerino
Jul 20 2017 06:37
If that would happen, a lot of websites would become incredibly slow.
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:37
will async and await work here..?
isnt there anyway to get the async data and then excute a function or assign the return data to global variables..?
Pieter Stokkink
@forkerino
Jul 20 2017 06:38
It can, but browser support is still lacking a bit
@prakashyadav008 callback promise generator, they can all work. Just do whatever you need to do with the data in the right place. I.e. inside callback/then/generator
Markus Kiili
@Masd925
Jul 20 2017 06:42
@prakashyadav008 You should forget the globals here and try to change the structure so that you use the response inside the callback.
prakash chandra yadav
@prakashyadav008
Jul 20 2017 06:43
@Masd925 ya ..i think the globals wont work....i am used to python and C language..so i thought of using globals
Pieter Stokkink
@forkerino
Jul 20 2017 06:43
:point_up:
Js isn't multi threaded
thinkC
@thinkC
Jul 20 2017 06:44
hello Campers...pls can someone help check what is wrong with my code...

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {  
  if((prop != "track") && (value != "")){
      collection[id][prop] = value;
  }
//   else if(collection[id].hasOwnProperty(prop) === null){
//       collection[id][prop] = [];
//   }

 else if(prop === "tracks" && collection[id].hasOwnProperty(prop) === null ){
   collection[id][prop] = [];
 }
 else if(prop === "track" && value != ""){
     collection[id][prop].push(value);


 }
  else if(value === ""){
      delete collection[id][prop];
  }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
aim1909
@aim1909
Jul 20 2017 06:45
please use a fiddle/codepen(urgh) with so much code
thinkC
@thinkC
Jul 20 2017 06:45
ok @aim1909
Pieter Stokkink
@forkerino
Jul 20 2017 06:46
@thinkC the first else if is never true
Might be smart to nest ifs too
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 06:48

@forkerino

Js isn't multi threaded

Web Workers?
SetTimeout
SetInterval

?????

thinkC
@thinkC
Jul 20 2017 06:48
@forkerino sorry , what do u mean to nest ifs
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 06:48
basically, anything asynchronous is inherantly threaded
child processes... etc.. all multithreaded
you usually don't need to worry about threading in JS but that doesn't mean js is not multithreaded
Pieter Stokkink
@forkerino
Jul 20 2017 06:49
@thinkC hard to type example on my phone, but put one inside the other.
thinkC
@thinkC
Jul 20 2017 06:51
ok @forkerino
Markus Kiili
@Masd925
Jul 20 2017 06:52
@SweetCodingInc JS engine is single threaded and runs one function at a time line by line. Browser in the other hand has other parts and can be multithreaded.
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 06:54
That's a bit misleading statement. The top level APIs exposed by JS engines run on main thread... It means you don't have to worry about thread handling on your own
However these are what they call onion APIs
there are layers upon layers of multi threaded APIs that you can use if you really want to get into it
Pieter Stokkink
@forkerino
Jul 20 2017 06:56
Hmmm
Owais Ahmed
@owaisehmed
Jul 20 2017 06:56
var array = [[4,0],[2,4,7,3]];
var singleVal = 0;

// Only change code below this line.

singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
}, 0);
@Masd925 what should this return?
Pieter Stokkink
@forkerino
Jul 20 2017 06:57
04,02,4,7,3?
Markus Kiili
@Masd925
Jul 20 2017 06:57
@owaisehmed The seems to be adding a number to an array, so something weird.
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 07:00
@owaisehmed for the sake of understanding, it is not a good practice to call first argument of .reduce callback previousVal. It's a bit misleading. The correct way to name it is accumulatedVal
var array = [[4,0],[2,4,7,3]];
var singleVal = 0;

// Only change code below this line.

singleVal = array.reduce(function(total, currentArray) {
  return currentArray.reduce(function(innerTotal, currentVal){
    return innerTotal + currentVal;
  },total)
}, 0);
Owais Ahmed
@owaisehmed
Jul 20 2017 07:03
@Masd925 why is it returning the numbers 04,02,4,7,3?
I just tried testing different codes and came up with this answer
@SweetCodingInc if i place the semicolon in the second last line of ur code, it would not include the last statement.
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 07:07
@owaisehmed it returns 04,02,4,7,3 becuase you have array of arrays. And when you use + operator on the operands whose typeof != number, it casts operands to strings..
and if you stringify array, you get comma separated representation of that array
[1,2]+[1] => 1,21
[1]+[1] => 11
Markus Kiili
@Masd925
Jul 20 2017 07:34
@SweetCodingInc For objects, the addition operator actually checks whether valueOf or toString method exists and returns a primitive value and then uses it when checking if either operand is a string. But for an array it goes like that.
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 07:49
:+1:
Ugo
@uvieugo
Jul 20 2017 08:12
Hey Y'all hows everyone
I need some help please, im currently working on the Tic Tac Toe challenge, and im stuck on how to create the Computer AI, here is what i have so far (https://codepen.io/uvieugo/full/dRxYpP/)
Huỳnh Trần Khanh
@khanh2003
Jul 20 2017 08:29
@uvieugo the computer doesnt need to be skilled
so make it plays randomly
Ugo
@uvieugo
Jul 20 2017 08:30
oh... okay i think i get it, but what if i would like to add some little skill.....just a tiny bit, how would i go about that
Markus Kiili
@Masd925
Jul 20 2017 08:45
@uvieugo You can fox example make it respond to threats of winning.
Huỳnh Trần Khanh
@khanh2003
Jul 20 2017 08:52
I need help real quick:
What does this error mean? (Node.js)
https://pastebin.com/CVvtus1D
abraham anak agung
@padunk
Jul 20 2017 09:00
Can someone take a quick look at this code? https://codepen.io/padunk/pen/WOVrQL?editors=1010
why is there a different output? I made same div using html and css and compare it with div make in JS with React.
Pieter Stokkink
@forkerino
Jul 20 2017 09:03
@khanh2003 your array is too big
Stanley Su
@stanley-su
Jul 20 2017 09:09

@padunk Isn’t it meant to be

<div class=‘color-items’>React</div>

?

@padunk Instead of className
abraham anak agung
@padunk
Jul 20 2017 09:11
@stanley-su not if you write it in react. Because class is a reserved word so react can't use it. so you have to write className instead
Stanley Su
@stanley-su
Jul 20 2017 09:12
@padunk Sorry! I probably shouldn’t have tried to help, I don’t even know react
abraham anak agung
@padunk
Jul 20 2017 09:12
@stanley-su np, it just confused me :smile: it is the same styling but the output is different
Jean-Luc
@daftbooy
Jul 20 2017 09:26
hello people i need help :( im lost
EpicTriffid
@EpicTriffid
Jul 20 2017 09:26

@EpicTriffid
Hi all. I'm working on my twitchAPI and i'm simplifying it myself first to just get it to console log each url I want to generate. Any idea where im going wrong with this?
var usernames = ["geekandsundry", "HardlyDifficult", "ESL_SC2", "OgamingSC2", "adobe", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb"]
var twitchAPI = "https://wind-bow.glitch.me/twitch-api/streams/";
var well = $(".well")

usernames.forEach(function () {
function genURL() {
for (var i = 0; i <= usernames.length; i++) {
twitchAPI + usernames[i]}
};
console.log(genURL)

Jean-Luc
@daftbooy
Jul 20 2017 09:29
:(((((
Tiago Correia
@tiagocorreiaalmeida
Jul 20 2017 09:29
hello everyone need a little help
var userChoice = prompt("Do you choose rock, paper or scissors?");
if(userChoice !== "rock" && userChoice !== "paper" && userChoice !== "scissors"){
    if(prompt("Error, would you like to choose again?") === true){
     userChoice = prompt("Do you choose rock, paper or scissors?");   
    }else{
        return "Maybe Another time!";
        }
}
shouldnt this work?
EpicTriffid
@EpicTriffid
Jul 20 2017 09:30
@daftbooy What's up?
Markus Kiili
@Masd925
Jul 20 2017 09:30
@EpicTriffid You are declaring and and logging a function once for each array element. Not executing it.
And is that the whole code? Some parens and braces missing.
EpicTriffid
@EpicTriffid
Jul 20 2017 09:31
@Masd925 Nope, not the whole code
@Masd925 the other stuff isn't related
@Masd925 I'm having a proper brainfart day
Tiago Correia
@tiagocorreiaalmeida
Jul 20 2017 09:32
return "Maybe Another time!";
this line gives me a erro?
error
Markus Kiili
@Masd925
Jul 20 2017 09:32
@EpicTriffid forEach already loops the array elements so no need to loop it again inside the callback I think.
aim1909
@aim1909
Jul 20 2017 09:32
Tiago you cannot return outside of a function maybe thats the problem
EpicTriffid
@EpicTriffid
Jul 20 2017 09:32
ok cool
Jean-Luc
@daftbooy
Jul 20 2017 09:32
@EpicTriffid im using onsen ui and firebase ive just created a login form email&password and work fine. but idk after that how to show another html page :(
im lost
Tiago Correia
@tiagocorreiaalmeida
Jul 20 2017 09:33
thanks @aim1909 just another question
CamperBot
@camperbot
Jul 20 2017 09:33
tiagocorreiaalmeida sends brownie points to @aim1909 :sparkles: :thumbsup: :sparkles:
:warning: @aim1909's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Tiago Correia
@tiagocorreiaalmeida
Jul 20 2017 09:34
if(prompt("Error, would you like to choose again?") === true){ this line dioesntwork tyhe wait I want
how can I confirm that the user said ok?
EpicTriffid
@EpicTriffid
Jul 20 2017 09:34
@Masd925 Nope, still brain farting. This really shouldnt be this hard
aim1909
@aim1909
Jul 20 2017 09:35
@tiagocorreiaalmeida assign the prompt function to a variable will save the answer
Markus Kiili
@Masd925
Jul 20 2017 09:36
@EpicTriffid I should most likely be usernames.forEach(function (name) {...} and then you would use name inside that callback. It holds each array element in its turn.
Tiago Correia
@tiagocorreiaalmeida
Jul 20 2017 09:41
@aim1909 I mean the confirm("");
it will just return a boolean (true/false)
Tiago Correia
@tiagocorreiaalmeida
Jul 20 2017 09:43
just saw it thanks mate :)
EpicTriffid
@EpicTriffid
Jul 20 2017 09:46
@Masd925 does "name" represent each element of the array?
Markus Kiili
@Masd925
Jul 20 2017 09:46
@EpicTriffid Yes, the forEach method passes each array element into the callback as name, or whatever parameter name you use.
EpicTriffid
@EpicTriffid
Jul 20 2017 09:47
@Masd925 oh god finally it clicked in my head. Thankyou!
CamperBot
@camperbot
Jul 20 2017 09:47
epictriffid sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4316 | @masd925 |http://www.freecodecamp.com/masd925
Chris Juchtmans
@kjuchtmans
Jul 20 2017 09:49
mornin coders of the brave new world! :wave:
Markus Kiili
@Masd925
Jul 20 2017 09:51
Morning.
aim1909
@aim1909
Jul 20 2017 09:51
good evening
Chris Juchtmans
@kjuchtmans
Jul 20 2017 09:52

'Arguments Optional' assignment: is addTogether(2)(3); correct function syntax?

This is one of the test calls.
But for the life of my I can't see how that is a function, let alone how to access 2 variables like this.

My code here returns a ...is not a function error

Any tips are welcome!
cheers, k

aim1909
@aim1909
Jul 20 2017 09:54
a = arguments[0]; b = arguments[1];
means it will take 2 parameters
so addTogether(2,3) would make more sense to me
=> 5
Markus Kiili
@Masd925
Jul 20 2017 10:08
@kjuchtmans addTogether(2) returns a function and (3) calls it.
Ken Haduch
@khaduch
Jul 20 2017 10:08
@kjuchtmans - this lesson is using the fact that a function can return another function - just as you can have a function stored in a variable in javascript. So the syntax addTogether(2)(3) is relying on the first function call to return a function, which is then invoked by the second set of parentheses, with 3 being the argument passed to it.
Markus Kiili
@Masd925
Jul 20 2017 10:08
So you need to check how many arguments are passed into addTogether
Ken Haduch
@khaduch
Jul 20 2017 10:10
@kjuchtmans - it is all about the Closures that they point to in the "Helpful Links" section.
Owais Ahmed
@owaisehmed
Jul 20 2017 10:11
newArray = oldArray.sort(concat(concatMe));
why doesnt this line work?
It says concat is not defined
Ken Haduch
@khaduch
Jul 20 2017 10:13
@owaisehmed - what are you trying to do here? Do yo u have a function named concat()?
Markus Kiili
@Masd925
Jul 20 2017 10:14
Or do you mean Array.prototype.concat ?
Owais Ahmed
@owaisehmed
Jul 20 2017 10:15
Yes, I'm actually doing trial and test of some of my code. I tried to concatenate two arrays and then sort them. But this doesnt work like this. Any leads how may i do it?
Markus Kiili
@Masd925
Jul 20 2017 10:15
@owaisehmed arr1.concat(arr2).sort(...)
Owais Ahmed
@owaisehmed
Jul 20 2017 10:17
@Masd925 thanks mate!
CamperBot
@camperbot
Jul 20 2017 10:17
owaisehmed sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4317 | @masd925 |http://www.freecodecamp.com/masd925
makalohri
@makalohri
Jul 20 2017 10:31
@knrt10 thanks you
CamperBot
@camperbot
Jul 20 2017 10:31
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 463 | @knrt10 |http://www.freecodecamp.com/knrt10
Nazar
@IsaakNazar
Jul 20 2017 10:35
does anyone understand html well?
Markus Kiili
@Masd925
Jul 20 2017 10:36
@IsaakNazar You can just ask the question here or https://gitter.im/FreeCodeCamp/HelpFrontEnd
Victor Popescu
@VicPopescu
Jul 20 2017 10:36
@IsaakNazar well, try asking in frontend chat
or both
Nazar
@IsaakNazar
Jul 20 2017 10:37
https://codepen.io/jordanamorais/pen/jyzBpB
this html is really new for me. can someone explain what type of html is this?
Markus Kiili
@Masd925
Jul 20 2017 10:40
@IsaakNazar It uses a html preprocessor called Pug, so the html looks different from the usual.
You can look at the settings tab where you can see what preprocessors or libraries are in use.
Nazar
@IsaakNazar
Jul 20 2017 10:41
@Masd925 ok thx amazing
CamperBot
@camperbot
Jul 20 2017 10:41
isaaknazar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4318 | @masd925 |http://www.freecodecamp.com/masd925
Nazar
@IsaakNazar
Jul 20 2017 10:42
@wonder2991 thx for the ling
CamperBot
@camperbot
Jul 20 2017 10:42
isaaknazar sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 410 | @wonder2991 |http://www.freecodecamp.com/wonder2991
Nazar
@IsaakNazar
Jul 20 2017 10:42
*link
wonder
@wonder2991
Jul 20 2017 10:43
np. :thumbsup:
Chris Juchtmans
@kjuchtmans
Jul 20 2017 10:54
@Masd925 @khaduch got it! had read the doc on Closures, wasn't clear to me from the examples they would take this syntax though. thanks guys
CamperBot
@camperbot
Jul 20 2017 10:54
kjuchtmans sends brownie points to @masd925 and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3126 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 4319 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 20 2017 10:56
@kjuchtmans There are a couple of ways to do it. You can construct the returned function, or use bind method on addTogether.
Blauelf
@Blauelf
Jul 20 2017 10:58
Liked that bind. Made me have my whole logic in one function.
Ken Haduch
@khaduch
Jul 20 2017 10:59
@kjuchtmans - that syntax itself has nothing to do with Closures - the addTogether(2)(3) is just JS function invocation - they just go hand-in-hand, I guess. At least that's the way I look at it. There are many crazy things in JS once you start to dig into it. The book "Eloquent JavaScript" has some real brain twisters! I should go back and look at that book again, now that I've had more time playing with this stuff - it might make more sense?
Owais Ahmed
@owaisehmed
Jul 20 2017 11:02

function reverseString(str) {
  var rev;
  var newStr="";
  for(var x=str.length; x>0;x--){
    rev = str.charAt(x-1);
    newStr = newStr + rev;
  }
  return newStr;
}

reverseString("hello");
Hey folks, has anyone done reverse string? If yes then share your answers please. I wanna see some other ideas too.
Markus Kiili
@Masd925
Jul 20 2017 11:03
@khaduch Some might argue that returning a function always has to do with closure. That always when you return a function you actually return a closure.
wonder
@wonder2991
Jul 20 2017 11:05
function reverseString(str) {
  return str.split('').reverse().join('');
}
@owaisehmed