These are chat archives for FreeCodeCamp/Help

2nd
Sep 2017
Uriel Guzmán
@Burinson
Sep 02 2017 01:00
Help
Why is this logging undefined?
$(document).ready(function(){

    var url = 'https://wind-bow.glitch.me/twitch-api/streams/';
    var streamers = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];


    for (var x = 0; x < streamers.length; x++) {

$.ajax({
                type: "GET",
                url: "https://api.twitch.tv/kraken/streams/" + streamers[x],
                headers: {
                    'client-ID': '8wp64ky5gj2bqordmiocrwdw4oivc0'
                },
                success: function(twitch){
console.log(twitch[x]);


                }
    });  // End of ajax call.
    } // End of x for loop.
}); // End of document function.
Long Nguyen
@longnt80
Sep 02 2017 01:06
@Burinson I think your callback doesn't recognize x
Coy Sanders
@coymeetsworld
Sep 02 2017 02:19
@Burinson what's twitch?
it should just be a json object, you don't need x or to access that as an array element
Randell Dawson
@RandellDawson
Sep 02 2017 02:38
Has anyone gone through any of the beta challenges in the past month?
just1witness
@just1witness
Sep 02 2017 03:24
@zootechdrum no worries, glad I could help
@rmdawson71 I'm almost done with the front end algo's I'm thinking of tackling the different ones on the beta next.
Randell Dawson
@RandellDawson
Sep 02 2017 03:26
@just1witness - That is great!
@just1witness - are you mentoring others now?
just1witness
@just1witness
Sep 02 2017 03:28
@rmdawson71 Yes, it seems I am
Randell Dawson
@RandellDawson
Sep 02 2017 03:28
@just1witness - It helps solidify what you do know and don't know.
just1witness
@just1witness
Sep 02 2017 03:30
@rmdawson71 I agree wholeheartedly. They say, after all, to be able to teach something is to know it... whoever "they" are :)
I only have one advanced algo left, Pairwise
just1witness
@just1witness
Sep 02 2017 03:42
@artoodeeto did you figure out your regex problem?
If you didn't you need to take into account that some of the number groups will have the brackets and/or the dash and some won't. Use the | (or) symbol to allow more than one format per number group. Also, this is an excellent tool for regex, http://regexr.com/ .
Darren
@DarrenfJ
Sep 02 2017 03:56
evening fCC
@coymeetsworld i haven't had one in 2 years... where' you end up going on your vacay?
Gersho
@Gersho
Sep 02 2017 04:13
hey @DarrenfJ just got back from work
Darren
@DarrenfJ
Sep 02 2017 04:13
coolCool :D
how was work?
Gersho
@Gersho
Sep 02 2017 04:13
lame as usual, i hate babysiting drunk adults
Darren
@DarrenfJ
Sep 02 2017 04:13
I'm up in Northern Ontario on a road trip for fun
bartender?
Gersho
@Gersho
Sep 02 2017 04:14
oh also karma got me in a weird way the other day, after i was on a crazy roll on the adv algo (4 in a row !! ) i went to bed ultra happy to see...the cat had peed on it
i manage the karaoke at a bar (i did bartender at some point)
bartender is actually the job that got me thinking "i need some new skills to get out of here"
Darren
@DarrenfJ
Sep 02 2017 04:15
karaoke! noice
cat' s always know how to get under yer skin, don't they ;)
Gersho
@Gersho
Sep 02 2017 04:16
but they're still better than dogs
Darren
@DarrenfJ
Sep 02 2017 04:17
i love dogs.. had a cat for a while but am horibl allergic
but i do love their sense of ruling the world
Gersho
@Gersho
Sep 02 2017 04:17
well they do
Darren
@DarrenfJ
Sep 02 2017 04:19
one of my fav twitch city episodes (old show): planet of cats
Gersho
@Gersho
Sep 02 2017 04:19
there's a fun futurama ep about cats
Darren
@DarrenfJ
Sep 02 2017 04:20
oh gawd that's big.. lemme clean it up
i don't remember the futurama one.. good?
Gersho
@Gersho
Sep 02 2017 04:22
not the best one, but funny anyway, lemme wiki that quickly
it's S6 ep08 (in the numerotation that has 7 seasons)
Darren
@DarrenfJ
Sep 02 2017 04:24
coolCool thanks @Gersho
CamperBot
@camperbot
Sep 02 2017 04:24
darrenfj sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Sep 02 2017 04:26
oh i love this, i'm "fixing" a computer that couldn't open .doc for someone, i boot the comp, double clic a .doc, and it work
Darren
@DarrenfJ
Sep 02 2017 04:29
:D
sounds about right
Gersho
@Gersho
Sep 02 2017 04:29
at least i'm done with the people wanting a W7->W10 downgrade
Darren
@DarrenfJ
Sep 02 2017 04:32
i haven't helped people fix their computer in years.. while i always found i could figure it out more or less it just ate up hours of time
now i'm all like yah, um, i know know how to push the buttons and make webpages
Gersho
@Gersho
Sep 02 2017 04:33
oh, it's because the bar where i work is actually my mom's, and most computer i fix is for her custofriends usualy for cheap or free
Darren
@DarrenfJ
Sep 02 2017 04:34
oh.. cool... perks of the job ;)
Gersho
@Gersho
Sep 02 2017 04:34
and if it sounds too complicated i turn them down
Darren
@DarrenfJ
Sep 02 2017 04:34
i hear yah on that one
heh
just1witness
@just1witness
Sep 02 2017 04:35
@Gersho how many advanced algo's do you have left?
Gersho
@Gersho
Sep 02 2017 04:36
5 i guess ? lemme check
was really on a roll the other day did 4 in a row (well ok, the easy ones)
just1witness
@just1witness
Sep 02 2017 04:37
That's been my experience too. I did 5 once, then spent four days on one...
Gersho
@Gersho
Sep 02 2017 04:37
5, i'm missing: Phone numbers, exact change , no repeats, map debris and pairwise (haven't started any)
just1witness
@just1witness
Sep 02 2017 04:37
Exact change took me 4 days
Gersho
@Gersho
Sep 02 2017 04:37
back in the intermediate algo, steamroll took me a full week
just1witness
@just1witness
Sep 02 2017 04:38
I had already accidentally flattened an array before that, so that one was easy for me, but it was a fluke, haha.
I have one left, Pairwise
Gersho
@Gersho
Sep 02 2017 04:40
they aren't mandatory so i focus on learning react and other stuff at the moment, JS is "for fun" :p
Darren
@DarrenfJ
Sep 02 2017 04:40
exact change took me forever too
Gersho
@Gersho
Sep 02 2017 04:40
well it seem to be detailed, so while no super hard, lots of step (aka lots of potential bugsà
just1witness
@just1witness
Sep 02 2017 04:41
I know they're not mandatory. Although I found myself wanting to update my projects every time I learned something new with the algo's, so I paused the projects to fi,ish them first.
Darren
@DarrenfJ
Sep 02 2017 04:41
oh yah.. jsut tons of combinatiosn of stuff to account for
Gersho
@Gersho
Sep 02 2017 04:42
the make a person one was actually my first time working on constructors
a bit like promises, i know the theory but haven't tried yet
or DOM, or so many other stuff
just1witness
@just1witness
Sep 02 2017 04:42
@Gersho I thought exactly the same thing when I first looked at exact change, @DarrenfJ is right though, it looks simple, but kicks your butt, lol.
I want to learn more about constructors, and objects. I don't feel confident in that area yet.
Darren
@DarrenfJ
Sep 02 2017 04:46
every time i deal with objects i have relearn them...
then I get them.. can work with them.. then next day... wham it's like all gone
Gersho
@Gersho
Sep 02 2017 04:47
memento.js
2 days ago the image at the bottom looked big, now it looks small ? is that some Cascading Satan Style trick ?
https://codepen.io/Gersho/pen/RpGJNJ
Darren
@DarrenfJ
Sep 02 2017 04:49
cascading satan style lol! perfect
Gersho
@Gersho
Sep 02 2017 04:50
that's how i feel about css
Darren
@DarrenfJ
Sep 02 2017 04:51
it's thee.worst
Gersho
@Gersho
Sep 02 2017 04:51
well before worying about it's size, i was supposed to change it to a b&w image, so good excuse to browse some Oda art <3
just1witness
@just1witness
Sep 02 2017 04:53
Dang, that's a big picture you have there
Gersho
@Gersho
Sep 02 2017 04:53
so it shows as big for you i guess
just1witness
@just1witness
Sep 02 2017 04:54
Yeah, it's like humungous
Darren
@DarrenfJ
Sep 02 2017 04:55
for me.. the most bottomist image is super tiny
Gersho
@Gersho
Sep 02 2017 04:56
for me too, today, 2 days ago it was as large as the white div
Darren
@DarrenfJ
Sep 02 2017 04:59
defintitely weird man
Gersho
@Gersho
Sep 02 2017 05:00
i tried putting width: 500px, but it seems i'm grabbing the thumbmail and extending it
Manish Giri
@Manish-Giri
Sep 02 2017 05:01
@DarrenfJ :wave:
Darren
@DarrenfJ
Sep 02 2017 05:01
hey buddy :D
Gersho
@Gersho
Sep 02 2017 05:01
your new avatar doesn't show up when we mouse over
Darren
@DarrenfJ
Sep 02 2017 05:01
@Gersho yah i just looked at it and now it's all extended
Gersho
@Gersho
Sep 02 2017 05:01
@DarrenfJ yeah i'm trying stuff
just1witness
@just1witness
Sep 02 2017 05:02
@Gersho the bottom image, for me, is the same size as the white div
Gersho
@Gersho
Sep 02 2017 05:02
@just1witness that's how it's supposed to be, but if you resfresh it probably won't be anymore
i'm trying to rehost it
just1witness
@just1witness
Sep 02 2017 05:06
@Gersho at 1x, it's right, at .50x it's right, but at .25x it's smaller on my phone as of right now.
Gersho
@Gersho
Sep 02 2017 05:08
at this point i think i'll just pick another image xD
Darren
@DarrenfJ
Sep 02 2017 05:09
ha!
css has wrestled you to the ground ;)
but seriously.. i woulda given'up already
yesterday ;)
Manish Giri
@Manish-Giri
Sep 02 2017 05:10
@DarrenfJ freeCodeCamp/freeCodeCamp#15833
trying to make new challenges is exhausting
just1witness
@just1witness
Sep 02 2017 05:11
Goodbye people, I'm going to stare at the back of my eyelids for a few hours.
Gersho
@Gersho
Sep 02 2017 05:11
have fun
Darren
@DarrenfJ
Sep 02 2017 05:13
@just1witness have fun and thank or the chat
CamperBot
@camperbot
Sep 02 2017 05:13
darrenfj sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @just1witness |http://www.freecodecamp.com/just1witness
Gersho
@Gersho
Sep 02 2017 05:13
image changed, if asked, that's how i wanted it from the start
Darren
@DarrenfJ
Sep 02 2017 05:14
@Manish-Giri seriously.. but good work! the whole object thing someone was asking that very kind of question a few days ago and it's hard to explain it using the fCC examples.. as they mention
thanks @Manish-Giri for tackling this kind of thing beyond the call of duty ;)
CamperBot
@camperbot
Sep 02 2017 05:14
darrenfj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6493 | @manish-giri |http://www.freecodecamp.com/manish-giri
Darren
@DarrenfJ
Sep 02 2017 05:14
i wonder what happens when someone hits 10K?
their PC explodes?
Gersho
@Gersho
Sep 02 2017 05:15
diabetes
Darren
@DarrenfJ
Sep 02 2017 05:15
ha!
claps
just1witness
@just1witness
Sep 02 2017 05:15
@Gersho @dngov no thank you! 😋
CamperBot
@camperbot
Sep 02 2017 05:15
just1witness sends brownie points to @gersho and @dngov :sparkles: :thumbsup: :sparkles:
:cookie: 73 | @dngov |http://www.freecodecamp.com/dngov
:cookie: 390 | @gersho |http://www.freecodecamp.com/gersho
Manish Giri
@Manish-Giri
Sep 02 2017 05:17
@DarrenfJ ty
CamperBot
@camperbot
Sep 02 2017 05:17
manish-giri sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2004 | @darrenfj |http://www.freecodecamp.com/darrenfj
Manish Giri
@Manish-Giri
Sep 02 2017 05:17
:smile:
lol 10K
I wonder when I'd hit 7k
:disappointed:
Darren
@DarrenfJ
Sep 02 2017 05:18
well.. eventually... just causa time
now it's almost impossible ;)
Manish Giri
@Manish-Giri
Sep 02 2017 05:18
true lol
Darren
@DarrenfJ
Sep 02 2017 05:21
i gotta scoot and do some show prep stuff... our improv troupe is gonna branch out into podcasts...
Manish Giri
@Manish-Giri
Sep 02 2017 05:26
good luck :clap:
heroiczero
@heroiczero
Sep 02 2017 06:18
@Manish-Giri here is another cookie to get you closer to 7k ty
CamperBot
@camperbot
Sep 02 2017 06:18
heroiczero sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6494 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Sep 02 2017 06:43
awwe
@heroiczero ty
CamperBot
@camperbot
Sep 02 2017 06:44
manish-giri sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1682 | @heroiczero |http://www.freecodecamp.com/heroiczero
kryssxx
@kryssxx
Sep 02 2017 07:00
Hi all, I'm doing some extra problem sets and for some reason, the object that I am being returned isn't counting the last element,
can someone please help

var countEvensAndOdds = function (array) {
var myObj = {};
var evenCount = 0;
var oddCount = 0;

for (var i = 0; i<=array.length; i++) {
if(array[i]%2 === 0) {
myObj.evenCount = evenCount++;
} else {
myObj.oddCount = oddCount++;
}

}
console.log(myObj);
}
console.log(countEvensAndOdds([1,2,3,4,5,6]));

kryssxx
@kryssxx
Sep 02 2017 07:05

What I am receiving is

[object Object] {
evenCount: 2,
oddCount: 3
}

but I need this

What I am receiving is

[object Object] {
evenCount: 3,
oddCount: 3
}

Manish Giri
@Manish-Giri
Sep 02 2017 07:10
@kryssxx post in jsbin or repl
and share the link
is that what you mean
@Manish-Giri
glitz20
@glitz20
Sep 02 2017 07:38
hey guys can anyone please let me know why my signup part is not working? https://glitch.com/edit/#!/static-file?path=views/signup.ejs:1:12
Manish Giri
@Manish-Giri
Sep 02 2017 07:48
@kryssxx yes
here's the corrected version

  for (var i = 0; i < array.length; i++) {
    if(array[i]%2 === 0) {
      myObj.evenCount = ++evenCount;
    } else {
      myObj.oddCount = ++oddCount;
    }

  }
  console.log(myObj);
}
Kelechi Chinaka
@ke1echi
Sep 02 2017 08:05
with the rate of work on fcc beta, when do u think it will go live @Manish-Giri
Manish Giri
@Manish-Giri
Sep 02 2017 08:07
@kelechy maybe in 3-4 months
Kelechi Chinaka
@ke1echi
Sep 02 2017 08:10
u said creating new challenges is alot, but i see it as an opportunity to contribute to open source @Manish-Giri
Manish Giri
@Manish-Giri
Sep 02 2017 08:11
it is
but you also need to write the tests which test the challenges
that's not easy.
Kelechi Chinaka
@ke1echi
Sep 02 2017 08:12
very true though
nice work you and the team are doing @Manish-Giri
Manish Giri
@Manish-Giri
Sep 02 2017 08:16
:+1:
@kelechy ty
CamperBot
@camperbot
Sep 02 2017 08:16
manish-giri sends brownie points to @kelechy :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @kelechy |http://www.freecodecamp.com/kelechy
gishy1
@gishy1
Sep 02 2017 10:37
@sjames1958gm thank you for that !!! from of all people a chelsea fan as well
CamperBot
@camperbot
Sep 02 2017 10:37
gishy1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8427 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Rajan
@ProgramNovice
Sep 02 2017 11:54
Hi guys
For Basic Front End Development Projects
in CodePen
Do we quick-add bootstrap3 or bootstrap4?
gishy1
@gishy1
Sep 02 2017 12:01
hello world need help!
Long Nguyen
@longnt80
Sep 02 2017 12:02
@ProgramNovice bootstrap 3
gishy1
@gishy1
Sep 02 2017 12:03
image.png
Ken Haduch
@khaduch
Sep 02 2017 12:05
@gishy1 - you can use 3 or 4, but the lessons are based on bootstrap 3. Better to stick with that.
gishy1
@gishy1
Sep 02 2017 12:06
@khaduch wrong person right answer
Ken Haduch
@khaduch
Sep 02 2017 12:06
Sorry, that was for @ProgramNovice
@gishy1 - you cannot combine (a,b) in your test. You have to have a < 0 || b < 0
@ProgramNovice - you can use 3 or 4, but the lessons are based on bootstrap 3. Better to stick with that.
Ken Haduch
@khaduch
Sep 02 2017 12:13
@gishy1 - then you have to do return undefined; instead of console.log
Rajan
@ProgramNovice
Sep 02 2017 12:24
@longnt80 ok thanks :)
CamperBot
@camperbot
Sep 02 2017 12:24
programnovice sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 545 | @longnt80 |http://www.freecodecamp.com/longnt80
Rajan
@ProgramNovice
Sep 02 2017 12:24
@khaduch ok thanks :)
Emmanuel Akodia
@akodiaemma
Sep 02 2017 12:26
i need help with transfering this form data to a kist of emails
how can i achieve that
littleZhuo
@littleZhuo
Sep 02 2017 13:23
hi everybody
i not know what's the means of "Link to External Pages with Anchor Elements"
paulsimmy
@paulsimmy
Sep 02 2017 13:35
How to buy UDEMY course in india? On website it is showing @Rs 450....And on app same courses worth @Rs 650..Why? Do we have to pay extra tax apart from 450rs on udemy website? Any Indian here plz help
Henry
@GitHub-Henry
Sep 02 2017 13:37
@paulsimmy businesses don't sell the same course for the same price. if you see the course offered at a lower price, get the course at the lower price.
just1witness
@just1witness
Sep 02 2017 13:39
@littleZhuo It means you link to an external webpage using <a href= webpage.com> </a>
korzo
@korzo
Sep 02 2017 13:39
@littleZhuo <a href="http://external-page.com">Your text</a>
just1witness
@just1witness
Sep 02 2017 13:40
@littleZhuo Also, if your using codepen you'll want to do it this way <a target='_blank' href = webpage.com></a>
paulsimmy
@paulsimmy
Sep 02 2017 13:40
@GitHub-Henry I can't able to buy it from website.. That's why, some payment method issue there
just1witness
@just1witness
Sep 02 2017 13:41
@akodiaemma can you show us?
what you have so far
paulsimmy
@paulsimmy
Sep 02 2017 13:41
Ok, just tell me..Does udemy charge extra apart from the mentioned price on its website?
Sandip Shrestha
@saninmersion
Sep 02 2017 13:49
no
Emmanuel Akodia
@akodiaemma
Sep 02 2017 13:50
@just1witness sure...hold up

if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "comprepair910@gmail.com";
    $email_subject = "The forms";

    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }


    // validation expected data exists
    if(!isset($_POST['full-name']) ||
        !isset($_POST['organisation']) ||
        !isset($_POST['email']) ||
        !isset($_POST['phoneNo']) ||
        !isset($_POST['skype'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }



    $fullNames         = $_POST["full-name"];
    $email             = $_POST["email"];
    $organisation     = $_POST["organisation"];
    $facebookId     = $_POST["facebook"];
    $twitterId         = $_POST["twitter"];
    $skypeId        = $_POST["skype"];
    $phoneNumber    = $_POST["phoneNo"];

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

  if(!preg_match($email_exp,$email)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }

    $string_exp = "/^[A-Za-z .'-]+$/";

  if(!preg_match($string_exp,$fullNames)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }

  if(strlen($organisation) < 2) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }

  if(strlen($fullNames) < 2) {
    $error_message .= 'The Names you entered do not appear to be valid.<br />';
  }

  if(strlen($error_message) > 0) {
    died($error_message);
  }

    $email_message = "Form details below.\n\n";


    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }



    $email_message .= "First Name: ".clean_string($fullNames)."\n";
    $email_message .= "Organisation: ".clean_string($organisation)."\n";
    $email_message .= "Email: ".clean_string($email)."\n";
    $email_message .= "Telephone: ".clean_string($phoneNumber)."\n";
    $email_message .= "Skype: ".clean_string($skypeId)."\n";

// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?php
@just1witness that's the code for the emailing,..it works finally but only some times. More so i find the mail in important section not inbox
Albert Cardona II
@daddycardona
Sep 02 2017 13:53
is all that php I see the open tag in the bottom of this code
@just1witness
Emmanuel Akodia
@akodiaemma
Sep 02 2017 13:57
@daddycardona there is more code after that
}
Albert Cardona II
@daddycardona
Sep 02 2017 13:57
Oh okay I didn't see the open tag on the top is all i am saying
Emmanuel Akodia
@akodiaemma
Sep 02 2017 13:57
thats it
Albert Cardona II
@daddycardona
Sep 02 2017 14:00
yes I am not that good with PHP @akodiaemma
Sandip Shrestha
@saninmersion
Sep 02 2017 14:04
@akodiaemma out of curiosity why do you have @mail()?
Emmanuel Akodia
@akodiaemma
Sep 02 2017 14:06
@saninmersion i actually do not know why its there but it seemedto send the first time i used it...so theres that
Sandip Shrestha
@saninmersion
Sep 02 2017 14:09
@akodiaemma I think it supresses any error messages you might get. can you check if your code actually does not send the mail or your code sends the mail the email it is sent to does not receive the mail.
Emmanuel Akodia
@akodiaemma
Sep 02 2017 14:13
@saninmersion yes i t has error messages. it worked at first and then it later refused to work ot
ut
its like it sends mail by chance
Sandip Shrestha
@saninmersion
Sep 02 2017 14:16
you might need to decode the error mesages.
Emmanuel Akodia
@akodiaemma
Sep 02 2017 14:16
@saninmersion that is what i am trying to do with every ones help :)
no error messages so far
Sandip Shrestha
@saninmersion
Sep 02 2017 14:17
@akodiaemma '@' is probably supressing your error messages.
korzo
@korzo
Sep 02 2017 14:17
@akodiaemma I think additional headers are case insensitive, so function clean_string will omit some malicious code
Emmanuel Akodia
@akodiaemma
Sep 02 2017 14:19
@korzo so i should use $organisation
just1witness
@just1witness
Sep 02 2017 14:19
@akodiaemma That's above my head, I can read what your doing just fine, but I wouldn't be able to pick out what's giving you problems.
Emmanuel Akodia
@akodiaemma
Sep 02 2017 14:20
@just1witness thank you for trying though
CamperBot
@camperbot
Sep 02 2017 14:20
akodiaemma sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @just1witness |http://www.freecodecamp.com/just1witness
just1witness
@just1witness
Sep 02 2017 14:20
@akodiaemma My pleasure :)
Emmanuel Akodia
@akodiaemma
Sep 02 2017 14:20
why im i giving u brownies facepalm
just1witness
@just1witness
Sep 02 2017 14:21
LOL, because you love me
@akodiaemma This is cool though, is it a challenge or something your doing for yourself?
korzo
@korzo
Sep 02 2017 14:23
@akodiaemma Sorry, it's ok. I mixed up $email_message and $headers variables.
Function clean_string is wrong, but it doesn't affect your script
Ivy-gaga
@Ivy-gaga
Sep 02 2017 14:44
i can't put the img element to smaller-mage in size your Image
Sam Goldberg
@sgoldber61
Sep 02 2017 17:46
when doing the dungeon crawler, i've been having problems.
movement of my character is really slow, and the slowness seems to be proportional to the size of hte map.
Sam Goldberg
@sgoldber61
Sep 02 2017 17:51
the map must be refreshing upon every movement, but i don't update said map in react...
:(
Gersho
@Gersho
Sep 02 2017 18:03
how do you update it then ?
just1witness
@just1witness
Sep 02 2017 19:19
I don't understand why this seems to be storing the 2, from the previous loop and adding the very same 2 to the next one, thus returning a true value and adding the identical index of 2 twice to the sum...
function pairwise(arr, arg) {
 var arr1 = [];
  var ind = [];
   for (var i = 0; i < arr.length; i++){
    arr.filter(function(el, index){
     if(el + arr[i] === arg){
      arr1.push(el , arr[i]);
       ind.push(index, i);
        arr[index] = "0";
        arr[i] = "0"; 
        }                 
       });
      }
return ind.reduce(function(sum, value) {
  return sum + value;
}, 0);

    }
pairwise([1, 3, 2, 4], 4);
Gersho
@Gersho
Sep 02 2017 19:22
a 2 ? how do you get a 2 with ([1, 3, 2, 4], 4), shouldn't the answer be 1 ?
pairwise([1, 3, 2, 4], 4);
1+3 = 4
 0+1=1 <---
just1witness
@just1witness
Sep 02 2017 19:24
What happes is it returns the index of 1, and 3, which is 0, 1. That's right. But it ALSO returns the index of 2(2), twice. Thus adding four to the sum of the indexes. I imagine, the loop is adding the two from the first loop, to the two of the second loop, but I don't understand why.
@Gersho
Gersho
@Gersho
Sep 02 2017 19:25
oh, because 2+2 = 4 ?
just1witness
@just1witness
Sep 02 2017 19:25
yup
Gersho
@Gersho
Sep 02 2017 19:26
i haven't really read (understood) the code in detail, but that means you're scanning it too much at some point, or should lock the value when used for comparison with other numbers
just1witness
@just1witness
Sep 02 2017 19:27
This solution passes tests 1, 4, and 5
Gersho
@Gersho
Sep 02 2017 19:28

if(el + arr[i] === arg){

to that if, you could add a check that verifies that el and arr[i] aren't one and the same

just1witness
@just1witness
Sep 02 2017 19:28
I tried that, maybe I did it wrong.
Gersho
@Gersho
Sep 02 2017 19:28
but you can't just compare their values, you need to compare where they come from
just1witness
@just1witness
Sep 02 2017 19:28
let's see if I can remember what I tried, I'll post it
I did that too
hold on
Gersho
@Gersho
Sep 02 2017 19:30

something like

(el + arr[i] === arg && i !== index)

(assuming i didn't misunderstand your code)

just1witness
@just1witness
Sep 02 2017 19:31
k, I added this, now it only fails test 3, thank you, I have momentum again! :)
if(el + arr[i] === arg && el !== arr[i])
@Gersho yours fixed it, thank you!!!!
CamperBot
@camperbot
Sep 02 2017 19:32
just1witness sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 391 | @gersho |http://www.freecodecamp.com/gersho
just1witness
@just1witness
Sep 02 2017 19:32
And DONE with advanced algo's!!!!!!!!!!!!!!
Gersho
@Gersho
Sep 02 2017 19:33
congratulations !
just1witness
@just1witness
Sep 02 2017 19:33
Thank you, haha, you understood my code better than me!
Gersho
@Gersho
Sep 02 2017 19:33
haven't started pairwise yet but that case
pairwise([0, 0, 0, 0, 1, 1], 1) should return 10.
sounds nasty to debug
just1witness
@just1witness
Sep 02 2017 19:33
But I did build it from scratch
yes, very
but if you get the others right, that one falls into place
Gersho
@Gersho
Sep 02 2017 19:34
i'm doing react on code academy at the moment
Uriel Guzmán
@Burinson
Sep 02 2017 19:34
@longnt80 Thanks. @coymeetsworld Twitch is the success function, I named it like that because it gives me the status of online/offline twitch streamers. Thanks!
CamperBot
@camperbot
Sep 02 2017 19:34
burinson sends brownie points to @longnt80 and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 546 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 2996 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
just1witness
@just1witness
Sep 02 2017 19:35
Is it easier to learn after having a javascript base? @Gersho
I'm going to angularJS next, since it seems all the rage with nearbye employers
Gersho
@Gersho
Sep 02 2017 19:36
considering it's a JS plugin, i'd even go as far as saying it's mandatory, htlm too
just1witness
@just1witness
Sep 02 2017 19:36
what react or angularJS?
Gersho
@Gersho
Sep 02 2017 19:36
react
just1witness
@just1witness
Sep 02 2017 19:37
That's in the backend curriculum right?
Gersho
@Gersho
Sep 02 2017 19:37
but i'd guess it's true for angular too
the data one i think
just1witness
@just1witness
Sep 02 2017 19:37
oh, right.
Gersho
@Gersho
Sep 02 2017 19:37
data visualisation, react challenges are actually right after the front end
just1witness
@just1witness
Sep 02 2017 19:38
I know, I wonder if I should hold off on angularJS until getting the data vis and backend certs, or not
Gersho
@Gersho
Sep 02 2017 19:40
i'd say try to give it a look after you finish front end
better make a choice when you've already tried the first few lessons
Saransh Barua
@saranshbarua
Sep 02 2017 19:41
Review my weather app. Is it necessary to add the toggle button?your suggestions are valuable.
https://codepen.io/saranshbarua/full/WEEERr/
Gersho
@Gersho
Sep 02 2017 19:42
the temperature toggle button is a user story, therefore mandatory
also why does it show weather in india before i click ?
the image should be relevant to the meteo, Thunderstorm isn't a sunny beach
Saransh Barua
@saranshbarua
Sep 02 2017 19:45
I used that value as a place holder. And the image is subjected to the temperature values.
Gersho
@Gersho
Sep 02 2017 19:47
it should be dependant on weather, not temperature (user story)
nice touch adding a field so we can search what city we want ! (we can't use ENTER in this field tho)
Saransh Barua
@saranshbarua
Sep 02 2017 19:49
@Gersho all right I'll fix it. Just wanted to ask whether to make a toggle button because it is already showing temperature in Celsius..

fixed the ENTER key issue

Uriel Guzmán
@Burinson
Sep 02 2017 20:42
$(document).ready(function() {
    var streamers = [
        "ESL_SC2",
        "OgamingSC2",
        "cretetion",
        "freecodecamp",
        "storbeck",
        "habathcx",
        "RobotCaleb",
        "noobs2ninjas"
    ];

    for (var x = 0; x < streamers.length; x++) {
        $.ajax({
            type: "GET",
            url: "https://api.twitch.tv/kraken/streams/" + streamers[x],

            headers: {
                "client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
            },
            success: function(twitch) {
                console.log(streamers[x]);

                if (twitch.stream !== null) {
                    var logo = twitch.stream.channel.logo;
                    var name = twitch.stream.channel.display_name;
                    var status = twitch.stream.channel.status;
                    var game = twitch.stream.channel.game;
                    var url = twitch.stream.channel.url;

                    $("#output").append(
                        "<a target = '_blank' href=" +
                            url +
                            "><div class = 'well'><img id = 'img' src =" +
                            logo +
                            ">" +
                            "<br></br>" +
                            "<p id = 'name'>" +
                            name +
                            "</p>" +
                            "<hr></hr>" +
                            "<p id = 'game'>" +
                            game +
                            "</p>" +
                            "<p id = 'status'>" +
                            status +
                            "</p>" +
                            "<p id = 'online'>Online</p>" +
                            "</div></a>"
                    );
                } else {
                    $("#output").append(
                        "<div class = 'well-md'>" +
                            "<img id = 'img' src = 'https://pre06.deviantart.net/1a10/th/pre/f/2015/291/5/1/logo_twitch_iosversion_by_akiruuu-d9djk9s.png'><br></br>" +
                            "<p id = 'name'>" +
                            streamers[x] +
                            "</p>" +
                            "<p id = 'offline'>Offline</p>" +
                            "</div>"
                    );
                } // End of else statement.
            } // End of success function.
        }); // End of ajax call.
    } // End of x for loop.
}); // End of document function.
Why is console.log(streamers[x]); returning undefined and how can I fix it?
I need it to return "ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"
Eric Miller
@ericmiller777
Sep 02 2017 20:49
@Burinson i had a problem like this, the fix was to use let instead of var in my for loop
pretty much i was told to never use var in a for loop again
Uriel Guzmán
@Burinson
Sep 02 2017 20:49
Let?
So I should replace all the var in my loops with let?
$(document).ready(function() {
    var streamers = [
        "ESL_SC2",
        "OgamingSC2",
        "cretetion",
        "freecodecamp",
        "storbeck",
        "habathcx",
        "RobotCaleb",
        "noobs2ninjas"
    ];

    for (var x = 0; x < streamers.length; x++) {
        $.ajax({
            type: "GET",
            url: "https://api.twitch.tv/kraken/streams/" + streamers[x],

            headers: {
                "client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
            },
            success: function(twitch) {
                console.log(streamers[x]);

                if (twitch.stream !== null) {
                    let logo = twitch.stream.channel.logo;
                    let name = twitch.stream.channel.display_name;
                    let status = twitch.stream.channel.status;
                    let game = twitch.stream.channel.game;
                    let url = twitch.stream.channel.url;

                    $("#output").append(
                        "<a target = '_blank' href=" +
                            url +
                            "><div class = 'well'><img id = 'img' src =" +
                            logo +
                            ">" +
                            "<br></br>" +
                            "<p id = 'name'>" +
                            name +
                            "</p>" +
                            "<hr></hr>" +
                            "<p id = 'game'>" +
                            game +
                            "</p>" +
                            "<p id = 'status'>" +
                            status +
                            "</p>" +
                            "<p id = 'online'>Online</p>" +
                            "</div></a>"
                    ); // End of online append.
                } else {
                    $("#output").append(
                        "<div class = 'well-md'>" +
                            "<img id = 'img' src = 'https://pre06.deviantart.net/1a10/th/pre/f/2015/291/5/1/logo_twitch_iosversion_by_akiruuu-d9djk9s.png'><br></br>" +
                            "<p id = 'name'>" +
                            streamers[x] +
                            "</p>" +
                            "<p id = 'offline'>Offline</p>" +
                            "</div>"
                    ); // End of offline append.
                } // End of else statement.
            } // End of success function.
        }); // End of ajax call.
    } // End of x for loop.
}); // End of document function.
Uriel Guzmán
@Burinson
Sep 02 2017 20:54
Still doesn't work :worried:
Lance
@texas2010
Sep 02 2017 20:55

he trying to say use let x = 0?

correct? @ericmiller777

Eric Miller
@ericmiller777
Sep 02 2017 20:56
yes
Uriel Guzmán
@Burinson
Sep 02 2017 20:56
oooooooooooooooooooh
Now it worked, haha
Lance
@texas2010
Sep 02 2017 20:56
bingo!
Uriel Guzmán
@Burinson
Sep 02 2017 20:56
@ericmiller777 Thank you very much
CamperBot
@camperbot
Sep 02 2017 20:56
burinson sends brownie points to @ericmiller777 :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @ericmiller777 |http://www.freecodecamp.com/ericmiller777
Uriel Guzmán
@Burinson
Sep 02 2017 20:56
@texas2010 thanks
Lance
@texas2010
Sep 02 2017 20:56
welcome anytime
Eric Miller
@ericmiller777
Sep 02 2017 20:56
I had the same problem for 2 days
no one could figure out the problem
glad i could help
Lance
@texas2010
Sep 02 2017 20:57
oh :O
Uriel Guzmán
@Burinson
Sep 02 2017 20:57
I didn't even know about let
Eric Miller
@ericmiller777
Sep 02 2017 20:57
pretty much in javascript never use var agiain
Uriel Guzmán
@Burinson
Sep 02 2017 20:57
I would've been stuck forever
Lance
@texas2010
Sep 02 2017 20:57
@ericmiller777 so you use jquery?
or just vanilla js
Eric Miller
@ericmiller777
Sep 02 2017 20:58
both :P
Lance
@texas2010
Sep 02 2017 20:58
ohh no wonder.....
probably something affect on your code.
i assumed
Eric Miller
@ericmiller777
Sep 02 2017 20:58
im used to using C3 so ive always used var
Lance
@texas2010
Sep 02 2017 20:58
i use vanilla js in my fcc project. i didnt use jquery ha
Eric Miller
@ericmiller777
Sep 02 2017 20:59
you still will have the problem with var when useing api calls
Uriel Guzmán
@Burinson
Sep 02 2017 20:59
So var never, never goes in js, only in css?
Lance
@texas2010
Sep 02 2017 20:59
i didnt get any issue with api calls ;)
Eric Miller
@ericmiller777
Sep 02 2017 20:59
well wait
never use var in a for loop
is what im saying
Uriel Guzmán
@Burinson
Sep 02 2017 20:59
Me neither... until now :shipit:
Eric Miller
@ericmiller777
Sep 02 2017 20:59
use let
Uriel Guzmán
@Burinson
Sep 02 2017 20:59
Ahh
Okay, good
Lance
@texas2010
Sep 02 2017 21:00
I already make random quote and weather. but i didnt use loop lol
Uriel Guzmán
@Burinson
Sep 02 2017 21:00
I understand now
Eric Miller
@ericmiller777
Sep 02 2017 21:00
you still have to use var when declareing a varible ect
but in the case of a for loop use let
Lance
@texas2010
Sep 02 2017 21:01
yeah it is better to use let in the loop. other day, i learned about let. i forget where ha
@ericmiller777 btw i make my own ajax function. so i dont have to write ajax repeat.
Eric Miller
@ericmiller777
Sep 02 2017 21:02
cool
Lance
@texas2010
Sep 02 2017 21:02
yeah
Uriel Guzmán
@Burinson
Sep 02 2017 21:02
I wonder how many times my for loops didn't work because of declaring var and I gave up
Haha
Lance
@texas2010
Sep 02 2017 21:03
but I didnt finish other part for deal with post and setRequestHeader. oh well.
so far i could use get and type file. text or json. something like that.
Aes
@CyberFistor
Sep 02 2017 21:05
Hello, I can't modify the height of the second video (#last) i can't figure why https://codepen.io/cyberfistor/pen/LjMVXv
Lance
@texas2010
Sep 02 2017 21:06
@ericmiller777 @Burinson somehow i like to write vanilla js. i feel like i dont need to use jquery ha.
Eric Miller
@ericmiller777
Sep 02 2017 21:07
thats cool, jquery can make some stuff much faster tho.
Lance
@texas2010
Sep 02 2017 21:07
true.
it is faster to finish project with jquery
I plan to take js 30 course. more js challenge for me. yay
Uriel Guzmán
@Burinson
Sep 02 2017 21:09
What is vanilla js?
Lance
@texas2010
Sep 02 2017 21:10
@Burinson
plain js
"VanillaJS is a name to refer to using plain JavaScript without any additional libraries like jQuery. People use it as a joke to remind other developers that many things can be done nowadays without the need for additional JavaScript libraries."
Mike
@MikeJSchorah
Sep 02 2017 21:10
I have a quick question: If I didn't use a child theme for my WordPress website, will all content be completely eliminated when the theme updates? I built 2 websites with the Avada theme and 3 websites with the Divi theme.
Uriel Guzmán
@Burinson
Sep 02 2017 21:12
Oh
Lance
@texas2010
Sep 02 2017 21:12
@Burinson yeah lol. just pure and plain.
normal js ha
Uriel Guzmán
@Burinson
Sep 02 2017 21:12
Haha, I didn't even understand API until the fourth channel
Challenge*
The API section on freecodecamp is really vague
sadly
Lance
@texas2010
Sep 02 2017 21:13
yeah. and they use jquery. i was like um...
it is pretty bad challenge. oh well. i didnt check on beta if they make it better.
i hope so
Uriel Guzmán
@Burinson
Sep 02 2017 21:15
tfw you wanna test your Twitch app and everyone is offline
:,(
Lance
@texas2010
Sep 02 2017 21:16
oh sad
you could check on twitch who is online. so add their username.
whatever who is on stream right now. for test
Gersho
@Gersho
Sep 02 2017 21:23
@Burinson OgamingSC2 is rarely offline
Uriel Guzmán
@Burinson
Sep 02 2017 21:24
@Gersho It's back now, it was offline 5 min ago, hehe
Gersho
@Gersho
Sep 02 2017 21:25
probably a reset, they broadcast almost 24/7
and now, since i've checked it's online, it would be rude not to watch... D:
oh aparently they had some internet issues
Eric Miller
@ericmiller777
Sep 02 2017 21:29
...
well anyway
anything after the if statement isnt happening
if i return after it isnt joined
my str isnt changed at all
function myReplace(str, before, after) {
  str = str.split(" ");
  before = before.split("");
  after = after.split("");
  if(before[0].toUpperCase() == before[0]){
    after[0] = after[0].toUpperCase();
  }
  before.join("");
  after.join("");
  for(let i = 0; i < str.length; i++){
    if(str[i] == before){
      str[i] = after;
    }
  }
  return after;
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting");
korzo
@korzo
Sep 02 2017 21:33
@ericmiller777 why return after; ?
Eric Miller
@ericmiller777
Sep 02 2017 21:33
well i want to return
str.join(" ");
korzo
@korzo
Sep 02 2017 21:33
@ericmiller777 also before.join(""); does nothing
Eric Miller
@ericmiller777
Sep 02 2017 21:33
but
yea
but still the after returned is still a array
korzo
@korzo
Sep 02 2017 21:34
you have to assign it back to before
@ericmiller777 you are returning after, but you should return str
Eric Miller
@ericmiller777
Sep 02 2017 21:35
I understand that but the issue is that nothing hapopens after the if statement
str.join returns "He is Sleeping on the Couch"
if i remove the if statement
korzo
@korzo
Sep 02 2017 21:35
@ericmiller777 because you are comparing string to array
Eric Miller
@ericmiller777
Sep 02 2017 21:35
?
if i take away the if statement
it comes back fine but no capital
idk
i split after to an array
then i want to join it?
@korzo idk maybe im just crazy....
korzo
@korzo
Sep 02 2017 21:38
@ericmiller777 you have to assign before and after back, when joining them
after = after.join("");
Eric Miller
@ericmiller777
Sep 02 2017 21:38
: O
korzo
@korzo
Sep 02 2017 21:41
@ericmiller777 That's one error. Second is return value. Then it should work
Eric Miller
@ericmiller777
Sep 02 2017 21:41
@korzo thanks
CamperBot
@camperbot
Sep 02 2017 21:41
ericmiller777 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 442 | @korzo |http://www.freecodecamp.com/korzo
Eric Miller
@ericmiller777
Sep 02 2017 21:41
um
why does my for loop still not work?
if i take away the if statement it works
just doesnt capitalize
korzo
@korzo
Sep 02 2017 21:42
post actual version
Eric Miller
@ericmiller777
Sep 02 2017 21:42
but with the if statement it does nothing
unction myReplace(str, before, after) {
  str = str.split(" ");
  before = before.split("");
  after = after.split("");
  if(before[0].toUpperCase() == before[0]){
    after[0] = after[0].toUpperCase();

  }

  after = after.join("");
  for(let i = 0; i < str.length; i++){
    if(str[i] == before){
      str[i] = after;
    }
  }
  return str.join(" ");
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting");
oh i missed the f
in function
function myReplace(str, before, after) {
  str = str.split(" ");
  for(let i = 0; i < str.length; i++){
    if(str[i] == before){
      str[i] = after;
    }
  }
  return str.join(" ");
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting");
that works but doesnt do capitalization
i just dont understand why it stops working
korzo
@korzo
Sep 02 2017 21:43
@ericmiller777 you forget to join before
Eric Miller
@ericmiller777
Sep 02 2017 21:43
oh
@korzo thank you so much
CamperBot
@camperbot
Sep 02 2017 21:44
ericmiller777 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: ericmiller777 already gave korzo points
Uriel Guzmán
@Burinson
Sep 02 2017 21:45
How do you get channel information when the Twitch streamer is offline?
I want the channel URL, but it only provides the API URL
korzo
@korzo
Sep 02 2017 21:46
@ericmiller777 But you don't have to split before/after just to get first letter.
You can access letter of string the same way you access array
var str = 'Hello World';
console.log(str[1]);
or str.charAt(1)
iso
@iso1048
Sep 02 2017 22:24
@Burinson use the channel route in the url. e.g. https://wind-bow.glitch.me/twitch-api/channels/freecodecamp. is that what you want?
Aes
@CyberFistor
Sep 02 2017 22:31
Hello guys, could you help me to increase the height of the second video #last i can't figure it out : https://codepen.io/cyberfistor/pen/LjMVXv?editors=1100
Uriel Guzmán
@Burinson
Sep 02 2017 22:58
@gothamknight Yes, I guess I gotta create another getJSON function? thanks
CamperBot
@camperbot
Sep 02 2017 22:58
burinson sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 415 | @gothamknight |http://www.freecodecamp.com/gothamknight
Gersho
@Gersho
Sep 02 2017 22:59
yes you'll need another call
Uriel Guzmán
@Burinson
Sep 02 2017 22:59
Can I nest the call in the other call?
Gersho
@Gersho
Sep 02 2017 22:59
(or work your code some way to make the relevant choices earlier in your code)
yes
Uriel Guzmán
@Burinson
Sep 02 2017 23:00
Wew
Let me try that
Gersho
@Gersho
Sep 02 2017 23:00
you can try various call url by putting them in your browser
Uriel Guzmán
@Burinson
Sep 02 2017 23:01
I tried, but I need to put my client id somewhere in the url...
I have a functioning ID, but don't know how to place it to check myself, lol
(For the kraken one)
Gersho
@Gersho
Sep 02 2017 23:02
copy it somewhere while you work on it
you don't use the fcc provided api ?
Uriel Guzmán
@Burinson
Sep 02 2017 23:16
@Gersho This is working very well, thank you :)
CamperBot
@camperbot
Sep 02 2017 23:16
burinson sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @gersho |http://www.freecodecamp.com/gersho
Uriel Guzmán
@Burinson
Sep 02 2017 23:16
I'm nesting two ajax calls
Eric Miller
@ericmiller777
Sep 02 2017 23:41
@Burinson that should work
@Burinson just nest a ajax in a ajax or a getJSON in a getJSON