These are chat archives for FreeCodeCamp/HelpFrontEnd

15th
Aug 2017
Gulsvi
@gulsvi
Aug 15 2017 00:33
@Trommelochse Sorry, didn't see the rest of your comments! I got mesmerized with the app and decided to make it with vanilla js :p
No idea what my highest 30-day score has been
I didn't even realize I was in the top spot :flushed:
https://codepen.io/skycoder/pen/xLXmEL?editors=0010
iso
@iso1048
Aug 15 2017 00:35
@SkyC0der bro, what is wrong with this (only returns [2,3]

function sumPrimes(num) {

  var arr=[];
  var isPrime = true;

  for (var i = 2; i<=num; i++){
    for (var j=2; j<i; j++){
     if (i%j ==0){
       isPrime = false;
     }
    }
    if (isPrime){
       arr.push(i);
    }
  }

  return arr;
}

sumPrimes(10);
Gulsvi
@gulsvi
Aug 15 2017 00:36
@gothamknight Walk through your double for loop - it does 2%2, 3%3, 4%4, etc
er.... 2%3 3%4 4%5
You want to take a number, for example 11 and do 11%2, 11%3, 11%4, 11%5 and if none of those return 0, it's prime
iso
@iso1048
Aug 15 2017 00:41
@SkyC0der why is it doing 2%3 3%4.... shouldn't the for loop with j loop through until j=i-1, then exit the loop and then increment i?
Trommelochse
@Trommelochse
Aug 15 2017 00:42
@SkyC0der really nice work man, just the functionality for alltime missing
Gulsvi
@gulsvi
Aug 15 2017 00:43
@Trommelochse Yeah, I didn't do sorting either, just putting up that up there to see if it's easier to just use JS :) I've been slow to pick up react!
Trommelochse
@Trommelochse
Aug 15 2017 00:45
very clean Vanilla, though
love it!
Gulsvi
@gulsvi
Aug 15 2017 00:46
Thanks! @Trommelochse
CamperBot
@camperbot
Aug 15 2017 00:46
skyc0der sends brownie points to @trommelochse :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @trommelochse |http://www.freecodecamp.com/trommelochse
Gulsvi
@gulsvi
Aug 15 2017 00:47
I can imagine react is a huge help with the sorting functionality - reading from the virtual dom has to make that a less-intensive process
Trommelochse
@Trommelochse
Aug 15 2017 00:47
your Javascript looks much shorter compared to mine, but then again: My Markup is there as well :D
Gulsvi
@gulsvi
Aug 15 2017 00:47
@gothamknight You're right, I console.logg'ed your code, let me dive in deeper to see why only two numbers are returned
Trommelochse
@Trommelochse
Aug 15 2017 00:49
@SkyC0der state makes a lot of things easier (and a lot of things harder...) ; But in general I have to say, that apps are more robust
you can put together components, easily debug them seperately, rearrange etc
without having to change a lot of your logic
Gulsvi
@gulsvi
Aug 15 2017 00:50
That makes a lot of sense
Ken Haduch
@khaduch
Aug 15 2017 00:50
@gothamknight - I found pseudocode for a primality test on this page and used that to generate an array of prime numbers. Not sure if that's the Sieve of Erastosthenes or not, but it works.
Trommelochse
@Trommelochse
Aug 15 2017 00:51
things are getting nasty when it gets more complex, though
Long Nguyen
@longnt80
Aug 15 2017 00:52

@SkyC0der @gothamknight

if (i%j == 0){
       isPrime = false;
     }

once it is false, it is just false and couldn't turn true again

Trommelochse
@Trommelochse
Aug 15 2017 00:52
using Flux architecture for my blog now... and even though it looks so simple on paper, it's still so confusing at times....
Long Nguyen
@longnt80
Aug 15 2017 00:53
@gothamknight https://repl.it/J9zr/26
Gulsvi
@gulsvi
Aug 15 2017 00:53
@longnt80 Thank you. I'm so bad at trying to get a grasp on someone else's JS and trying to make it work for them as they intended. I just want to rewrite it all from scratch and say "do it my way instead" :p
CamperBot
@camperbot
Aug 15 2017 00:53
skyc0der sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 498 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Aug 15 2017 00:54
@SkyC0der same here
Trommelochse
@Trommelochse
Aug 15 2017 00:54
guess that counts for most :(
Daniel
@DanJP2016
Aug 15 2017 01:02
I am working on my wiki viewer project and I was curious if the promise function I wrote was the correct way to use that feature, or if it was overkill for this type of project?
https://codepen.io/bones211/pen/GvMPOe?editors=0010
Long Nguyen
@longnt80
Aug 15 2017 01:04
@DanJP2016 how do make the live search?
Daniel
@DanJP2016
Aug 15 2017 01:04
it should automatically update as you type
Long Nguyen
@longnt80
Aug 15 2017 01:05
call the API at every input?
Daniel
@DanJP2016
Aug 15 2017 01:05
yes
i guess thats a bad idea though
Long Nguyen
@longnt80
Aug 15 2017 01:05
I'm new to Promise as well, but I guess if it's working then it is correct
Gulsvi
@gulsvi
Aug 15 2017 01:06
@DanJP2016 That promise looks great! You don't need a promise, but implementing it that way isn't overkill IMO
Gaurav
@gauravmagan
Aug 15 2017 01:06
trying to install webpack
Gulsvi
@gulsvi
Aug 15 2017 01:07
$.ajax and fetch() use promise() under the hood - whether you need that functionality or not
Gaurav
@gauravmagan
Aug 15 2017 01:07
for already developed template
Daniel
@DanJP2016
Aug 15 2017 01:07
@SkyC0der ah awesome thank you
CamperBot
@camperbot
Aug 15 2017 01:07
danjp2016 sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2391 | @skyc0der |http://www.freecodecamp.com/skyc0der
Daniel
@DanJP2016
Aug 15 2017 01:08
@longnt80 thanks man
CamperBot
@camperbot
Aug 15 2017 01:08
danjp2016 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 499 | @longnt80 |http://www.freecodecamp.com/longnt80
Gaurav
@gauravmagan
Aug 15 2017 01:08
is there any better way to configure webapp
juni
@junipberry
Aug 15 2017 01:08
sky, I can’t get the first even number to show false
function areBothOdd(num1, num2) {
  if (Math.abs((num1 && num2) % 2) ==1){
    return true;
    } else {
      return false;
    }
}
@SkyC0der
Gaurav
@gauravmagan
Aug 15 2017 01:08
to the template
is there any better way to configure webapp to the template
?
Gulsvi
@gulsvi
Aug 15 2017 01:09
@junipberry You'll need to use Math.abs(num) % 2 on each number, can't group them together like that.
juni
@junipberry
Aug 15 2017 01:10
oh okay
Gulsvi
@gulsvi
Aug 15 2017 01:10
Like if you wanted to know if both 3 and 5 are less than 7, you would do:
if(3 < 7 && 5 < 7)
Can't do
if(3 && 5 < 7)
juni
@junipberry
Aug 15 2017 01:11
got it. ty again @SkyC0der
CamperBot
@camperbot
Aug 15 2017 01:11
junipberry sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2392 | @skyc0der |http://www.freecodecamp.com/skyc0der
Can anyone tell me why the getLocation function doesn't work?
Gulsvi
@gulsvi
Aug 15 2017 01:11
No problem - always happy to help
Gaurav
@gauravmagan
Aug 15 2017 01:11
to the template
is there any better way to configure webapp to the template
?
yeoman generator is
outdated
Gulsvi
@gulsvi
Aug 15 2017 01:12
@EricHasegawa What does the variable displayedLoc refer to?
CallMeOrange
@EgnaroDev
Aug 15 2017 01:12
I think, you need to add .html() to show it somewhere @EricHasegawa
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:14
@SkyC0der It would ideally display the coordinates of the user on the page
Long Nguyen
@longnt80
Aug 15 2017 01:14
@junipberry why Math.abs(num1) % 2) ==1?
Daniel
@DanJP2016
Aug 15 2017 01:14
@EricHasegawa it does not look like you have the button attached to the function with a eventListener
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:15
@DanJP2016 How could I attach that?
Daniel
@DanJP2016
Aug 15 2017 01:15
i see it now, should'nt it be onclick instead of onClick?
juni
@junipberry
Aug 15 2017 01:15
@SkyC0der would the same logic work on a 'if or’? like:
function isEitherEven(num1, num2) {
  if (Math.abs(num1 % 2) || (num2 % 2) ===0) {
    return true;
    } else {
      false;
    }
}
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:16
@DanJP2016 Yeah I fixed that, it's still not working though
juni
@junipberry
Aug 15 2017 01:16
*not if or, either
Gulsvi
@gulsvi
Aug 15 2017 01:16
@EricHasegawa Your <br> tag will need quotes around it - and then you'll need to add displayedLoc to the HTML like you did with the code in your if / else earlier.
var displayedLoc = "Latitude: " + position.coords.latitude + '<br />' + "Longitude: " + position.coords.longitude;
@junipberry You need the === for both numbers
Long Nguyen
@longnt80
Aug 15 2017 01:17
@junipberry I don't think this will work:
(Math.abs(num1 % 2) || (num2 % 2) ===0)
Gulsvi
@gulsvi
Aug 15 2017 01:17
we need to have something that evaluates to true or false before and after every && or ||
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:18
@SkyC0der What have I done wrong now?
CallMeOrange
@EgnaroDev
Aug 15 2017 01:18
@EricHasegawa .append() is like +=
Long Nguyen
@longnt80
Aug 15 2017 01:18
@junipberry change to this:
Math.abs(num1) % 2 !== 0 && Math.abs(num2) % 2 !== 0
CallMeOrange
@EgnaroDev
Aug 15 2017 01:18
Each time you press a button
Gulsvi
@gulsvi
Aug 15 2017 01:18
@EricHasegawa displayedLoc is out of scope now - it needs to be inside your showPosition() function block
function showPosition(position) { 
  var displayedLoc = "Latitude: " + position.coords.latitude + '<br />' + 
      "Longitude: " + position.coords.longitude;
  $("#try").append(displayedLoc)
}
Hello orange :wave:
CallMeOrange
@EgnaroDev
Aug 15 2017 01:20
:wave:
CallMeOrange
@EgnaroDev
Aug 15 2017 01:20
:clap:
Gulsvi
@gulsvi
Aug 15 2017 01:20
It works ^^ :)
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:20
I did that as well, but still not working :/
CallMeOrange
@EgnaroDev
Aug 15 2017 01:20
Need space and fix .append()
Gulsvi
@gulsvi
Aug 15 2017 01:21
works for me - click the get location button and I see the lat + long on the page
Trommelochse
@Trommelochse
Aug 15 2017 01:21
working here as well ;)
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:22
Oh sweet it works! But it adds "on" to the paragraph at the top every time, any idea why?
CallMeOrange
@EgnaroDev
Aug 15 2017 01:22
Hm.. why this?
Lat
Lon + Lat
Lon + Lat
...
...
Lon
.append() might be the problem but I wonder how Lat show up on top and Lon on bottom
@EricHasegawa Because of .append(), it is like +=
juni
@junipberry
Aug 15 2017 01:23
function isEitherEven(num1, num2) {
  if (Math.abs(num1 % 2) ===0 || (num2 % 2) ===0) {
    return true;
    } else {
      false;
    }
}
@SkyC0der , I can’t get it to pass the test where 2 odds show false
CallMeOrange
@EgnaroDev
Aug 15 2017 01:23
lol
Gulsvi
@gulsvi
Aug 15 2017 01:23
(What orange said)
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:24
@EgnaroDev @SkyC0der Any way I can avoid this without restructuring the code entirely?
Gulsvi
@gulsvi
Aug 15 2017 01:24
@junipberry The || means one or the other. If you need them both, use &&
CallMeOrange
@EgnaroDev
Aug 15 2017 01:24
@EricHasegawa You might want to use something else instead of .append()
or you can empty html before its function
Gulsvi
@gulsvi
Aug 15 2017 01:25
@EricHasegawa .html() will overwrite the HTML every time. .append() adds to it
juni
@junipberry
Aug 15 2017 01:25
I want to either one to be even then show true. But one of the tests is to get 2 odds to be false
so I do want to use ||
Long Nguyen
@longnt80
Aug 15 2017 01:26
@junipberry no, you need &&
juni
@junipberry
Aug 15 2017 01:26
why?
isn’t that for both?
I want either
Eric Hasegawa
@EricHasegawa
Aug 15 2017 01:26
@EgnaroDev @SkyC0der I think I got it, thanks!
CamperBot
@camperbot
Aug 15 2017 01:26
erichasegawa sends brownie points to @egnarodev and @skyc0der :sparkles: :thumbsup: :sparkles:
:cookie: 551 | @egnarodev |http://www.freecodecamp.com/egnarodev
:star2: 2393 | @skyc0der |http://www.freecodecamp.com/skyc0der
Trommelochse
@Trommelochse
Aug 15 2017 01:27
function isEitherEven(num1, num2) {
  return (num1 % 2 === 0 || num2 % 2 === 0)
}
Gulsvi
@gulsvi
Aug 15 2017 01:27
Yeah, if you want either, then using || is the right way to go
juni
@junipberry
Aug 15 2017 01:27
it is passing 3 of 4 tests @SkyC0der
don’t know whats wrong
sorry, passing 4/5
Gulsvi
@gulsvi
Aug 15 2017 01:27
You may need Math.abs() on that second number too? @junipberry
juni
@junipberry
Aug 15 2017 01:28
I tried that
Gulsvi
@gulsvi
Aug 15 2017 01:28
Math.abs(num1 % 2) === 0 || Math.abs(num2 % 2) === 0
juni
@junipberry
Aug 15 2017 01:28
don’t think that is it
CallMeOrange
@EgnaroDev
Aug 15 2017 01:29
```js
:trollface: :trollface: :trollface: :trollface: :trollface: :trollface:
```
Long Nguyen
@longnt80
Aug 15 2017 01:30
@junipberry what's the test you didn't pass?
Gulsvi
@gulsvi
Aug 15 2017 01:30
@junipberry Do you know which numbers?
CallMeOrange
@EgnaroDev
Aug 15 2017 01:30
^ yeah?
Gulsvi
@gulsvi
Aug 15 2017 01:30
Your code is working for me
CallMeOrange
@EgnaroDev
Aug 15 2017 01:30
Which challenge is this?
juni
@junipberry
Aug 15 2017 01:30
its saying “should return false if both numbers are odd"
Gulsvi
@gulsvi
Aug 15 2017 01:31
Unless you also have to round the number maybe? Is a number a decimal?
Though... I don't know if something like "2.4" is even
Long Nguyen
@longnt80
Aug 15 2017 01:31
@junipberry it should be false
juni
@junipberry
Aug 15 2017 01:32
oh..like I would have to use Math.floor too?
Gulsvi
@gulsvi
Aug 15 2017 01:32
Can you see the numbers used for each test case?
Long Nguyen
@longnt80
Aug 15 2017 01:32
yeah, Math.floor is needed too
Gulsvi
@gulsvi
Aug 15 2017 01:33
The code that @Trommelochse put above should be sufficient, unless you need to round decimal numbers first
juni
@junipberry
Aug 15 2017 01:37
oh didn’t see that, ty @SkyC0der
CamperBot
@camperbot
Aug 15 2017 01:37
junipberry sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:warning: junipberry already gave skyc0der points
juni
@junipberry
Aug 15 2017 01:37
ty @Trommelochse
I got rid of the Math.abs and it worked. Forgot I don’t need it for ===0
Gulsvi
@gulsvi
Aug 15 2017 01:38
ahhh, that makes sense
juni
@junipberry
Aug 15 2017 01:38
only for when modulus ==1
:D yes, makes total sense whew
ty all~~
Trommelochse
@Trommelochse
Aug 15 2017 01:47
you are welcome :)
iso
@iso1048
Aug 15 2017 01:52
@longnt80 of course.
@SkyC0der @khaduch @longnt80 thanks
CamperBot
@camperbot
Aug 15 2017 01:52
gothamknight sends brownie points to @longnt80 and @skyc0der and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 500 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 2394 | @skyc0der |http://www.freecodecamp.com/skyc0der
:star2: 3204 | @khaduch |http://www.freecodecamp.com/khaduch
Kevin L Wei
@kevinlwei
Aug 15 2017 01:55
Hey peeps! Can anyone tell me why none of my CSS is working? :'(
Working on personal webpage
https://github.com/kevinlwei/me/blob/master/index.html
but none of my css (inline or import) will display. Trying to make a sidebar with a top and left margin :/
iso
@iso1048
Aug 15 2017 02:00
@SkyC0der bro
@longnt80 bro
Long Nguyen
@longnt80
Aug 15 2017 02:05
@gothamknight hey
iso
@iso1048
Aug 15 2017 02:09

@longnt80 I managed to pass that sum primes challenge, but I am looking back at another approach i had to solve it and something strange happens.


function sumPrimes(num) {

  var arr=[];
  var isPrime = true;

for (var i = 2; i <=num; i++){
    if (i%2 !==0){
      arr.push(i);
    }
  }
  arr.unshift(2);
  for (var j = 1; j<arr.length; j++){
    for (var q = 2; q <=1000; q++){
      if (arr.indexOf(arr[j]*q) !== -1){
        var x = arr.indexOf(arr[j]*q);
        arr[x] = 0;
      }
    }
  }
  arr = arr.reduce(function(a,b){return a+b;});
  return arr;
}

sumPrimes(10);

above is my alternative approach - I am able to pass the challenge with this. however, when I replace sumPrimes(10) with sumPrimes(977), I cannot pass the challenge because it says I have a potential infinite loop with this line for (var q = 2; q <=1000; q++){.
I tested the code with sumPrimes(977) on repl.it and it runs.
What is going on with that?

Long Nguyen
@longnt80
Aug 15 2017 02:09
@gothamknight nothing wrong
just a safeguard from FCC to prevent infinite loop
iso
@iso1048
Aug 15 2017 02:10
But even repl.it has a safeguard to prevent an infinite loop and it still worked on there.
Long Nguyen
@longnt80
Aug 15 2017 02:10
I think you need to write some code at the top to bypass it
@gothamknight add this at the top: //noprotect
iso
@iso1048
Aug 15 2017 02:16
@longnt80 cool. thanks
CamperBot
@camperbot
Aug 15 2017 02:16
gothamknight sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: gothamknight already gave longnt80 points
Long Nguyen
@longnt80
Aug 15 2017 02:18
@gothamknight :+1:
Daniel
@DanJP2016
Aug 15 2017 02:36
nothing fancy but i'm finished with my Wikipedia viewer project.
https://codepen.io/bones211/full/GvMPOe/
Long Nguyen
@longnt80
Aug 15 2017 02:39
@DanJP2016 I found a bug
@DanJP2016 after typing some thing to search, I backspaced to an empty string, then the result is not correct anymore
Daniel
@DanJP2016
Aug 15 2017 02:40
it should be a blank screen if the string is empty, is it showing something else for you?
Long Nguyen
@longnt80
Aug 15 2017 02:40
you need to to type at least 2 characters first
let me take a screenshot
@DanJP2016 wait, it only happens when I maximized my browser, let me check
Daniel
@DanJP2016
Aug 15 2017 02:42
sometimes the page is slow to update, that may be because of the way i wrote the api call.
Long Nguyen
@longnt80
Aug 15 2017 02:43
maybe, it's weird bug
@DanJP2016 let me send the screenshot anyway, just in case
Daniel
@DanJP2016
Aug 15 2017 02:44
ok
Long Nguyen
@longnt80
Aug 15 2017 02:44
Capture.JPG
could be something with my browser/computer
Daniel
@DanJP2016
Aug 15 2017 02:45
what browser are you using?
Kevin
@kevinwr
Aug 15 2017 02:45
Well, about to start my first Computer Science course at my university, and it looks like they are having us learn Java. Anyone know of some good Java resources for beginners that I could use while going through the course?
Long Nguyen
@longnt80
Aug 15 2017 02:46
@DanJP2016 Chrome/Windows 10
Daniel
@DanJP2016
Aug 15 2017 02:46
@kevinwr i think codecademy has a java tutorial. not sure how in depth it goes though
@longnt80 ok thank you let me do some testing real quick and see if I can track it down.
CamperBot
@camperbot
Aug 15 2017 02:47
danjp2016 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 501 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Aug 15 2017 02:47
@DanJP2016 but as soon as I try to inspect it with the devtool, it goes away
so not sure what it is
Daniel
@DanJP2016
Aug 15 2017 02:50
i see it now, the wiki api is throwing an error because the search string is empty. thought i had that fixed with the find !== null statement.
Manan Shah
@mananshah51
Aug 15 2017 03:36
Between the style tags, give the p elements font-size of 16px. Browser and Text zoom should be at 100%.
Ravi Kishore Thella
@ravikishorethella
Aug 15 2017 03:36
@mananshah51 show what you did
Manan Shah
@mananshah51
Aug 15 2017 03:37

@ravikishorethella

<style>
.red-text {
color: red;
font-size: 16px;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched</p>

Ravi Kishore Thella
@ravikishorethella
Aug 15 2017 03:37
@mananshah51 font-size is to be given for the p tag not for the .red-text class
Manan Shah
@mananshah51
Aug 15 2017 03:59
@ravikishorethella Thank you so much for the help, really appreciate it.
CamperBot
@camperbot
Aug 15 2017 03:59
mananshah51 sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:star2: 1000 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Ravi Kishore Thella
@ravikishorethella
Aug 15 2017 04:00
@mananshah51 :+1:
Lallo Vigil
@lalov1
Aug 15 2017 04:00
I'm pretty close to being finished with the Simon game, but can't figure out why all the buttons go off at the same time: https://codepen.io/lalov1/full/MvgvxY/
heroiczero
@heroiczero
Aug 15 2017 04:03
@kevinwr https://github.com/EbookFoundation/free-programming-books there are some free resources here
heroiczero
@heroiczero
Aug 15 2017 04:08
@DanJP2016 Well your wikipedia works well. Rating: 5 :star:
heroiczero
@heroiczero
Aug 15 2017 04:14
@kevinlwei <div class="border: black; width: 20vw;"> this is not inline style. you have to use style=""
Daniel
@DanJP2016
Aug 15 2017 04:14
@heroiczero thank you
CamperBot
@camperbot
Aug 15 2017 04:14
danjp2016 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1610 | @heroiczero |http://www.freecodecamp.com/heroiczero
Gaurav
@gauravmagan
Aug 15 2017 05:13
hi guys does anyone know the easiest way to set up webpack
npardon
@npardon
Aug 15 2017 05:20
hey guys I have been trying to figure this out I can't get past this challenge:

var count = 0;

function cc(card){
  // Only change code below this line
  switch(card){
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count= count +=1;
      break;
    case 7:
    case 8:
    case 9:
      count= count +=0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count= count -=1;
      break;
  }

  if (count <= 0){
    return (count) + " Hold ";
  } else { 
    return (count) + " Bet ";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
}
Gaurav
@gauravmagan
Aug 15 2017 05:22
Gaurav Kumar Magan @gauravmagan 01:13
hi guys does anyone know the easiest way to set up webpack
Markus Kiili
@Masd925
Aug 15 2017 05:41
@npardon Just count+=1 etc
return count + " Bet"; <- no trailing space.
npardon
@npardon
Aug 15 2017 05:55
@Masd925 I tried that it still will not work but thanks
CamperBot
@camperbot
Aug 15 2017 05:55
npardon sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4413 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 15 2017 05:55
@npardon Post the code again.
npardon
@npardon
Aug 15 2017 05:59
@Masd925 thanks that worked
CamperBot
@camperbot
Aug 15 2017 05:59
npardon sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: npardon already gave masd925 points
Markus Kiili
@Masd925
Aug 15 2017 06:00
@npardon :+1:
Xi
@yuman959
Aug 15 2017 07:25
Hi friends, my code for “Search and Replace” doesn’t work. Anybody know why?

function myReplace(str, before, after) {

 if (before.charAt(0) == before.charAt(0).toUpperCase()){
   after = after.chatAt(0).toUpperCase() + after.slice(1);
 }

  str= str.replace(before,after);
  return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 07:26
Try using simple RegEx for finding and replacing strings
iso
@iso1048
Aug 15 2017 07:38
@yuman959 after.charAt instead of after.chatAt - spelling error
Trommelochse
@Trommelochse
Aug 15 2017 08:28
I find arrays to be more convenient @yuman959
function myReplace(str, before, after) {
str = str.split(' ');
str.splice(str.indexOf(before), 1, after);
return str.join(' ');
}
Tanushree Samanta
@TSamanta
Aug 15 2017 10:04
hi should how good id pluralsight?
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 10:04
It's not free @TSamanta
Tanushree Samanta
@TSamanta
Aug 15 2017 10:05
yeah but should I do pluralsight plus free videos or should I take courses available offline?
i am just confused
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 10:06
Start with the free ones
What topics you are looking for?
Tanushree Samanta
@TSamanta
Aug 15 2017 10:06
i have done basic stuff using free videos
the topic I ma looking for now is basic and advanced js with a framework such as react
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 10:07
Ok
Tanushree Samanta
@TSamanta
Aug 15 2017 10:08
so currently I am doing from free videos but people say offline classes are not upto the mark I dunno
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 10:14
ok
Teo
@Teo03
Aug 15 2017 10:30
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  var keys = Object.keys(source);
  // Only change code below this line
  for(var i = 0; i < keys.length; i++){
    if(collection.hasOwnProperty(keys[i]) === source.hasOwnProperty(keys[i])){
      arr.push(source);
    }
  }
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Can someone help I don't know what is wrong with my code?
korzo
@korzo
Aug 15 2017 10:32
@Teo03 What's the name of challenge?
Teo
@Teo03
Aug 15 2017 10:33
@korzo Wherefore art thou
Markus Kiili
@Masd925
Aug 15 2017 10:33
@Teo03 You need two nested loops or iterations through collection and keys.
@Teo03 You only keep those objects (collection elements) that have matching property values with source for all the source's keys. So a loop solution needs some loop logic.
korzo
@korzo
Aug 15 2017 10:34
@Teo03 Collection is array, not object
Teo
@Teo03
Aug 15 2017 10:36
@Masd925 @korzo thanks a lot!
CamperBot
@camperbot
Aug 15 2017 10:36
teo03 sends brownie points to @masd925 and @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @korzo |http://www.freecodecamp.com/korzo
:star2: 4416 | @masd925 |http://www.freecodecamp.com/masd925
Roxroy
@roxroy
Aug 15 2017 10:55
@TSamanta , I use pluralsight alot. I use to to go over topics that are relevant to my project. I also use plenty of blogs and the free videos to complement and to cement the concepts. Then I begin the fcc project. If I get stuck I will review the videos. It takes lot of preparation for the the backend and frontend projects.
Tchr. Joe Gachau
@tchrjoegachau
Aug 15 2017 11:05
How do i put unordered list below the underlined element in this code: https://codepen.io/tchrjoegachau/pen/YxrVgW?
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 11:06
<ul> tag?
Tchr. Joe Gachau
@tchrjoegachau
Aug 15 2017 11:07
But the tag is putting the list on top of the underlined element instead of there below https://codepen.io/tchrjoegachau/full/YxrVgW/
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 11:09
I can't see the tag in your code anywhere
Tchr. Joe Gachau
@tchrjoegachau
Aug 15 2017 11:11
I tried putting the tag below each underlined element but all of the listed items went above my underlined elements. I have deleted the <ul> tags
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 11:12
what's the <p1> tag? no such tag exists in HTML. Remove the <head> tag, CodePen HTML window only recommends the content that would appear inside the <body>
Tchr. Joe Gachau
@tchrjoegachau
Aug 15 2017 11:13
Thanks @NitinNair89
CamperBot
@camperbot
Aug 15 2017 11:13
tchrjoegachau sends brownie points to @nitinnair89 :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @nitinnair89 |http://www.freecodecamp.com/nitinnair89
Tanisha Garg
@TanishaGarg
Aug 15 2017 12:39
How do I adjust the space outside of my jumbotron bakground
Thayyeb salim
@Thayyebsalim
Aug 15 2017 12:40
background position would do well
@TanishaGarg
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 12:40
@TanishaGarg adjust its margin
can you post your code?
Tanisha Garg
@TanishaGarg
Aug 15 2017 12:44
@NitinNair89 yes
<div class="jumbotron background"> And this is the css document maintaining the properties of background .background { background-color: #FFFFCC; background-position: center; }
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 12:46
and how does it look and how you want it to look
?
Tanisha Garg
@TanishaGarg
Aug 15 2017 12:48
@NitinNair89 thanks, I specified the margins and now it works perfectly
CamperBot
@camperbot
Aug 15 2017 12:48
tanishagarg sends brownie points to @nitinnair89 :sparkles: :thumbsup: :sparkles:
:cookie: 454 | @nitinnair89 |http://www.freecodecamp.com/nitinnair89
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 12:48
@TanishaGarg :+1:
:)
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:06
How can I adjust space b/w lines in Html
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 13:07
line-height CSS property
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:07
Like some lines which contain bigger text are automatically having more spaces b/w it and the next line
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 13:08
line-height CSS property Check this once, not sure if it will help
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:10
@NitinNair89 It did, thanks again!
CamperBot
@camperbot
Aug 15 2017 13:10
tanishagarg sends brownie points to @nitinnair89 :sparkles: :thumbsup: :sparkles:
:warning: tanishagarg already gave nitinnair89 points
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 13:12
:)
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:13
And what's wrong with this way of adding a background image? background : "Quant.jpg";
Nitin Chandran Nair
@NitinNair89
Aug 15 2017 13:13
Does the image exist in the same location as the code?
use the background-image:url('...') css property
korzo
@korzo
Aug 15 2017 13:18
@TanishaGarg this way image path is relative to file, where this code is
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:19
@NitinNair89 Yes, they exist in the same folder
Nicol
@NicolNonga
Aug 15 2017 13:33
@NicolNonga
working in my wheater app help me please i can not get the json file
var localwheaterApi= 'openweathermap.org/data/2.5/weather?lat='+mlatitude+'&lon='+mlongitude+'&appid=6ab6456e50beb0ef672b8db38175174f';

$.getJSON(localwheaterApi, function(dados){

console.log( mlongitude);
});
});
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:43
What's wrong with this way of adding a background image? background : "Quant.jpg";
@NitinNair89
@korzo
Josh Daniell
@joshdaniell
Aug 15 2017 13:44
Rookie question - why isn't $("#selectSide").modal("hide"); working when you click on either button in the modal? https://codepen.io/joshdaniell/pen/jLGKqw?editors=1010
korzo
@korzo
Aug 15 2017 13:44
@TanishaGarg It's relative path and depend on location of css image file
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:45
@korzo But the image and the code are located in the same folder
korzo
@korzo
Aug 15 2017 13:46
@TanishaGarg Then check developer console in browser for error
Maybe wrong filename or background doesn't show up for other reasons
Markus Kiili
@Masd925
Aug 15 2017 13:49
@TanishaGarg Shouldn't it be like background : url("Quant.jpg")
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:50
@Masd925 Not when they are in the same folder
Markus Kiili
@Masd925
Aug 15 2017 13:51
@TanishaGarg ok
Tanisha Garg
@TanishaGarg
Aug 15 2017 13:55
Can anyone tell me how can i add an image in b/w a paragraph such that the paragraph adjusts itself on all sides of the image
?
@korzo any suggestions
Ken Haduch
@khaduch
Aug 15 2017 13:58
@TanishaGarg - there are probably many ways to do it - here is an article about using float to do it.
korzo
@korzo
Aug 15 2017 13:58
@TanishaGarg I think @Masd925 is right. you have wrong syntax
Markus Kiili
@Masd925
Aug 15 2017 13:59
@korzo I checked the specification and all the cases have the url there.
@TanishaGarg
korzo
@korzo
Aug 15 2017 14:00
@Masd925 right, you can't use it without url.()
Tanisha Garg
@TanishaGarg
Aug 15 2017 14:02
Yeah, it's working now! Thanks @Masd925 and @khaduch
CamperBot
@camperbot
Aug 15 2017 14:02
tanishagarg sends brownie points to @masd925 and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 4417 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 3206 | @khaduch |http://www.freecodecamp.com/khaduch
Peter Steele
@PeterHSteele
Aug 15 2017 14:05
@joshdaniell .modal isn't a jquery method, it's a selector. $("#selectSide").hide() should do the trick if I'm not mistaken. Or $(".modal").hide()
Josh Daniell
@joshdaniell
Aug 15 2017 14:10
Thank you @PeterHSteele - that fixed it!
CamperBot
@camperbot
Aug 15 2017 14:10
joshdaniell sends brownie points to @peterhsteele :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @peterhsteele |http://www.freecodecamp.com/peterhsteele
Tanisha Garg
@TanishaGarg
Aug 15 2017 14:16
How to add bootstrap in HTML while using notepad
?
Or how can I add a navigational bar without bootstap?
bootstrap*
Ken Haduch
@khaduch
Aug 15 2017 14:19
@TanishaGarg - the syntax for including bootstrap in a page should be on the bootstrap site - https://getbootstrap.com/docs/3.3/getting-started/ for version 3. You can look at the bootstrap CDN section or find many other ways to include it...
Jorge
@flawedLogic506
Aug 15 2017 14:30
@PeterHSteele modal trigger by jquery is: $('#myModal').modal('show');
Peter Steele
@PeterHSteele
Aug 15 2017 15:05
@OrangeKulture oh ok, I looked for .modal() in the api docs and couldn't find anything but maybe that doesn't cover everything?
Peter Steele
@PeterHSteele
Aug 15 2017 15:13

I'm trying to figure out why my col-md-offset-1 class isn't working:
HTML:

<div class="container-fluid" id='app'></div>

JS:

class Leaderboard extends React.Component {
  render (){
return (
      <div className="col-md-10 col-md-offset-1 leaderboard">
//code...
</div>
)
}

React.render(<Leaderboard />,document.getElementById('app'))
Gulsvi
@gulsvi
Aug 15 2017 15:16
@PeterHSteele col-md-offset-1 is for Bootstrap 3. You have bootstrap 4 added to your project, so you'll need to use offset-md-1.
(or switch to Bootstrap 3)
Peter Steele
@PeterHSteele
Aug 15 2017 15:26
@SkyC0der @amandamartin thanks!
CamperBot
@camperbot
Aug 15 2017 15:26
peterhsteele sends brownie points to @skyc0der and @amandamartin :sparkles: :thumbsup: :sparkles:
:warning: @amandamartin's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
:star2: 2395 | @skyc0der |http://www.freecodecamp.com/skyc0der
Rahul Yedida
@yrahul3910
Aug 15 2017 16:07
Sorry if this is a stupid question, but how do I send data in the body of a POST request (like how you can do in Postman)?
Moisés Man
@moigithub
Aug 15 2017 16:13
with plain html.. using a form element u can set method attribute to POST (default if i recall)
OR u can use some client libraries like jQuery, axios, fetch etc.. to do via javascript (how exactly check the documentation on each) @yrahul3910
Rahul Yedida
@yrahul3910
Aug 15 2017 16:20
Even using Fetch, I can't figure out what I'm doing wrong. Here's my code:
fetch("/api/authenticate", {
            headers: {
                "Accept": "application/json",
                "Content-Type": "application/json"
            },
            method: "POST",
            body: JSON.stringify({
                username: "Rahul",
                password: "pwd"
            })
        });
But in Express, doing console.log(req.body.username) always shows undefined
Postman seems to be sending this request right, since I can see the username printed when it gets that request
Moisés Man
@moigithub
Aug 15 2017 16:25
how u configuring ur body parser ? @yrahul3910
Rahul Yedida
@yrahul3910
Aug 15 2017 16:26

I'm using:

app.use(bodyParser.urlencoded({extended: true}));

I realized I ought to change Content-Type to application/x-www-form-urlencoded but that didn't work either.

I just know it's something silly, I can't put a finger on it
Moisés Man
@moigithub
Aug 15 2017 16:29
fetch(url, {  
    method: 'post',  
    headers: {  
      "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"  
    },  
    body: 'foo=bar&lorem=ipsum'  
  })
if u using bodyParser.urlencoded
Rahul Yedida
@yrahul3910
Aug 15 2017 16:34
Still showing undefined :/
Moisés Man
@moigithub
Aug 15 2017 16:36
if u using "content-type":"application/json"
u need to config bodyparser with json
app.use(bodyParser.json())
Rahul Yedida
@yrahul3910
Aug 15 2017 16:37
I've changed it to "application/x-www-form-urlencoded; charset=UTF-8"
Rahul Yedida
@yrahul3910
Aug 15 2017 16:37
Using qs.stringify as suggested github/fetch#263 didn't work either
Rahul Yedida
@yrahul3910
Aug 15 2017 17:10
Man, this is frustrating. I'm sure my body-parser is set up right (now using JSON), and it always works using Postman, but using Fetch or jQuery the body is always empty
Moisés Man
@moigithub
Aug 15 2017 17:15
go to ur network tab(devtools) and check how request is done
compare postman vs fetch/other library
Daniel Feldman
@Feldbot
Aug 15 2017 17:15

Can someone help explain the Factorialize a Number challenge to me? The suggested solution is:

function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}
factorialize(5);

I don't understand why it iterates through like a loop. To my way of thinking it would stop after the first evaluation of 5 * 4 since at that point it is asked to return. What prompts this to keep evaluating like a loop? I guess I should also say I don't understand how the return 1 ties in either.

Gulsvi
@gulsvi
Aug 15 2017 18:00
My Non-React Leaderboard is finished :) https://codepen.io/skycoder/pen/xLXmEL?editors=0010
Though.... I don't get why the column size changes when sorting...will need to debug that later
Adam Recvlohe
@arecvlohe
Aug 15 2017 18:11
:thumbsup:
Christopher McCormack
@cmccormack
Aug 15 2017 18:12
@SkyC0der odd behavior when you select the current sort
Gulsvi
@gulsvi
Aug 15 2017 18:15
@cmccormack Uggh, I know what it is now. That isn't really a sort - it gets an entirely different dataset and some names are longer. I should have known that lol, just had my head buried in the code for a bit too long this morning I guess.
Christopher McCormack
@cmccormack
Aug 15 2017 18:16
Hey I'm not judging it's really nice for only ~20 lines of code
And I actually just meant the arrow directions on the column headers
Gulsvi
@gulsvi
Aug 15 2017 18:18
I'll have to think about that some more - there must be some standard guidelines on how to show a column is sortable, but not sorted yet
Thanks for checking it out @cmccormack
CamperBot
@camperbot
Aug 15 2017 18:20
skyc0der sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1143 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Aug 15 2017 18:21
@SkyC0der you can add a data-toggle or something to each header and use the value to determine which arrow to use maybe
Utsav Kafley
@chopedada
Aug 15 2017 18:21
https://codepen.io/chopedada/pen/EXpMex
Hi, I am working on my portfolio page and so far I have come up with this. But I feel like im using too many divs and classes. Is there a cleaner way of creating similar output? Also what would be a good way of going about and adding a gallery of images
Christopher McCormack
@cmccormack
Aug 15 2017 18:22
@chopedada divs and classes will be heavily used in many projects, maybe just get comfortable with it :D
Utsav Kafley
@chopedada
Aug 15 2017 18:54
https://codepen.io/chopedada/pen/EXpMex?editors=1000
Trying to have two a grid of images 2 columns x 3 rows.
What rule would I need to use in css to make that happen?
Gulsvi
@gulsvi
Aug 15 2017 18:58

@chopedada If you want a grid that is always 2 images wide per row, you can use the automatic columns in bootstrap:

<div class="row">
  <div class="col">
    This takes up 50% of the page width
  </div>
  <div class="col">
    This takes up 50% of the page width
  </div>
</div>

https://v4-alpha.getbootstrap.com/layout/grid/#equal-width

Just repeat that for every row ^^ or customize it further to make it 1 grid wide on mobile, 2 on tablet, 3 on laptops, etc...
Utsav Kafley
@chopedada
Aug 15 2017 18:59
Thank you @SkyC0der . So class="col" is always 50% width or does it change dependin on how many elements are in that class?
CamperBot
@camperbot
Aug 15 2017 18:59
chopedada sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2400 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Aug 15 2017 19:00
@chopedada col is an automatic width calculator - if you have 3 <div class="col"></div> elements in a row, it will be 33% wide. Only 1, it will be 100% wide. 4, it will be 25% wide, etc
Utsav Kafley
@chopedada
Aug 15 2017 19:01
Great thanks @SkyC0der
CamperBot
@camperbot
Aug 15 2017 19:01
chopedada sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:warning: chopedada already gave skyc0der points
Gulsvi
@gulsvi
Aug 15 2017 19:01
@Thayyebsalim Thank you as well - also good advice to use the grid system
CamperBot
@camperbot
Aug 15 2017 19:01
skyc0der sends brownie points to @thayyebsalim :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @thayyebsalim |http://www.freecodecamp.com/thayyebsalim
Thayyeb salim
@Thayyebsalim
Aug 15 2017 19:03
No problem
You didn't have to do that @SkyC0der
:D
Thanks
Gulsvi
@gulsvi
Aug 15 2017 19:05
:)
Daniel Feldman
@Feldbot
Aug 15 2017 19:14
@moigithub @SkyC0der Wow, and I thought I was previously confused! Curious that the angularindepth article said beginning programmers make the mistake of trying to understand why it works instead of trusting that it does. Quite the departure from previous lessons—pretty scary this is filed under Basic Algorithms no. 2. Good links though, thanks for sharing those.
CamperBot
@camperbot
Aug 15 2017 19:14
feldbot sends brownie points to @moigithub and @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2402 | @skyc0der |http://www.freecodecamp.com/skyc0der
:star2: 3589 | @moigithub |http://www.freecodecamp.com/moigithub
Gulsvi
@gulsvi
Aug 15 2017 19:17
@Feldbot To be honest, I don't know why they gave that as a solution without showing a simple for loop example as well. You are not expected to use recursion for that challenge :)
function factorialize(num) {
  if (num < 2) return 1;
  for(var i = num - 1; i > 1; i--) num *= i;
  return num;
}

factorialize(5);
or:
function factorialize(num) {
  var answer = 1;
  if (num < 2) return answer;
  for(var i = 2; i <= num; i++) answer *= i;
  return answer;
}

factorialize(5);
Daniel Feldman
@Feldbot
Aug 15 2017 19:23
@SkyC0der I started out trying to solve it with for and while loops but couldn't figure out how to come up with the factorial algorithm. I have a hard time seeing why 1 is needed as the return value to cause the execution break. From what I understand so far, one would need to understand recursion to begin with to know why this is used. Like the article said: "To understand recursion, one needs to first understand recursion" :-)
Eric Hasegawa
@EricHasegawa
Aug 15 2017 19:28
How can I take this link and make it so it puts in the users longitude and latitude instead of the default ones?https://fcc-weather-api.glitch.me/api/current?lat=35&lon=139 here is my code so far, I know the current link variable is broken https://codepen.io/erichasegawa/pen/brdYKd?editors=1010
Adam Recvlohe
@arecvlohe
Aug 15 2017 19:28
I think a good breakdown is to visualize what the stack would be for the recursive computations.
factorialize(5)
5 * factorialize(5 - 1)
4 * factorialize(4 - 1)
3 * factorialize(3 - 1)
2 * factorialize(2 - 1)
1
// factorialize(2 - 1) ===  1 meaning we return 1
// now we return back up the stack
2 * 1  returns 2 // factorialize(2 - 1) is defined as 1
3 * 2 returns 6  // factorialize(3 - 1) is defined as 2
4 * 6 returns 24 // factorialize(4 - 1) is defined as 4
5 * 16 returns 120  // factorialize(5 - 1) is defined as 24
Adam Recvlohe
@arecvlohe
Aug 15 2017 19:37
@Feldbot ^^^
*/ factorialize(4 - 1) is defined as 6
Gulsvi
@gulsvi
Aug 15 2017 19:51
@EricHasegawa Seems you got the latitude/longitude variables figured out. To see your JSON on the page, below your latitude and longitude, format the raw json and put it in <pre> tags:
    $.getJSON(weatherAPI, function(json) {
      var rawJSON = JSON.stringify(json, null, 2);
      $('body').append('<pre>' + rawJSON + '</pre>');
    });
Gulsvi
@gulsvi
Aug 15 2017 20:09
@arecvlohe Do you know why an infinite loop doesn't happen? i.e. why doesn't it go factorialize(1 - 0), factorialize (0 - 1), factorialize (-1 - 1), etc...
I'm still at the point where I just know it works :joy:
iso
@iso1048
Aug 15 2017 20:09
@SkyC0der hey bro
Gulsvi
@gulsvi
Aug 15 2017 20:09
Hey @gothamknight
iso
@iso1048
Aug 15 2017 20:10
what's happening?
Gulsvi
@gulsvi
Aug 15 2017 20:10
not much, you?
iso
@iso1048
Aug 15 2017 20:11
same old. just at uni
Adam Recvlohe
@arecvlohe
Aug 15 2017 20:13
@SkyC0der That’s because there is a base case that resolves the computation and prevents it from being an infinite loop. Without a base case a function would do what you are saying.
Gulsvi
@gulsvi
Aug 15 2017 20:14
@arecvlohe thanks! Duh... it returns before it can call the function again. I wasn't thinking through that one lol
CamperBot
@camperbot
Aug 15 2017 20:14
skyc0der sends brownie points to @arecvlohe :sparkles: :thumbsup: :sparkles:
:cookie: 410 | @arecvlohe |http://www.freecodecamp.com/arecvlohe
Adam Recvlohe
@arecvlohe
Aug 15 2017 20:15
Recursion is hard to visualize, at least for me, because I can’t see the call stack, to see how it goes in order
But once you can kind of see the progress that the function makes, it’s a little easier
Shivaji
@psrijan
Aug 15 2017 20:25
@psrijan
my pomodoro app was looking fine while I made it in sublime text. I copy pasted the same code to codepen and now my layout seems to be everywhere
https://codepen.io/shivji/pen/NvwjOg
Why is this happening?
image.png
how it looks when i run it in browser after making from sublime text
Jorge
@flawedLogic506
Aug 15 2017 20:45
lol @ recursion
@psrijan it's best to leave out the imports from your pen's html section .. it's best to use the settings tab for that. Maybe try loading all js, css and fonts with the 'Settings'
Daniel Feldman
@Feldbot
Aug 15 2017 21:13
@arecvlohe Thanks for the visualization Adam, that helps a lot. I was trying to log those steps to the console so I could better see what was happening, but I didn't have any luck with that. So when this the function is called the first time, it literally goes through that order to evaluate?
CamperBot
@camperbot
Aug 15 2017 21:13
feldbot sends brownie points to @arecvlohe :sparkles: :thumbsup: :sparkles:
:cookie: 411 | @arecvlohe |http://www.freecodecamp.com/arecvlohe
Adam Recvlohe
@arecvlohe
Aug 15 2017 21:20
@Feldbot Yes, it goes through the function and create a new stack to be evaluated, once it hits the end, it runs back up the call stack
It’s a bit harder to log the steps in the console using JavaScript
I think ruby is able to do that though
I will come up with something, one moment
Adam Recvlohe
@arecvlohe
Aug 15 2017 21:31
Okay, looks likes there is not easy way, so your going to have to use your imagination :smile:
This might be the best thing I have found: https://visualgo.net/bn/recursion
@Feldbot Make sure to factorial numbers from the options in the bottom left
Daniel Feldman
@Feldbot
Aug 15 2017 21:35
@arecvlohe In your example, what is meant by the comment series // factorialize(2 - 1) is defined as 1 ? Not sure what "is defined as n" means...
Adam Recvlohe
@arecvlohe
Aug 15 2017 21:37
@Feldbot Since the base case is if (n === 1) return 1 we know that factorialize(2 - 1) which is factorialize(1) equates to 1
replaces defined with returns
Daniel Feldman
@Feldbot
Aug 15 2017 21:38
@arecvlohe Sorry, what is a base case?
Adam Recvlohe
@arecvlohe
Aug 15 2017 21:39
The base case stops the exection of a recursive function when it reaches the end, in so many words
Another example is reversing an array
Adam Recvlohe
@arecvlohe
Aug 15 2017 21:46
function reverseArray(arr) {
  if (arr.length === 0 ) return [];
  return [].concat(arr[arr.length - 1], reverseArray(arr.slice(0, -1))) 
}
Here the base case is an emtpy array
That’s becasue after each iteration of reverseArray I am slicing off the last value arr.slice(0, -1)
At some point there won’t be any values left, and when that happens, I need it to resolve [].concat for each value I added, which is a new array of [4, 3, 2, 1] if I pass [1, 2, 3, 4]
@Feldbot
you can play around with it here: https://repl.it/KLGp
Daniel Feldman
@Feldbot
Aug 15 2017 21:54
@arecvlohe Thanks Adam. This will take me awhile to truly understand, but I get a general sense what you are showing me.
CamperBot
@camperbot
Aug 15 2017 21:54
feldbot sends brownie points to @arecvlohe :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave arecvlohe points
Adam Recvlohe
@arecvlohe
Aug 15 2017 21:56
Yeah, it takes a good while to figure out but once it clicks you can do all kinds of cool stuff with it
for example, you can flatten an array: https://repl.it/Iyar/0
Daniel Feldman
@Feldbot
Aug 15 2017 22:03
@arecvlohe I'm just beginning to code, so I'll take your word for it. Not sure what that example does, but pretty neat how you have built the test in. Thanks again for taking the time to explain!
CamperBot
@camperbot
Aug 15 2017 22:03
feldbot sends brownie points to @arecvlohe :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave arecvlohe points
Adam Recvlohe
@arecvlohe
Aug 15 2017 22:05
No problem!
Michael Rodriguez
@mrod75
Aug 15 2017 22:06
How is this pulling the value from the propery? For example, how does this one pull "pony?"

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
} else {
return "Not Found";
}
return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");

Ken Haduch
@khaduch
Aug 15 2017 22:11
@mrod75 - is it working the way it is supposed to work? Or is it not working, or do you not understand what is going on? It looks like the code is correct.
Michael Rodriguez
@mrod75
Aug 15 2017 22:12
it works, I just don't understand what is going on.
Just don't see the correlation that is pulling the values out of the objects.
Ken Haduch
@khaduch
Aug 15 2017 22:13
@mrod75 - okay - checkObj() is a function, and the line at the bottom checkObj("gift") is passing the value (a string) "gift" as the argument. Within the function, the function argument checkProp takes on the value of the argument, so it is a variable that has the value "gift" for this particular instance.
@mrod75 - now, you use the method .hasOwnProperty() to determine if the object has the property - the property can either be passed directly as a string, or in this case, the more useful way is to use the function's argument (a variable) to refer to the value that was passed in. If you have the property, .hasOwnProperty() will return true and you execute the block of code return myObj[checkProp];.
Colin
@finkbeca
Aug 15 2017 22:15
Hi everyone I have been working on a webpage and when i tried to host it it showed a title icon that I never put in their. Any ideas of how to get rid of it. I have no code at all that points toward it so I am so baffled on how it got their
there*
Michael Rodriguez
@mrod75
Aug 15 2017 22:17
Just having a hard time understanding how it pulls the the value "pony"? it seems like it should only be seeing or looking at the propery "gift."
Ken Haduch
@khaduch
Aug 15 2017 22:17
@mrod75 - that is using bracket notation to have the variable access the object - the value of the variable is a property name in that context, so if checkProp has the value "gift" then the return myObj[checkProp]; will access the value of the object in the "gift" property and return the value contained therein, which is "pony". Similarly if checkProp has the value "pet" you will return "kitten" and if the checkProp has a value like "zzzzzz", you should not find anything with .hasOwnProperty() and use the other block in the if ... else and return "Not found"... (In the tests, they use the value "house" for the case where you should return "Not found" - but any property name that doesn't exist in the object will return that.
Michael Rodriguez
@mrod75
Aug 15 2017 22:21
Thank so much! It just CLICKED! :)
I was waaaaay over thinking it.
Ken Haduch
@khaduch
Aug 15 2017 22:22
@mrod75 - the property name is "gift" - when you reference it as myObj["gift"] you will get the value "pony" as the result. When the checkProp has the value "gift" you use the checkProp variable to access it - the same result because for that case myObj[checkProp] is the same as myObj["gift"] but much more useful because you can pass any value into the function and access it through the variable.
Michael Rodriguez
@mrod75
Aug 15 2017 22:23
thank you @khaduch !
CamperBot
@camperbot
Aug 15 2017 22:23
mrod75 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3207 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Aug 15 2017 22:24
@mrod75 - you're welcome.
Gulsvi
@gulsvi
Aug 15 2017 22:34
@finkbeca It sounds like it might be a favicon, but hard to tell without seeing what you are seeing. You could try using your own favicon instead. Put this in the <head> of your HTML file:
<link rel="shortcut icon" type="image/png" href="https://path/to/your/favicon/file/out/on/the/web">
Colin
@finkbeca
Aug 15 2017 22:36
k
@SkyC0der It is still showing up
Gulsvi
@gulsvi
Aug 15 2017 22:38
@finkbeca Be sure to clear cache before checking again, but it was just a guess. I have no idea without seeing what you are seeing.
Colin
@finkbeca
Aug 15 2017 22:38
okay , ill check the cache and if that doesnt work Ill pm you a link to the website
Davide
@DavOnGit
Aug 15 2017 22:41
Hi, someone here with safari can pls review this?
https://youread.herokuapp.com/
:book: trading :clubs:
Colin
@finkbeca
Aug 15 2017 22:45
@SkyC0der I sent you a pm
CallMeOrange
@EgnaroDev
Aug 15 2017 23:47
@SkyC0der Hey, nice avatar
Gulsvi
@gulsvi
Aug 15 2017 23:48
@EgnaroDev Hello :wave:
I might get rid of the :sunglasses:
:)
CallMeOrange
@EgnaroDev
Aug 15 2017 23:48
lol
Your avatar represents your face?
Gulsvi
@gulsvi
Aug 15 2017 23:49
No, just chose random ones until it looked normal.
CallMeOrange
@EgnaroDev
Aug 15 2017 23:49
I see
I'm just orange
Gulsvi
@gulsvi
Aug 15 2017 23:50
haha
CallMeOrange
@EgnaroDev
Aug 15 2017 23:50
@SkyC0der How good are you at Geo?
Gulsvi
@gulsvi
Aug 15 2017 23:50
What algorithm are you working on?
CallMeOrange
@EgnaroDev
Aug 15 2017 23:50
I haven't done an algorithm a while
Gulsvi
@gulsvi
Aug 15 2017 23:51
navigator.geolocation? I know it pretty well
CallMeOrange
@EgnaroDev
Aug 15 2017 23:51
lol
I meant Geometry
Gulsvi
@gulsvi
Aug 15 2017 23:51
geometry? lol it was my best class in high school but I don't know if I remember everything very well now
CallMeOrange
@EgnaroDev
Aug 15 2017 23:51
Hm...
Gulsvi
@gulsvi
Aug 15 2017 23:51
it was a lot of memorizing
CallMeOrange
@EgnaroDev
Aug 15 2017 23:52
Yeah a lot
Gulsvi
@gulsvi
Aug 15 2017 23:52
theorems and postulates...
CallMeOrange
@EgnaroDev
Aug 15 2017 23:52
lol
Like Ruler postulate, Segment addition etc.
I can't tell the difference between theorems and postulates...
Gulsvi
@gulsvi
Aug 15 2017 23:53
theorem can be proven, postulate is assumed to be true without proof
CallMeOrange
@EgnaroDev
Aug 15 2017 23:54
lol I was going to say that
I just realized
Want to try to solve a problem?
Gulsvi
@gulsvi
Aug 15 2017 23:55
lol, I'll try
haven't though much about geo for a few years though :p
CallMeOrange
@EgnaroDev
Aug 15 2017 23:55
(1,3) and (5, 7), find the distance between them
I just want to test your skills
Gulsvi
@gulsvi
Aug 15 2017 23:57
5.65685
4 root 2
CallMeOrange
@EgnaroDev
Aug 15 2017 23:57
Let me confirm it
Gulsvi
@gulsvi
Aug 15 2017 23:57
? I think? :p
CallMeOrange
@EgnaroDev
Aug 15 2017 23:59
Hm.. I'm not sure but I got root 32 or 2 root 8
Joseph Davidson
@jojacino
Aug 15 2017 23:59
Does anyone live in Arkansas?