These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Mar 2018
DistinctWolf
@DistinctWolf
Mar 06 2018 01:28
anyone available to help?
Christopher McCormack
@cmccormack
Mar 06 2018 01:37
@FlashHero probably someone around :)
Stephen James
@sjames1958gm
Mar 06 2018 01:45
@FlashHero I am not here
DistinctWolf
@DistinctWolf
Mar 06 2018 01:53
@sjames1958gm @cmccormack thanks guys, I got it solved !!
CamperBot
@camperbot
Mar 06 2018 01:53
flashhero sends brownie points to @sjames1958gm and @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1365 | @cmccormack |http://www.freecodecamp.org/cmccormack
:star2: 9061 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 06 2018 01:53
@FlashHero :+1:
Christopher McCormack
@cmccormack
Mar 06 2018 01:53
@FlashHero :thumbsup:
j-gonzales
@j-gonzales
Mar 06 2018 02:52
Greetings.
I am stuck, can someone help with out with Wherefore Art Thou
Christopher McCormack
@cmccormack
Mar 06 2018 02:54
@j-gonzales what exactly are you stuck with?
I slowly started to try to apply what I learned in the forum, to the problem I am working on.
So for my for loop I tried something like, collection[i].hasOwnProperty(source)) but this didn't work. Probably because source is an object and for it to work I need to have something like source.last
Sorry if this isn't clear. I hope I am making sense.
Christopher McCormack
@cmccormack
Mar 06 2018 03:00
@j-gonzales go ahead and paste your latest code here, surrounded by three backticks on top and bottom:
```
[ Code Block ]
```
j-gonzales
@j-gonzales
Mar 06 2018 03:01

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
   //Does each element in collection have 'all' of key/value pairs of source?



  for (var i=0; i<collection.length; i++){
    if (collection[i].hasOwnProperty(source)){
      return true;
    }

  }
     return false;

}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
CamperBot
@camperbot
Mar 06 2018 03:01
:bulb: to format code use backticks! ``` more info
Christopher McCormack
@cmccormack
Mar 06 2018 03:01
backticks are on the ~ key
j-gonzales
@j-gonzales
Mar 06 2018 03:01
oops
Christopher McCormack
@cmccormack
Mar 06 2018 03:01
usually, anyhow
you can edit a previous post
j-gonzales
@j-gonzales
Mar 06 2018 03:02
I am no where where I need to be. Just trying to step through it.
Christopher McCormack
@cmccormack
Mar 06 2018 03:03
so you are correct, source is an object.
So what are you trying to do first in your loop?
j-gonzales
@j-gonzales
Mar 06 2018 03:05
I am all over the place. I was thinking of checking to see if the key(s) existed from source in the collection.
Christopher McCormack
@cmccormack
Mar 06 2018 03:06
Slow down, write some comments in your code that guide you to your resolution - // first I want to take the value of x and compare to y, like that
Before you write code you should have a plan
j-gonzales
@j-gonzales
Mar 06 2018 03:09
Check each object for the key value pairs in source. If all of the key value pairs exist then return the object
I need to iterate through the object and what is in the object
Christopher McCormack
@cmccormack
Mar 06 2018 03:12
@j-gonzales you will also need to iterate over the properties/values of the second argument (source) as well, and you're given a hint to use Object.keys on the sidebar
j-gonzales
@j-gonzales
Mar 06 2018 03:13
Let me see if I can write it on paper, and have more of a gameplan. I will check back later.
Christopher McCormack
@cmccormack
Mar 06 2018 03:13
@j-gonzales using a REPL is a good way to play with this stuff:
> var choice = { last: "Capulet" }
> Object.keys(choice)
[ 'last' ]
> choice.last
'Capulet'
> choice['last']
'Capulet'
j-gonzales
@j-gonzales
Mar 06 2018 03:15
OK.
Thanks.
Christopher McCormack
@cmccormack
Mar 06 2018 03:15
@j-gonzales np, feel free to inquire about how specific functions work if that's where you are hung up
j-gonzales
@j-gonzales
Mar 06 2018 03:15
ok thanks
Dan Malone
@danmalone89
Mar 06 2018 03:19
I'm having some trouble appending my json data to my html document... Could anyone point me in the right direction? I'm able to append a string but not data.
$(document).ready(function () {
    $.ajax({
        url: 'https://****************',
        type: 'GET',
        dataType: 'json',
        success: function (data) {
            $('#contact-data').append(data);
            console.log(data);
           {alert('Success! Check the console for data.')};
         }, 
        error: function () { alert('Request failed'); },
        beforeSend: setHeader
    });
});
I can see my the json response in console so I'm aware the request is coming through appropriately. I should note it is coming over as an array of an object.
Christopher McCormack
@cmccormack
Mar 06 2018 03:25
@danmalone89 I believe append should append jquery elements (htmlString or Element or Text or Array or jQuery) to the DOM, not a JS object
Moisés Man
@moigithub
Mar 06 2018 03:25
.....append(JSON.stringify(data))
Dan Malone
@danmalone89
Mar 06 2018 03:30
@moigithub Worked like a charm. Thank you sir.
CamperBot
@camperbot
Mar 06 2018 03:30
danmalone89 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
api offline
Dan Malone
@danmalone89
Mar 06 2018 03:31
@cmccormack Thanks!
CamperBot
@camperbot
Mar 06 2018 03:31
danmalone89 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Rajat
@rajataudichya
Mar 06 2018 08:54
Hello Everyone ,
I need help with objects
Is this the right way to make them?
       var wicket = {

            "name": "Kusel Perera",
            "points": 0,
            credits: 9,

            "name": "Dinesh Kartik",
            "points": 0,
            credits: 9,

            "name": "Rishabh Pant",
            "points": 0,
            credits: 9

        };



        var batsman = {

            "name": "Rohit Sharma",
            "points": 0,
            credits: 11,

            "name": "Shikhar Dhawan",
            "points": 0,
            credits: 10.5,

            "name": "Suresh Raina",
            "points": 0,
            credits: 9.5,

            "name": "Kusal Mendi",
            "points": 0,
            credits: 9,

            "name": "Lokesh Rahul",
            "points": 0,
            credits: 9,

            "name": "Manish Pandey",
            "points": 0,
            credits: 9,

            "name": "Dinesh Chandimal",
            "points": 0,
            credits: 9,

            "name": "Dhanushka Gunathilaka",
            "points": 0,
            credits: 8.5,

            "name": "Dhananjaya De Silva",
            "points": 0,
            credits: 8.5,

            "name": "Deepak Hooda",
            "points": 0,
            credits: 8

        };


        var allRounder = {

            "name": "Thisara Perera",
            "points": 0,
            credits: 9.5,

            "name": "Axar Patel",
            "points": 0,
            credits: 8.5,

            "name": "Dasun Shanaka",
            "points": 0,
            credits: 8.5,

            "name": "Jeevan Mendis",
            "points": 0,
            credits: 8,


            "name": "Vijay Shankar",
            "points": 0,
            credits: 8.5,


            "name": "Washington Sundar",
            "points": 0,
            credits: 8.5,
        };



        var bowlers = {

            "name": "Yuzvendra Chahal",
            "points": 0,
            credits: 9,

            "name": "Suranga Lakmal",
            "points": 0,
            credits: 9,

            "name": "Jaydev Unadkat",
            "points": 0,
            credits: 8.5,

            "name": "Akila Dhanajaya",
            "points": 0,
            credits: 8.5,


            "name": "Nuwan Pradeep",
            "points": 0,
            credits: 8.5,



            "name": "Shardul Thakur",
            "points": 0,
            credits: 8.5,

            "name": "Mohammed Siraj",
            "points": 0,
            credits: 8,

            "name": "Isura Udana",
            "points": 0,
            credits: 8,

            "name": "Dushmantha Chamera",
            "points": 0,
            credits: 8
        };
I believe no one is there to help??
Sweet Coding :)
@SweetCodingInc
Mar 06 2018 08:58
@rajataudichya depends on how you intend to use them
syntactically they're correct
Rajat
@rajataudichya
Mar 06 2018 08:59
@SweetCodingInc Thanks
CamperBot
@camperbot
Mar 06 2018 08:59
rajataudichya sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 340 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Markus Kiili
@Masd925
Mar 06 2018 09:23
@rajataudichya You have duplicate keys on the objects, so later ones overwrite earlier ones.
So I don't think that this structure is what you need.
Rajat
@rajataudichya
Mar 06 2018 09:24
Yes @Masd925 I got that :) Thanks
CamperBot
@camperbot
Mar 06 2018 09:24
rajataudichya sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4715 | @masd925 |http://www.freecodecamp.org/masd925
Chantelle Robinson
@chantellerobinson
Mar 06 2018 10:51
Hello, I've not used the chatrooms on here before, but decided this would be the best place to come for some advice. Basically, I'm currently working through the algorithm challenges on here, and I've got onto 'Confirm the Ending' challenge. On all the previous challenges, I've been able to look at them and mentally break down the steps to complete it. It's usually taken me days or weeks to be able to implement those steps and for it to work, but I have an idea of what I am aiming for. On this one however, I don't really know where to start (other than maybe an if statement at some point). Does anyone have any suggestions on how to break this challenge down, or a first step to help me start it?
Markus Kiili
@Masd925
Mar 06 2018 10:53
@chantellerobinson Remember that you can compare string content with ===. You also have methods for making substrings from originals. That should ring some bells.
Aditya
@ezioda004
Mar 06 2018 10:55
@chantellerobinson The challenges have helpful links provided to point you in the right direction, I used to give them a read and have my thought process keep those (methods) in mind.
There's substring() and substr() as hints, so I'd suggest reading those and think how you can implement those in your logic.
Stephen James
@sjames1958gm
Mar 06 2018 10:57
@chantellerobinson Welcome. Check if a string (first argument, str) ends with this is in the challenge, so it seems you need to figure out how to get the end of a string
Chantelle Robinson
@chantellerobinson
Mar 06 2018 11:07
@ezioda004 I've read through them (& eventually understood the difference between the two, which is useful in itself!) but can't seem to make the connection to how that will come in useful with regards to the challenge
Aditya
@ezioda004
Mar 06 2018 11:14

@chantellerobinson You're given a string, all you need is to extract its last character and compare with the other argument target.
If you looked at example of substringat MDN, this is how you can use it.

var anyString = 'Mozilla';
console.log(anyString.substring(0, 1)); //M

The above example extracted the first character, can you think of a way how you can get the last character?

The first argument of substring is the starting index, and the second is the last index, so it extracts the characters b/w those
Chantelle Robinson
@chantellerobinson
Mar 06 2018 11:21
@ezioda004 I get it! you've just gave me a complete light bulb moment! Thank you so much! I know exactly why I couldn't understand now - I know how to get the last character, but in my head I need to include the characters prior to the last one in case they also equal 'target' - but actually that doesn't make a difference.
CamperBot
@camperbot
Mar 06 2018 11:21
chantellerobinson sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 496 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Aditya
@ezioda004
Mar 06 2018 11:24
:thumbsup:
Chantelle Robinson
@chantellerobinson
Mar 06 2018 11:24
Much appreciated :)
Aditya
@ezioda004
Mar 06 2018 11:25
Happy to help :)
Adel
@AdelMahjoub
Mar 06 2018 11:33
@alpox nice, took you only two hours and it works.
alpox
@alpox
Mar 06 2018 11:42
@AdelMahjoub I just made a version with common catmull-rom
Its does not cover the centripetal and chord versions :D but i think this version is mostly used
Its kinda interesting to do such things :D
Adel
@AdelMahjoub
Mar 06 2018 11:49
@alpox that's how that waveforms app work, it generate all the points for the waves yu want to use.
@alpox and it is a 5$ plugin,
alpox
@alpox
Mar 06 2018 11:51
@AdelMahjoub Thats cool :)
Adel
@AdelMahjoub
Mar 06 2018 11:57
@alpox there are a lot of useful libs , pathfinding and Procedural generation along with this numerical methods
alpox
@alpox
Mar 06 2018 11:58
I believe you that :D sadly i have other things to do now. But its fun :)
I just completed a course on numerical methods last semester :D
Stephen James
@sjames1958gm
Mar 06 2018 11:59
@chantellerobinson The ending wont === target unless it is the same length as target
abraham anak agung
@padunk
Mar 06 2018 12:28
Questuon about pure function. If a pure function that call another pure function can consider as pure?
Markus Kiili
@Masd925
Mar 06 2018 12:35
@padunk That seems pure to me.
Quantomistro3178
@Quantomistro3178
Mar 06 2018 12:49
function songDecoder(song){
  // ...
 var str = song.split("WUB");
 str.filter((val) => val != " ";);
 console.log(str);
}
Am I using the arrow function correctly? I'm getting a SyntaxError: missing ) after argument list
abraham anak agung
@padunk
Mar 06 2018 12:52
@Masd925 thanks
CamperBot
@camperbot
Mar 06 2018 12:52
padunk sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4718 | @masd925 |http://www.freecodecamp.org/masd925
Aditya
@ezioda004
Mar 06 2018 12:52
Dont use semicolon inside the filter() @Quantomistro3178
abraham anak agung
@padunk
Mar 06 2018 12:53
@Quantomistro3178 remove the ; inside parentheses
Quantomistro3178
@Quantomistro3178
Mar 06 2018 12:57
Oh
@padunk @ezioda004 thanks!
CamperBot
@camperbot
Mar 06 2018 12:57
quantomistro3178 sends brownie points to @padunk and @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 465 | @padunk |http://www.freecodecamp.org/padunk
:cookie: 497 | @ezioda004 |http://www.freecodecamp.org/ezioda004
function songDecoder(song){
  var a = song.split("WUB")
  var b = a.filter(function(val) { return val != " "; });
  console.log(b);

}
Why isn't my filter function working properly?
h1tag
@h1tag
Mar 06 2018 13:24
@Quantomistro3178 the space in the aarray is represented by "", not " "
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:26
@h1tag ohhh...yeah. Stupid mistake, my bad.
h1tag
@h1tag
Mar 06 2018 13:28
@Quantomistro3178 why a has empty strings like that though?
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:29
because I split it at every "WUB", right?
h1tag
@h1tag
Mar 06 2018 13:29
@Quantomistro3178 IDK, I'm asking, not testing you :D
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:30
And WUB can appear more than once, in a row. Like "xWUBWUByWUBzWUBWUB"
h1tag
@h1tag
Mar 06 2018 13:30
from the split description in the MDN docs, it doesn't seem to do that
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:31
and we need to remove all the WUBs and return a string with the other letters/words separated by spaces wherever WUB occurred
So I guess it adds an empty string when WUB appears twice, since it splits at one WUB, adds "" to the array, then splits again at the next WUB
because there's nothing b/w the two WUBs
h1tag
@h1tag
Mar 06 2018 13:32
@Quantomistro3178 but there's a WUB between WE and ARE, and it didn't put an "" there
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:33
Because it's only one WUB
the empty string is added when there's two or more WUBs in a row. Because there's nothing b/w them
so they're split with an empty string.
At least that's what I think, I'm still learning anyways.
h1tag
@h1tag
Mar 06 2018 13:34
@Quantomistro3178 oh, I see, Thank you :D
CamperBot
@camperbot
Mar 06 2018 13:34
:cookie: 270 | @quantomistro3178 |http://www.freecodecamp.org/quantomistro3178
h1tag sends brownie points to @quantomistro3178 :sparkles: :thumbsup: :sparkles:
h1tag
@h1tag
Mar 06 2018 13:35
We are all still learning, and always will be
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:35
@h1tag Yeah. That's what tech is all about, keep on learning new things.
h1tag
@h1tag
Mar 06 2018 13:36
plus, JS is weird :p
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:38
@h1tag I've heard a lot of people say that, but I don't really know since it's the first language I'm learning. Don't know any other to compare it to...
lol
h1tag
@h1tag
Mar 06 2018 13:38
@Quantomistro3178 read YDKJS, and you'll see why
Markus Kiili
@Masd925
Mar 06 2018 13:40
@h1tag Pretty elegant for a language originally written in 10 days.
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:40
@h1tag Sure
@Masd925 ?!
Markus Kiili
@Masd925
Mar 06 2018 13:41
@Quantomistro3178 Originally JS was written for Netscape in 10 days, by Brendan Eich in 1995.
That explains some design errors the language has.
h1tag
@h1tag
Mar 06 2018 13:43
@Masd925 yea, maybe because its dynamic also and I haven't tried any other dynamic languages
Edit: I tried PHP before (which isn't weird like JS ;P)
Quantomistro3178
@Quantomistro3178
Mar 06 2018 13:43
@Masd925 I'm having enough trouble trying to learn it...
Diego Mayer
@Chrono79
Mar 06 2018 14:02

@Masd925 yea, maybe because its dynamic also and I haven't tried any other dynamic languages
Edit: I tried PHP before (which isn't weird like JS ;P)

Don't open that door please

He isn't the biggest fan of PHP :P
And PHP has its own big bag of weirdness
Arturo Mago
@ArturoMago
Mar 06 2018 14:17
@rajataudichya What is the credits used for?
Aftab Parvez
@aftabparvez
Mar 06 2018 15:08
If I change the url to : https://api.twitch.tv/helix/streams, I get back the data.
Christopher McCormack
@cmccormack
Mar 06 2018 15:12
@aftabparvez yeah it appears that url redirects to https://api.twitch.tv/kraken/base
Marianissimus
@Marianissimus
Mar 06 2018 15:13
You can try this: https://wind-bow.glitch.me/ @aftabparvez
Matej Bošnjak
@mbosnjak01
Mar 06 2018 15:13
@aftabparvez Did you read this challenge and tried to use https://wind-bow.glitch.me/ API?
@Marianissimus come on ... xD
Christopher McCormack
@cmccormack
Mar 06 2018 15:13
If it makes you feel better @mbosnjak01 I was about to paste it as well :)
Matej Bošnjak
@mbosnjak01
Mar 06 2018 15:14
:D
Christopher McCormack
@cmccormack
Mar 06 2018 15:14
@aftabparvez you're free to use the twitch api if you really want but make sure you read all the documentation, and I'm willing to bet most people here did NOT use the twitch api so may not be able to help without a little research
Aftab Parvez
@aftabparvez
Mar 06 2018 15:24
@cmccormack @mbosnjak01 @Marianissimus Thank you 🙏
CamperBot
@camperbot
Mar 06 2018 15:24
aftabparvez sends brownie points to @cmccormack and @mbosnjak01 and @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 476 | @marianissimus |http://www.freecodecamp.org/marianissimus
:star2: 1369 | @cmccormack |http://www.freecodecamp.org/cmccormack
:cookie: 244 | @mbosnjak01 |http://www.freecodecamp.org/mbosnjak01
Matej Bošnjak
@mbosnjak01
Mar 06 2018 15:30
@aftabparvez In the end it's all the same because you can make your own JSON object(s) and call them localy, and work with the data the same way you'd be working using api, only the link would be different
you don't have to make it difficult to yourself in order to learn something :)
anyway, your call
Markus Kiili
@Masd925
Mar 06 2018 16:08
@Chrono79 :imp:
Nate Mallison
@NJM8
Mar 06 2018 16:09
Hi, I am hoping for some bootstrap help, I want to detect when a modal is closed with JS, I know you can do this with $('#score-modal').on('hidden.bs.modal', function(){}; But is there a way to do it without jQuery? I tried attaching an event listener to the modal and to the window for 'hidden.bs.modal', no luck.
Matej Bošnjak
@mbosnjak01
Mar 06 2018 16:13
@NJM8 Maybe you can do it with appending/removing class with js
Jason Luboff
@JLuboff
Mar 06 2018 16:14
@Chrono79 @cmccormack @mbosnjak01 @Masd925 :wave:
Christopher McCormack
@cmccormack
Mar 06 2018 16:14
@JLuboff whatup
Matej Bošnjak
@mbosnjak01
Mar 06 2018 16:14
and if your desired element has, for example, class "open" or "active", modal is open ... and if it doens't have that class, it's closed
Jason Luboff
@JLuboff
Mar 06 2018 16:14
@cmccormack Just starting the day...I'm finding myself drinking coffee more and more frequently now.. heh.. you?
Matej Bošnjak
@mbosnjak01
Mar 06 2018 16:16
I am currently thinking of how to get an array of cities in some area, and then append a road route from first to last
Christopher McCormack
@cmccormack
Mar 06 2018 16:16
@JLuboff yes I also find myself drinking too much coffee
Matej Bošnjak
@mbosnjak01
Mar 06 2018 16:16
while appending weather icons over each city
all shown on google maps or something like that
XD
Jason Luboff
@JLuboff
Mar 06 2018 16:17
@cmccormack I never used to drink coffee...until I had a kid hahaha
Christopher McCormack
@cmccormack
Mar 06 2018 16:18
@JLuboff if you can stop now, do it before the headaches come!
Nate Mallison
@NJM8
Mar 06 2018 16:20
@cmccormack Come on now, who doesn't love a good caffeine headache. It's like playing chemistry with your body. Not enough water? headache. Not enough coffee? headache. Too much water? pee every 5 minutes. Too much coffee? headache. It's fun!
Kaz Baig
@kbaig
Mar 06 2018 16:20
@NJM8 Don't forget the tummy aches :)
I love being an adult now
Nate Mallison
@NJM8
Mar 06 2018 16:21
Yeah, I helped those by getting a chemex, extra thick paper filter so not as much acidity
:+1:
Markus Kiili
@Masd925
Mar 06 2018 16:22
@JLuboff Yo.
Nate Mallison
@NJM8
Mar 06 2018 16:22
And it's more labor intensive to accidentally drink 8 cups so that helps.
Christopher McCormack
@cmccormack
Mar 06 2018 16:22
@NJM8 you can just toss a little salt in to the grounds for that as well
Nate Mallison
@NJM8
Mar 06 2018 16:23
@cmccormack interesting, I think I heard about that awhile back but never tried
Christopher McCormack
@cmccormack
Mar 06 2018 16:23
@NJM8 works OK - I've been tossing a small pinch of kosher in every morning for a year or so and it seems fine
Jason Luboff
@JLuboff
Mar 06 2018 16:24
@cmccormack Meh... I have daily headaches already. Doesn't make a difference lol
Christopher McCormack
@cmccormack
Mar 06 2018 16:24
@JLuboff drink more water too! headaches are often attributed to dehydration, and coffee sure doesn't help with that
Diego Mayer
@Chrono79
Mar 06 2018 16:37
:wave: @all
Christopher McCormack
@cmccormack
Mar 06 2018 16:37
@Chrono79 heya! Long time no see
Diego Mayer
@Chrono79
Mar 06 2018 16:40
took a couple of weeks for vacations, still tired, but accustomed to it
Christopher McCormack
@cmccormack
Mar 06 2018 16:41
@Chrono79 vacation can be exhausting, we always joke we need a vacation after our vacation but it's not a joke some times
Jason Luboff
@JLuboff
Mar 06 2018 16:49
@cmccormack I drink roughly 3/4 to a gallon of water a day
@Chrono79 Go anywhere or have a staycation?
Christopher McCormack
@cmccormack
Mar 06 2018 16:49
@JLuboff maybe it's the LA water :D
Jason Luboff
@JLuboff
Mar 06 2018 16:49
Psh... I don't drink LA water
Kelechi Chinaka
@ke1echi
Mar 06 2018 16:49
:wave: guys
Jason Luboff
@JLuboff
Mar 06 2018 16:50
Hey
Kelechi Chinaka
@ke1echi
Mar 06 2018 16:50
hope u r good? @Chrono79
Markus Kiili
@Masd925
Mar 06 2018 16:50
@JLuboff I have only Persistent Headache Pulsation when I read this chat.
Jason Luboff
@JLuboff
Mar 06 2018 16:50
:joy:
Jason Luboff
@JLuboff
Mar 06 2018 16:55
Whats everyone working on today?
Markus Kiili
@Masd925
Mar 06 2018 16:57
@JLuboff Read about Julia language. Interesting.
Diego Mayer
@Chrono79
Mar 06 2018 16:58
@JLuboff sadly staycations
Christopher McCormack
@cmccormack
Mar 06 2018 16:58
@JLuboff breaking Codepen playing with hsl values
Jason Luboff
@JLuboff
Mar 06 2018 16:58
@Masd925 Looks like it's a very math driven language?
@Chrono79 It's better than no vacations :D
@cmccormack now now, be nice to poor ol' codepen
Diego Mayer
@Chrono79
Mar 06 2018 16:59
the glass half full uh?
Jason Luboff
@JLuboff
Mar 06 2018 16:59
Yup!
Markus Kiili
@Masd925
Mar 06 2018 17:00
@JLuboff Yes, meant for numerical computing. Bit too small yet maybe. Could die away.
Christopher McCormack
@cmccormack
Mar 06 2018 17:01
@JLuboff it can't handle drawing 3600000 divs apparently
Jason Luboff
@JLuboff
Mar 06 2018 17:01
....thats a lot of divs
Christopher McCormack
@cmccormack
Mar 06 2018 17:01
was an accident :D
Firefox was a champ though - couldn't even get to the edit page in Chrome but firefox was great at stopping it from loading when it saw it was slow
Jason Luboff
@JLuboff
Mar 06 2018 17:02
There's a reason I use FF over chrome
Markus Kiili
@Masd925
Mar 06 2018 17:05
@JLuboff Finally started learning ES6 this week.
Jason Luboff
@JLuboff
Mar 06 2018 17:08

Alright. Got a question! Becuase I'm lazy, I still use jQuery. I'm going to have a file uploader and want to get the file name. In vanilla JS you would do

let file = document.getElementById('id');
console.log(file.files.name); //You would place this in a change event listener

However, in jQuery, this does not work

console.log($('#id').files.name); //We get undefined

According to what I've found, the different is that jQuery wraps the DOM element into an object, where as vanilla gets strictly the DOM element. Ok, so then we need to target the first element of that object using [0] but that still doesn't work. It's not a big deal to mix vanilla with jQuery which works, but just wondering if anybody knows the pure jQuery method?

alpox
@alpox
Mar 06 2018 17:09
@JLuboff $("#id").get(0).files[0].name does this work?
Jason Luboff
@JLuboff
Mar 06 2018 17:09
I was trying $('#id')[0].files.name
alpox
@alpox
Mar 06 2018 17:09
Or $("#id")[0].files[0].name
Jason Luboff
@JLuboff
Mar 06 2018 17:10
let me try
@alpox Thanks. Second one worked
CamperBot
@camperbot
Mar 06 2018 17:10
jluboff sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1574 | @alpox |http://www.freecodecamp.org/alpox
alpox
@alpox
Mar 06 2018 17:11
@JLuboff :thumbsup:
Jason Luboff
@JLuboff
Mar 06 2018 17:11
I guess I should have tried a few more console.logs :D
alpox
@alpox
Mar 06 2018 17:11
Np :D
Jason Luboff
@JLuboff
Mar 06 2018 17:11
And now I can use $(this) even better!
alpox
@alpox
Mar 06 2018 17:11
:thumbsup:
Jason Luboff
@JLuboff
Mar 06 2018 17:12
Dooppee!
Too bad my current form looks like shit lol
Daniel Romero
@Ranacode
Mar 06 2018 18:11
problem fetching data on react native
this.state.albums is undefined
import React, { Component } from 'react';
import { View, Text } from 'react-native';

class AlbumList extends Component {
  state = {
    albums: [],
  };

  componentDidMount() {
    fetch('https://rallycoding.herokuapp.com/api/music_albums')
      .then(response => response.json())
      .then((responseJSON) => {
        console.log(responseJSON);
        this.setState({ albums: responseJSON.data });
      })
      .catch(error => console.error(error));
  }

  renderAlbums = () => this.state.albums.map(album => <Text key={album.title}>album.title</Text>);

  render() {
    return <View>{this.renderAlbums()}</View>;
  }
}

export default AlbumList;
The responseJSON have the data I wanted to fetch because I can see it on the chrome console but it shows me an undefined error trying to map an undefined object (this.state.albums.map...) on the android emulator
Christopher McCormack
@cmccormack
Mar 06 2018 18:37
@Ranacode can you provide the format of responseJSON as well as the full error?
@Ranacode also album.title should be an expression in your Text component
Matej Bošnjak
@mbosnjak01
Mar 06 2018 19:17
@cmccormack https://rallycoding.herokuapp.com/api/music_albums well this is the format, right? :D
Christopher McCormack
@cmccormack
Mar 06 2018 19:18
@mbosnjak01 probably but I'm not going to do all the work :)
@Ranacode albums: responseJSON.data what is .data?
Matej Bošnjak
@mbosnjak01
Mar 06 2018 19:19
looking at the same thing
lel
XD
@cmccormack does all of that makes sense to you? :|
Christopher McCormack
@cmccormack
Mar 06 2018 19:22
@mbosnjak01 hmm all of what exactly?
Matej Bošnjak
@mbosnjak01
Mar 06 2018 19:22
whole componentDidMount
also, this.setState({ albums: responseJSON.data }); ... shouldn't here be a .push as well?
Christopher McCormack
@cmccormack
Mar 06 2018 19:25
@mbosnjak01 yeah it's a pretty standard json fetch
@mbosnjak01 it's React so you'll be replacing state based on the object passed in setState
Matej Bošnjak
@mbosnjak01
Mar 06 2018 19:25
I don't do react native so it looks weird to me as I don't know where responseJSON comes from
although i need to switch to react cause generating even the most simple template in plain js is hardcore pain
:|
Christopher McCormack
@cmccormack
Mar 06 2018 19:26
@mbosnjak01 agreed :)
@mbosnjak01 responseJSON is the actual json object returned from fetch, after calling .json() on the initial response
Matej Bošnjak
@mbosnjak01
Mar 06 2018 19:28
em, did you work with google maps apis maybe?
Christopher McCormack
@cmccormack
Mar 06 2018 19:32
@mbosnjak01 a tiny bit
Matej Bošnjak
@mbosnjak01
Mar 06 2018 19:33
I'll need to use Drawing on the map for icons and Directions service .. and I am wondering, after gathering all of the data I need to generate a map, after calling one api to generate a direction( a road route) and then api to add drawings on the map(icons), will one override the other?
Christopher McCormack
@cmccormack
Mar 06 2018 19:35
@mbosnjak01 i've never worked at that level, mostly just including maps with their api and some options, sorry
Frederik De Bleser
@fdb
Mar 06 2018 19:37

I have an unusual question: I was parsing data from an API but came across a really weird format. It looks like this:

"a:4:{s:4:\"bars\";a:31:{i:0;a:63:{s:5:\"PubID\";s:2:\"44\";s:7:\"PubName\";s:9:\"Den Engel\";

Anybody knows what it is called?

Jason Luboff
@JLuboff
Mar 06 2018 19:42
Looks sort of like a really messy object but its not a standard object
Christopher McCormack
@cmccormack
Mar 06 2018 19:43
@fdb did you read the api documentation?
Frederik De Bleser
@fdb
Mar 06 2018 19:44
@cmccormack I'm scraping the data so there is no documentation :-)
Gulsvi
@gulsvi
Mar 06 2018 19:45
@fdb Just looks like a stringified object with escaped characters
(maybe missing an endquote)
Or maybe there's another line to parse below it with the final endquote
Frederik De Bleser
@fdb
Mar 06 2018 19:46
It's much, much longer. This is just part of it.
From what I gather it lists the type + amount, so an array with 4 elements, containing a string with 4 characters, "bars", then an array with 31 elements, consisting of an integer with the value 0, ...
Christopher McCormack
@cmccormack
Mar 06 2018 19:47
@Ranacode stripping out your react native stuff this works:
class AlbumList extends React.Component {
  state = {
    albums: [],
  }

  componentDidMount() {
    fetch('https://rallycoding.herokuapp.com/api/music_albums')
      .then(response => response.json())
      .then((responseJSON) => {
        this.setState({ albums: responseJSON })
      })
      .catch(console.error)
  }

  renderAlbums = () => this.state.albums.map(album => <div>{album.title}</div>)

  render() {
    return ( 
      <div>
        { this.state.albums.length > 0 && this.renderAlbums() }
      </div>
    )
  }
}

ReactDOM.render(<AlbumList />, document.body)
Frederik De Bleser
@fdb
Mar 06 2018 19:48
Found it! This seems to be PHP's serialization format. https://secure.php.net/manual/en/function.unserialize.php
Thanks for your help. Just writing it down actually helped me find the solution ;-)
Christopher McCormack
@cmccormack
Mar 06 2018 19:49
@fdb :thumbsup:
Nate Mallison
@NJM8
Mar 06 2018 19:51
Hey I need some help with jQuery animate. I am using it on my weather app. http://www.natethedev.com/FreeCodeCampFrontEndProjects/localWeather/
If you search for a location everything works just fine but on the second search or upon clicking 'get new gifs' the gifcontainers no longer animate in. they just pop in.
I think I just realized why. ha
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:09
//I tried var classPoints = []; but couldn't make it work.
function betterThanAverage(classPoints, yourPoints) {
  var total = 0;
  for (var i = 0; i < classPoints.length; i++) {
    total = total + classPoints[i];
  }
  var average = total / classpoints.length;

  if (yourPoints > average) {
    return True;
  }

  else {
    return False;
  }
}
May I get some help with it?
classPoints should be an array but I can't find a way to declare it.
Brad
@bradtaniguchi
Mar 06 2018 21:09
@imran-n classPoints is being passed to the function right? Do you have to declare it or should it already be declared?
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:10
I believe I have to declare it
Matej Bošnjak
@mbosnjak01
Mar 06 2018 21:10
if you want classpoints inside your array
Jason Luboff
@JLuboff
Mar 06 2018 21:10
classPoints is a parameter, it should be initilized in the function call (or a variable declared outside both the function and function call which is used in the function call)
Matej Bošnjak
@mbosnjak01
Mar 06 2018 21:11
you should have an array declared as in your comment, and then do classPoints.push(values[i])
or am I wrong here?
and then do total / classPoints.length
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:13
betterThanAverage([3, 4, 6], 7); //should return True
Jason Luboff
@JLuboff
Mar 06 2018 21:13
Ok, so [3, 4, 6] is the argument passed to the parameter classPoints
7 is yourPoints
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:13
Yeah
Jason Luboff
@JLuboff
Mar 06 2018 21:14
@imran-n
Also, its true and false
not True and False
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:18
another example, betterThanAverage([2, 3], 5) should return True (or true)
and im getting the error ReferenceError: classpoints is not defined
at betterThanAverage
Jason Luboff
@JLuboff
Mar 06 2018 21:19
True is not a valid javascript boolean. If they want True then it needs to be a string.
Stephen James
@sjames1958gm
Mar 06 2018 21:19
@imran-n check your upper vs. lower cases
Jason Luboff
@JLuboff
Mar 06 2018 21:20
@imran-n And as @sjames1958gm just pointed out, Javascript is case sensitive.. classPoints is not the same as classpoints
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:21
I'm trying to solve a codewars challenge so you may ignore what it says in the error message. classPoints and True are the given values
my problem is I can't declare classPoints as an array
Jason Luboff
@JLuboff
Mar 06 2018 21:22
You don't have it
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:22
it has to be such that betterThanAverage([2, 3], 5) returns true
Jason Luboff
@JLuboff
Mar 06 2018 21:22
Line 7 you have a spelling error
Kelechi Chinaka
@ke1echi
Mar 06 2018 21:22
share link
Jason Luboff
@JLuboff
Mar 06 2018 21:22
classpoints is not equivelent to classPoints
Imran N. Huda
@removed~imran-n
Mar 06 2018 21:24
Oh, just noticed it now lol
Thanks for pointing it out XD
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:26
hello everyone
Jason Luboff
@JLuboff
Mar 06 2018 21:26
Yo
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:26
all good @JLuboff ?
Christopher McCormack
@cmccormack
Mar 06 2018 21:27
@tiagocorreiaalmeida hello
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:27
hey @cmccormack :D
need a little help here
            let data = new FormData();
            console.log(this.state.file);
            data.append("avatar", this.state.file);
            console.log(data);
do you see any issue on this?
somehow doesnt append the file
Jason Luboff
@JLuboff
Mar 06 2018 21:27
@tiagocorreiaalmeida Ya not bad. Just working. Went to the gym during lunch, worked out nicely
You?
Christopher McCormack
@cmccormack
Mar 06 2018 21:28
@tiagocorreiaalmeida is append a method on data?
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:28
sick and failed my fight class today the only good thing of the week to release stress :D, how c#?
@cmccormack I think so
readed a bit around
Jason Luboff
@JLuboff
Mar 06 2018 21:29
@tiagocorreiaalmeida Been working on a nodejs/sql app, only updating stuff in C# as issues arise.
Christopher McCormack
@cmccormack
Mar 06 2018 21:29
@tiagocorreiaalmeida did you create FormData?
@JLuboff nice :D atually im thinking about finally using sql on my next project, was it too complicated or easy to setup?
Jason Luboff
@JLuboff
Mar 06 2018 21:32
@tiagocorreiaalmeida I find it more difficult to work with than Mongo, but thats mainly due to the relational nature of things.
I'm useing Microsoft SQL Express for development with no issues
I didn't do anything special in setting up the database, just created it and started adding tables
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:33
I see, can I see an example of a normal select?
if you do have one
Christopher McCormack
@cmccormack
Mar 06 2018 21:34
@tiagocorreiaalmeida try
for (item of data) {
  console.log(item)
}
Jason Luboff
@JLuboff
Mar 06 2018 21:34
@tiagocorreiaalmeida
Select l.LocationID, l.LocationName, p.Email
                               from Location as l
                               Inner Join Person as p
                               on l.ForemanID = p.PersonID
                               order by LocationName
well thats the select statement but not including the actual JS side lol
Christopher McCormack
@cmccormack
Mar 06 2018 21:35
@tiagocorreiaalmeida looks like it's an Iterator so you may need to treat it different
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:35
I wanted to see the js :D, can you use promises by using any package ?
Jason Luboff
@JLuboff
Mar 06 2018 21:35
using mssql package..
sql
      .connect(sqlConfig)
      .then(pool => {
        const request = new sql.Request();
        request.multiple = true;


        return request.query(`Select l.LocationID, l.LocationName, p.Email
                               from Location as l
                               Inner Join Person as p
                               on l.ForemanID = p.PersonID
                               order by LocationName`).then(result => {})
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:35
@cmccormack trhows undefined can't evne open the page :D eslinter xd
Jason Luboff
@JLuboff
Mar 06 2018 21:36
@tiagocorreiaalmeida mssql allows you to use promises, async, or callbacks
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:36
@JLuboff just wanted to know that :D looks great and thanks
CamperBot
@camperbot
Mar 06 2018 21:36
tiagocorreiaalmeida sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2357 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 06 2018 21:36
There is sequelize which is an ORM for SQL but I didn't want to deal with that lol
Christopher McCormack
@cmccormack
Mar 06 2018 21:37
@tiagocorreiaalmeida are you not using latest es?
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:37
I am that's the strange part
Christopher McCormack
@cmccormack
Mar 06 2018 21:40
@tiagocorreiaalmeida works here
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:40
image.png
I guess its just eslint
Christopher McCormack
@cmccormack
Mar 06 2018 21:41
I didn't have a v in my code
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:41
            for (v of data) {
                console.log(v)
            }
Christopher McCormack
@cmccormack
Mar 06 2018 21:41
not in the code I pasted in here
but I added let try it again
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:42
ok got it :D
so sadly the issue is on the api :D, thanks @cmccormack
CamperBot
@camperbot
Mar 06 2018 21:44
tiagocorreiaalmeida sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1375 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Mar 06 2018 21:44
@tiagocorreiaalmeida what issue
that's how it works
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:46
I mean the issue on my api code :D
            let data = new FormData();
            data.append("avatar", this.state.file);
            try {
                let data = await axios.patch("/api/user/avatar", data);
                console.log(data);
            } catch (e) {
                this.setState(() => ({ errorMessage: e.response.data.error, successMessage: "" }))
            }
router.patch("/avatar", upload.single("avatar"), auth, async (req, res) => {
somehow Im doing something different on postman that im doing on my axios request and can't spot what
Christopher McCormack
@cmccormack
Mar 06 2018 21:52
Never used postman sorry
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 21:53
its just a tool that we use to test manually an api
the strange aprt is when I patch the the route above on postman works :\
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:01
uh ok express bodyparser has a file limit :D
Jason Luboff
@JLuboff
Mar 06 2018 22:01
You're uploading a file through bodyparser? I thought it didn't allow for file upload
Tai Jones
@taiJones00
Mar 06 2018 22:04
Can I use JQuery inside of React? I want to get JSON and I feel that the regualar javascript way is too much code
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:05
get json? you mean make an http request?
@JLuboff I was sending it in the request body as a key value, value being the image, but at this point im just testing out can't figure out what's wrong :D
Jason Luboff
@JLuboff
Mar 06 2018 22:07
@tiagocorreiaalmeida Oh, interesting
Christopher McCormack
@cmccormack
Mar 06 2018 22:07
@taiJones00 try using fetch
@taiJones00 it's a little more verbose to grab json or post but you don't need to import jquery
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:08
@taiJones00 or just use axios :D
Christopher McCormack
@cmccormack
Mar 06 2018 22:09
@taiJones00 here's an example of a get request using fetch I made to help someone earlier.
Gulsvi
@gulsvi
Mar 06 2018 22:09
Unless JSONP is needed, then jQuery may be cleaner :)
But yes, jQuery works with react just fine - it's all JS
Tai Jones
@taiJones00
Mar 06 2018 22:11
Is fetch just apart of javaScript? No importing required unlike JQuery? @cmccormack
Christopher McCormack
@cmccormack
Mar 06 2018 22:11
@taiJones00 correct
@gulsvi @taiJones00 if you need to do jsonp I have a vanilla way to do that as well
Tai Jones
@taiJones00
Mar 06 2018 22:12
Awesome. What do you think of this? It looks best on desktop now @cmccormack https://codepen.io/taiJones00/pen/NyoGdm?editors=0010
Stephen James
@sjames1958gm
Mar 06 2018 22:12
@taiJones00 It is part of the browser API and not specifically part of js.
Tai Jones
@taiJones00
Mar 06 2018 22:13
Oh like it comes with every browser. That's interesting @sjames1958gm
Christopher McCormack
@cmccormack
Mar 06 2018 22:13
@sjames1958gm thank you for the correction
CamperBot
@camperbot
Mar 06 2018 22:13
cmccormack sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9063 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Adel
@AdelMahjoub
Mar 06 2018 22:13
you can use request and http too
ah you are writing on codepen, nvm then sorry :smile:
Christopher McCormack
@cmccormack
Mar 06 2018 22:15
@taiJones00 looks good - now add a way to clear all input as well as a way to copy all text to clipboard :)
Tai Jones
@taiJones00
Mar 06 2018 22:15
Wha couldn't they easily copy with keyboard shortcuts? @cmccormack
Christopher McCormack
@cmccormack
Mar 06 2018 22:15
@taiJones00 I'm just offering up a challenge
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:16
@cmccormack wanna know what was my issue?:D
Tai Jones
@taiJones00
Mar 06 2018 22:16
Gotcha @cmccormack
Christopher McCormack
@cmccormack
Mar 06 2018 22:16
@tiagocorreiaalmeida PEBCAK?
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:16
indeed :D
     let data = new FormData();
            data.append("avatar", this.state.file);
            try {
                let data = await axios.patch("/api/user/avatar", data);
                console.log(data);
            } catch (e) {
                this.setState(() => ({ errorMessage: e.response.data.error, successMessage: "" }))
            }
look closely :D
what happens inside the try block :D
Christopher McCormack
@cmccormack
Mar 06 2018 22:17
you're logging the promise?
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:17
ahahah close
look what happens in line 1 and line 4
Christopher McCormack
@cmccormack
Mar 06 2018 22:17
jeeze why are you declaring data three times?
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:17
ahahahah there you go
Christopher McCormack
@cmccormack
Mar 06 2018 22:18
well, twice I guess
so was axios using FormData?
Tiago Correia
@tiagocorreiaalmeida
Mar 06 2018 22:19
yeah it worked perfectly my issue is that latelly I desctructor the object directly
like this
let { data: avatar } = await axios.patch("/api/user/avatar", data);
but this time just writed data for some reason :D
@taiJones00 looks good :)
Christopher McCormack
@cmccormack
Mar 06 2018 22:20
@tiagocorreiaalmeida ah that will do it
Jason Luboff
@JLuboff
Mar 06 2018 22:26
I wish there were more hours in a day so I could learn more lol
Christopher McCormack
@cmccormack
Mar 06 2018 22:32
There are 72 free hours in a week if you subtract 40 hours for work and 8 hours of sleep @JLuboff :p
Jason Luboff
@JLuboff
Mar 06 2018 22:32
@cmccormack You're forgetting the hours to spend with the wife and child ;) (you should know the wife one!)
Matej Bošnjak
@mbosnjak01
Mar 06 2018 22:33
what about the time to go to work or get home from work, eat, shower, bathroom stuff ... ? XD
Christopher McCormack
@cmccormack
Mar 06 2018 22:36
just mimicking what I had listened to seconds before @JLuboff said that on the FCC podcast XD
Jason Luboff
@JLuboff
Mar 06 2018 22:37
:)
Gulsvi
@gulsvi
Mar 06 2018 23:52
@cmccormack That's some fancy Vanilla JS JSONP, nice work :)
My basic approach without a Promise, using the weather API as an example:
var url = "https://fcc-weather-api.glitch.me/api/current?lat=35&lon=139"
var scriptEl = document.createElement("script");

scriptEl.src = url + "&callback=getData";
document.body.appendChild(scriptEl);

function getData(data) {
  console.log(data);
}