These are chat archives for FreeCodeCamp/Help

5th
Sep 2017
aRtoo
@artoodeeto
Sep 05 2017 00:36

yow fam on my repl.it i am returning the right objects but when i paste everything on fcc theres a incorrect return value. heres my code:


// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold",

    }
};

var collectionCopy = JSON.parse(JSON.stringify(collection));

function updateRecords(id, prop, value) {

  if(prop !== 'tracks' && value !== '') {
      collection[id][prop] = value;
  } 
   else if(prop === 'tracks' && !collection[id].hasOwnProperty('tracks') ) {
    collection.tracks = [value];
   }    

    else if(prop === 'tracks' && value !== '') {
      collection[id].tracks.push(value);
    } 

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

  return collection;
}

updateRecords(5439, "tracks", "Take a Chance on Me");//tracks should have "Take a Chance on Me" as the last element.

this is the culprit. but i think its a bug.

updateRecords(5439, "tracks", "Take a Chance on Me");//tracks should have "Take a Chance on Me" as the last element.
Moisés Man
@moigithub
Sep 05 2017 01:12
check ur code .. whats difference between
collection.tracks = [value];
and ur other code / lines with collection @artoodeeto
u NOT accessing the property correctly
Ginger
@GingerChew
Sep 05 2017 01:16
@piteto Yep, you're right, that fixed it
Hey guys, I'm starting my first day as an intern at a web developmetn firm, any tips or advice? First job in a tech field
Ellyria
@Ellyria
Sep 05 2017 01:35
Congratulations, @GingerChew! I say relax and be yourself and all will be well.
Rafael Monroy
@rafaelmonroy
Sep 05 2017 02:45
whats up guys! hope everyone had a good weekend, I just finised about 90%(or so i think) of my wiki search engine, the only thing i am having trouble with is getting my program to print out each title as it irerates through the array, it only prints out the last result, I tried a for loop and while loop but same results, im so close I KNOW IT lol maybe not, can anyone look into my code and see what i am doing wrong? thanks! https://codepen.io/rafaelmonroy/pen/BdEBXB
Rafael Monroy
@rafaelmonroy
Sep 05 2017 03:06
nvm guys! solve, thanks anyways!
Nahuel Ovejero
@NahuelOvejero
Sep 05 2017 03:19
no problem ;p
Eric Miller
@ericmiller777
Sep 05 2017 06:45
function booWho(bool) {
  // What is the new fad diet for ghost developers? The Boolean.
  if(bool === true || bool === false){
    return true;
  }else{
    return false;
  }
}

booWho(null);
function booWho(bool) {
  // What is the new fad diet for ghost developers? The Boolean.
  if(bool == true || bool == false){
    return true;
  }else{
    return false;
  }
}

booWho(null);
the second one doesnt work
why
bool(1)
returns true
heroiczero
@heroiczero
Sep 05 2017 06:47
@ericmiller777 second bool is a loose equivalent
Ai rui 艾瑞
@aisolae
Sep 05 2017 08:13
is there a command that lets you return to a specific line of code in javascript
LydaTech
@lydatech
Sep 05 2017 08:38
@aisolae can you give an example of what you mean?
Ai rui 艾瑞
@aisolae
Sep 05 2017 08:38
using the if statement
if a condition isn't met, repeat line ....
LydaTech
@lydatech
Sep 05 2017 08:39
while
Ai rui 艾瑞
@aisolae
Sep 05 2017 08:39
it works in java but not sure it does in js
ok
LydaTech
@lydatech
Sep 05 2017 08:39
use a while statement
Ai rui 艾瑞
@aisolae
Sep 05 2017 08:40
ok
i will try that
thanks @lydatech
CamperBot
@camperbot
Sep 05 2017 08:40
aisolae sends brownie points to @lydatech :sparkles: :thumbsup: :sparkles:
:star2: 2404 | @lydatech |http://www.freecodecamp.com/lydatech
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 08:53
imagine You wanna do 50/0.18 it will be equal = 9
but Imagine the result I wanna get is the other part the 41 how can I proceed?
Jan Shah
@JanShah
Sep 05 2017 09:20

@tiagocorreiaalmeida

let number = 50
let answer = number/(1-0.18)
let remaining  = number - answer

would this work?

Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 09:21
I did it other way around like
50 * (1-0.18) :D
Jan Shah
@JanShah
Sep 05 2017 09:23
@tiagocorreiaalmeida
I did it in console, it's not 41
let number = 50
let answer = number/(1-0.18)
let remaining  = number - answer
number
50
answer
60.975609756097555
remaining
-10.975609756097555
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 09:24
I just tought like if we wanted the oposite
Jan Shah
@JanShah
Sep 05 2017 09:24
answer = number/(1+0.18)
42.37288135593221
remaining = number-answer
7.627118644067792
this is closer
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 09:24
why not pick a integer
the remove the 0.18
and the multiply 50 by that
it worked :D
Jan Shah
@JanShah
Sep 05 2017 09:25
I did + instead of -
LydaTech
@lydatech
Sep 05 2017 09:28
@tiagocorreiaalmeida cant you multiply by .82?
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 09:30
that's what I did
LydaTech
@lydatech
Sep 05 2017 09:32
@tiagocorreiaalmeida why 1-0.18 instead of just .82 ?
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 09:33
cause its a dynamic number
and has multiply tests
so I use a variable
to go into 1 and remove that % value
Ai rui 艾瑞
@aisolae
Sep 05 2017 10:29
what have i done wrong
```
var userInput = "rock";
var randomNumber="";
userInput = userInput.toLowerCase();

function getcomputerChoice(){
  randomNumber = Math.floor(Math.random() * 2 );
  if (randomNumber == 0 ){
    return "rock";
  }
  else if (randomNumber == 1){
   return "paper";
  }

  else {
      return "sciccors";
  }

}

function determineWinner(userChoice, computerChoice){
  if (userChoice === computerChoice){
    return "Game was a tie";
  }
  if (userChoice === "rock") {
    if (computerChoice === "paper")
    {return "Computer Wins"; }
  }
  else {
    return "user win";
  }

  if (userChoice === "rock") {
    if (computerChoice === "scissors"){
    return "user Win";
  } 
  }

 else {
    return "computer win";
  }


 if (userChoice === "paper"){

  if (computerChoice === "scissors"){
    return "Computer  Win";
  } 
 }
  else {
    return "user win";
  }


function playGame(){
  var userChoice = userInput;
  var computerChoice = getcomputerChoice();
  console.log('You threw: ' + userChoice);
 console.log('The computer threw: ' + computerChoice);
}

playGame();
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 10:34
if (randomNumber == 0 ){
set it ===
korzo
@korzo
Sep 05 2017 10:38
@aisolae You have 2 times if (userChoice === "rock") {
Ai rui 艾瑞
@aisolae
Sep 05 2017 10:40
yeah, comparing with different values
@tiagocorreiaalmeida, ==== gives error
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 10:43
you have some error im trying tyo figure out what's the eror
found it
missing a }
adfter the ele
to close the function determineWinner fucntion
Ai rui 艾瑞
@aisolae
Sep 05 2017 10:45
ok
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 10:45
you should also set var randomNumber = 0;
anmd use ===
you also not using the winner function for what I saw?
anyway gl
korzo
@korzo
Sep 05 2017 10:54
@aisolae But it will return after after 1.condition
Ai rui 艾瑞
@aisolae
Sep 05 2017 11:04
yeah, i notice that
nevermind
will solve it morrow
thanks @korzo
CamperBot
@camperbot
Sep 05 2017 11:04
aisolae sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 449 | @korzo |http://www.freecodecamp.com/korzo
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 11:07
always had problems with regex can't figure out how to use it proprely and what things I can really achieve with it can youy guys point me so good tutorial ou link to give a read?
just1witness
@just1witness
Sep 05 2017 11:52
@tiagocorreiaalmeida Play around with this. Yo can replace the text below with what your working on, it is very helpful.
http://regexr.com/
Seong No
@drno09
Sep 05 2017 12:23
++
dyon3334
@dyon3334
Sep 05 2017 15:08
can someone explain me the radix parameter in parseInt(s,radix) ?
Gil Alexandel
@gilalexandel
Sep 05 2017 15:15
@korzo thanks you so much. Its working now
Rajan
@ProgramNovice
Sep 05 2017 15:16
Hi guys
I have a doubt to ask you
For example: <h2>Hello</h2>
what is the difference between the terms 'h2 element' and 'h2 tag'?
Dylan
@dhcodes
Sep 05 2017 15:20
@ProgramNovice nothing really
semantics
Rajan
@ProgramNovice
Sep 05 2017 15:20
oh ok thanks :) @dhcodes
CamperBot
@camperbot
Sep 05 2017 15:20
programnovice sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1832 | @dhcodes |http://www.freecodecamp.com/dhcodes
Darren
@DarrenfJ
Sep 05 2017 15:21
morning fCC
Rajan
@ProgramNovice
Sep 05 2017 15:22
Morning Darren :)
Darren
@DarrenfJ
Sep 05 2017 15:23
hey guys :wave: @dhcodes @just1witness nice to see some friendly faces :D
thanks @Manish-Giri for the kata challenge..
CamperBot
@camperbot
Sep 05 2017 15:25
darrenfj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6506 | @manish-giri |http://www.freecodecamp.com/manish-giri
Rajan
@ProgramNovice
Sep 05 2017 16:03
Hi guys
after I finished the challenge "Build a Tribute Page" ,
can I post my html code here to receive comments on how to improve?
Darren
@DarrenfJ
Sep 05 2017 16:07
yes
post a codepen if you have it
or a link to something so we can view the finished product and not just the code, if possible
@ProgramNovice and you know how to post code using markdown if you do need to post snippets of code here?
Rajan
@ProgramNovice
Sep 05 2017 16:09
oh ok thanks alot Darren :) @DarrenfJ
CamperBot
@camperbot
Sep 05 2017 16:09
programnovice sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2007 | @darrenfj |http://www.freecodecamp.com/darrenfj
Darren
@DarrenfJ
Sep 05 2017 16:10
:D
just1witness
@just1witness
Sep 05 2017 16:14
Sup @DarrenfJ :)
Darren
@DarrenfJ
Sep 05 2017 16:24
the yoush..
hanging in the fCC helproom watching the tumbleweeds roll on by
just1witness
@just1witness
Sep 05 2017 16:30
I know, I hear crickets
I'm working on my calculator now
Mike
@MikeJSchorah
Sep 05 2017 16:59
What do you do about HTML regarding WordPress updates?
zootechdrum
@zootechdrum
Sep 05 2017 17:07
Yeah. nice! @just1witness
Grigor Minasyan
@gogminsam
Sep 05 2017 17:23

can someone help me with the cash in the drawer problem, i am trying to sum all cash in drawer using reduce method, what's the problem with this method?

  var totalcid = cid.reduce(function(a,b) {
    return a[1]+b[1];
  }, 0);

this is the cash in the drawer array

[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]
Randell Dawson
@RandellDawson
Sep 05 2017 17:29
@gogminsam - try
return a + b[1];
Mike
@MikeJSchorah
Sep 05 2017 17:31
I built 5 sites, 3 with Divi. I'm learning how to modify the style.css file for a child theme of the Divi theme.
Grigor Minasyan
@gogminsam
Sep 05 2017 17:41
@rmdawson71 it worked, thanks a lot
CamperBot
@camperbot
Sep 05 2017 17:41
gogminsam sends brownie points to @rmdawson71 :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @rmdawson71 |http://www.freecodecamp.com/rmdawson71
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 18:16
Anybody have the time to review a MEAN app I made for practice? I am facing an issue after deploying to production and I am not able to debug it. Please help
Production app link - http://monkmessages-env.us-east-2.elasticbeanstalk.com/messages
Github repo - https://github.com/thedigitalmonk/monk-messages
You can go ahead and create a test user and try creating messages. It shows an error in the console (502 bad gateway) but when you refresh the page the message loads. Is this an AWS issue? I found a SO answer close to it but none of the solutions worked for me
Engjell Bislimi
@Engjell00
Sep 05 2017 18:47
Hello guys, I have a simple question. One of my friends is currently studying programming for a long time. I told him I start doing my thing in FCC and explain to him like HTML5 is 5 hour Boostrap 5 hours etc.. and he said This is not good. I won't learn nothing about it and some of my friend told me it's worth it.. SO i am like in between opinions trying to know which one is really worth. SO far I really like FCC it is sooo easy to actually learn with the challenges. but is there something I will miss by learning here
Coy Sanders
@coymeetsworld
Sep 05 2017 18:48
the times are just projections, and they vary from person to person so don't take the numbers too literally @Engjell00
Stephen James
@sjames1958gm
Sep 05 2017 18:49
@Engjell00 It will give you a broad basis for learning more and more. The projects will challenge you more than the challenges.
Also, the online community, IMO, is one of the better ones for helping beginners.
Coy Sanders
@coymeetsworld
Sep 05 2017 18:50
Don't worry about what others say either, FCC may not be university-level education but first time programmers have done just fine here, the numbers speak for themselves https://www.freecodecamp.com/about/
also I do have a CS-related degree so I know both sides
Engjell Bislimi
@Engjell00
Sep 05 2017 18:52
I'm trying to create like some wordpress website by the side when i'm not on FCC but I didn't know you could have a certificate by learning here and get a job wth haha
I live in Montreal and I always tho you need 100% need a university diplome
thanks @coymeetsworld @sjames1958gm !
CamperBot
@camperbot
Sep 05 2017 18:53
engjell00 sends brownie points to @coymeetsworld and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8443 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2998 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Stephen James
@sjames1958gm
Sep 05 2017 18:53
@thedigitalmonk Are you seeing the POST get to your back-end?
@thedigitalmonk Is it possible you are getting an exception and the back end is exiting ?
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 18:57
Sorry @sjames1958gm I don't understand what you mean when you say seeing the POST get to the backend. Could you elaborate? I am a slow learner...
I am getting two errors in the console - bundle.js:760 POST http://monkmessages-env.us-east-2.elasticbeanstalk.com/message?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjU5YWVlOGRjNDNmNzc5MDQ5ZmRiZjY4OCIsImZpcnN0TmFtZSI6InQiLCJsYXN0TmFtZSI6InQiLCJlbWFpbCI6InRAdC5jb20iLCJwYXNzd29yZCI6IiQyYSQxMCQwRHBCR2xHZDV2UXhTREN3d2REMnUuL3paNUN6aWVZL2NNenY1bmEvTDlmdkxjd1IwTFpSNiIsIl9fdiI6MCwibWVzc2FnZXMiOltdfSwiaWF0IjoxNTA0NjM1MTI2LCJleHAiOjE1MDQ2NDIzMjZ9.iR8U7dBPH_HzkOj8w5dqit9oKXwr5MxGiZo9oQpvWIM 502 (Bad Gateway)
followed by bundle.js:676 SyntaxError: Unexpected token < in JSON at position 0
Stephen James
@sjames1958gm
Sep 05 2017 18:58
@thedigitalmonk When you click save - it sends a POST request to your server.
@thedigitalmonk The second error is a result of the first because you are getting HTML not json because of the error.
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 18:59
Ah I see
So if I fix the first then the second will go away?
Stephen James
@sjames1958gm
Sep 05 2017 18:59
@thedigitalmonk I would go to your server and look at the logs and see if you have some failure
@thedigitalmonk yes, I believe so
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 19:01
Went to AWS dashboard and downloaded the last 100 lines of log
Full of errors. So overwhelming. :(
Stephen James
@sjames1958gm
Sep 05 2017 19:02
@thedigitalmonk Did you download the log right after you hit save? so you should be closer to the error?
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 19:03
Okay I will try that
Stephen James
@sjames1958gm
Sep 05 2017 19:06
@thedigitalmonk Add in more console.log statements if needed to isolate when/where it all goes south.
I see you have morgan installed that should help.
Engjell Bislimi
@Engjell00
Sep 05 2017 19:08
Simple question in jQuery when I need to write the $("name") The class starts with a . and id with a # right? like $(".chesse") $("#target3") for example
Stephen James
@sjames1958gm
Sep 05 2017 19:09
@Engjell00 yes. . is used for classes and # is used for ids
Engjell Bislimi
@Engjell00
Sep 05 2017 19:10
@sjames1958gm do you recommend any platform to use my learning? I mean wordpress keeps deleting my html codes everytime i preview my website and they won't let me do any font-family and im sure i wont be able to use the script for jquery
Stephen James
@sjames1958gm
Sep 05 2017 19:12
codepen is what is recommended here on FCC - it is mostly barebones as far as you provide the HTML, CSS and js - but it helps with making the inclusion of libraries part of settings.
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 19:12
@sjames1958gm was reading the error log and found this line 2017/09/05 14:47:40 [error] 4308#0: *40 upstream prematurely closed connection while reading response header from upstream, client: 172.31.8.248, server: , request: "POST /message?token= and so on
What does this mean
I am getting this over and over again
Stephen James
@sjames1958gm
Sep 05 2017 19:14
@thedigitalmonk hmm. not sure.
Thomson Muriyadan
@thedigitalmonk
Sep 05 2017 19:19
:thumbsup:
Ross Nelson
@rdnelson2010
Sep 05 2017 19:39
hello everyone! is the freecodecamp website down today?
mstellaluna
@mstellaluna
Sep 05 2017 19:42
@rdnelson2010 FCC is currently down and is being investigated, it should be up and running shortly
Coy Sanders
@coymeetsworld
Sep 05 2017 19:44
I'm on it right now
Henry
@GitHub-Henry
Sep 05 2017 19:44
Looks like the initial page loads, but it won't let me log in, perhaps the backend is down, just got a time out error
Coy Sanders
@coymeetsworld
Sep 05 2017 19:45
hmm, ok I logged out and now I'm unable to log back in with GitHub authentication lol
mstellaluna
@mstellaluna
Sep 05 2017 19:46
@coymeetsworld are you looking at a cached version?
image.png
^ it's what im getting ..
Coy Sanders
@coymeetsworld
Sep 05 2017 19:47
no, when I was logged in I was able to submit a challenge and my points went up @mstellaluna
mstellaluna
@mstellaluna
Sep 05 2017 19:48
its being looked into at the moment so that might be the reason
Ross Nelson
@rdnelson2010
Sep 05 2017 19:51
@mstellaluna ok thanks i thought i was the only one
CamperBot
@camperbot
Sep 05 2017 19:51
rdnelson2010 sends brownie points to @mstellaluna :sparkles: :thumbsup: :sparkles:
:cookie: 768 | @mstellaluna |http://www.freecodecamp.com/mstellaluna
piteto
@piteto
Sep 05 2017 19:54
.org is down, not .com
mstellaluna
@mstellaluna
Sep 05 2017 19:59
that's because your asking for a specific page, the .com domain now re-directs to .org .. if you try just freecodecamp.com it will re-direct to org which is down
Ross Scarborough
@SourceHorse
Sep 05 2017 20:10
can someone check out my twitch app and critique it?
Gersho
@Gersho
Sep 05 2017 20:26
@SourceHorse looks nice, could you make the scrolling text start in the middle rather than on the right ? so we don't have to wait 10+ sec to read
and sometimes it blinks a bit (the whole window)
Josebuendia
@Josebuendia
Sep 05 2017 20:28
Why has Freecodecamp stopped working?
Engjell Bislimi
@Engjell00
Sep 05 2017 20:38
what do you guys think
I think to put everything i know List, Title, Gif back,ground color img
am I missing something^
I didnt use jquery yet since i'm just starting to learn it
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 20:45
not the hackerman we deserve but the hackerman we need
Engjell Bislimi
@Engjell00
Sep 05 2017 20:46
LOL
Giovanni Panasiti
@giovapanasiti
Sep 05 2017 21:08
I need an admin.
Lance
@texas2010
Sep 05 2017 21:08
@giovapanasiti freecodecamp mod will pm you
Gersho
@Gersho
Sep 05 2017 21:48
@Engjell00 wrong hackerman !
Uriel Guzmán
@Burinson
Sep 05 2017 22:30
How can I make my Twitch API project return a message when API is not found on my searchbar?
I've been stuck for hours
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:33
send the codepen link
Uriel Guzmán
@Burinson
Sep 05 2017 22:33
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:35
by api you mean user not found?
Uriel Guzmán
@Burinson
Sep 05 2017 22:35
Yes, haha
I want to return something if nothing is show in the output
Shown*
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:36
ok then
can you point me the line of code
where you do the search part?
wanna go straight to it :D
Uriel Guzmán
@Burinson
Sep 05 2017 22:37
@tiagocorreiaalmeida
// -----------------------ON KEYPRESS-------------------------
    $("#searchTerm").keypress(function(e) {
        // Keypress.
        if (e.keyCode === 13) {
            // When spacebar is pressed.
            $("#output").empty();
            var searchTerm = $("#searchTerm").val();

            // Iterate through streamers and get the API of each one of them.
            $.ajax({
                type: "GET",
                url: "https://api.twitch.tv/kraken/streams/" + searchTerm, // Each streamer's user name gets added to URL.
                headers: {
                    "client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
                },
                success: function(twitch) {
                    // This contains each streamer's API.

                    if (twitch.stream !== null) {
                        // If streamers are online...
                        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(
                            // Append to #output div.
                            "<a target = '_blank' href=" +
                                url +
                                "><div class = 'well'>" +
                                "<img id = 'img' src =" +
                                logo +
                                ">" +
                                "<br></br>" +
                                "<p id = 'name'>" +
                                name +
                                "</p>" +
                                "<hr></hr>" +
                                "<p id = 'status'>" +
                                status +
                                "</p>" +
                                "<hr></hr>" +
                                "<p id = 'online'>Online</p>" +
                                "</div></a>"
                        ); // End of online append.
                    } else if (twitch.stream === null) {
                        $.ajax({
                            // If streamers are offline...
                            type: "GET",
                            url:
                                "https://api.twitch.tv/kraken/channels/" + searchTerm + "?callback?", // Get info from their channel instead of stream.
                            headers: {
                                "client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
                            },
                            success: function(twitchOffline) {
                                console.log(twitchOffline.status);
                                // API of streamer's channel.

                                var logo = twitchOffline.logo != null // If logo exists,
                                    ? (logo = twitchOffline.logo) // logo conserves properties.
                                    : (logo =
                                            "https://pre06.deviantart.net/1a10/th/pre/f/2015/291/5/1/logo_twitch_iosversion_by_akiruuu-d9djk9s.png"); // If not, logo is now this image.
                                var url = twitchOffline.url;
                                var status = twitchOffline.status != null // If status exists,
                                    ? (status = twitchOffline.status) // status conserves properties.
                                    : (status = "404 not found"); // If not, status displays "404 not found".
                                var displayName = twitchOffline.display_name;
                                $("#output").append(
                                    // Append to the same #output div.
                                    "<a target = '_blank' href =" +
                                        url +
                                        "><div class = 'well well-md'>" +
                                        "<img id = 'img' src =" +
                                        logo +
                                        "><br></br>" +
                                        "<p id = 'name'>" +
                                        displayName +
                                        "</p>" +
                                        "<hr></hr>" +
                                        "<p id = 'status'>" +
                                        status +
                                        "</p>" +
                                        "<hr></hr>" +
                                        "<p id = 'offline'>Offline</p>" +
                                        "</div></a>"
                                ); // End of offline append.
                            } // End of nested success function.
                        }); // End of nested ajax call.
                    } // End of else statement.
                } // End of success function.
            }); // End of ajax call.
        } // End of if statement.
    }); // End of searchTerm function.
This one is for when you click enter
The other one is when you press the icon, but they're exactly the same thing
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:38
then you have duplicated code?
Uriel Guzmán
@Burinson
Sep 05 2017 22:38
Yeah, haha
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:38
create a function with that code and call it twice?
Uriel Guzmán
@Burinson
Sep 05 2017 22:39
function(searchCode) { All my code}
Like that?
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:40
something like taht not sure if it needs parameters but doesnt seems to
anyway for what I Saw you just make a new request to the api everytime the usr searchs right?
Uriel Guzmán
@Burinson
Sep 05 2017 22:40
Yeah, I just add the thing they type onto the link
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:41
so the thing you need to do is check if the json request bring some object that says null or something?
like the channel doesnt exit
Uriel Guzmán
@Burinson
Sep 05 2017 22:41
"https://api.twitch.tv/kraken/channels/" + searchTerm + "?callback?", // Get info from their channel instead of stream. This is where it all happens
I tried, but don't know how to do that
That's why I've been stuck there since yesterday :(
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:42
image.png
twitch.status === 400?
Uriel Guzmán
@Burinson
Sep 05 2017 22:43
Great
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:43
wait something missing here
dont get into it yet
Uriel Guzmán
@Burinson
Sep 05 2017 22:43
Oh, okay
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:44
just a sec and sorry
Uriel Guzmán
@Burinson
Sep 05 2017 22:44
I think you're missing the id header
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 22:47
you need to add error
to your ajax request
Uriel Guzmán
@Burinson
Sep 05 2017 22:49
Oh, okay
What parameters would I need?
Uriel Guzmán
@Burinson
Sep 05 2017 22:56
error: function (twitch) {

                        },
Can I put twitch again?
@tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 23:00
sent you a pm
Uriel Guzmán
@Burinson
Sep 05 2017 23:19
@tiagocorreiaalmeida thanks
CamperBot
@camperbot
Sep 05 2017 23:19
burinson sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
api offline