These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Mar 2018
FlashHero
@FlashHero
Mar 29 2018 00:03
@MelMacaluso I'm not farmilar with vuejs but if vue has it's own server and you're trying to merge it with express server then you can use proxy for that
Mel Macaluso
@MelMacaluso
Mar 29 2018 00:04
uhm that's a point!
so the flow would be like this: frontend file's form sends a post request to my "express server" (whatever that means or does), it gets the request and then sends back to the frontend?
FlashHero
@FlashHero
Mar 29 2018 00:06
yes, so both server are on different ports and you have your form created using vuejs and when you click submit or whatever it sends a post request to the express server which is in a different port
you can set up a proxy in the webpack.config.js
Mel Macaluso
@MelMacaluso
Mar 29 2018 00:08
thanks man
how will that work in practice?
ie.
```
createMergedPlaylist() {
    console.info("actual token: " + localStorage.code)
    axios({
        method: 'post',
        url: 'https://api.spotify.com/v1/users/' + this.userId + '/playlists',
        data: { name:this.mergePlaylistName, public:false},
        headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + localStorage.code}
    })
    .then(function (response) {
        console.log(response);
    })
    .catch(function (error) {
        console.log(error);
    });
}
```
FlashHero
@FlashHero
Mar 29 2018 00:11
I don't know about that but this is how I have mine set up in webpack
devServer: {
    hot: true,
    proxy: {
  "/api": "http://localhost:3000"
}
  }
so any request made in port 8080 will go to port 3000 which is the express server and it handles the request there
Mel Macaluso
@MelMacaluso
Mar 29 2018 00:13
aaaah understood, but how do you deal with taht when you go live with the website?
as in you deploy to live
does it work as it is?
FlashHero
@FlashHero
Mar 29 2018 00:14
@MelMacaluso Idk i'm kind of new to this stuff too
Mel Macaluso
@MelMacaluso
Mar 29 2018 00:14
shit, I guess we'd need to trial and error the shit out of that
FlashHero
@FlashHero
Mar 29 2018 00:15
there's probably some documentation or tutorials for that as well
@FlashHero thanks man you pointed me to the right direction
CamperBot
@camperbot
Mar 29 2018 00:17
melmacaluso sends brownie points to @flashhero :sparkles: :thumbsup: :sparkles:
:cookie: 324 | @flashhero |http://www.freecodecamp.org/flashhero
jusgoose
@gusd773
Mar 29 2018 03:07
I'm trying to post my code for my wiki page on github so that somebody on here can look at it since it uses an outside source codepen does not provide to add as an external resource. anybody have any good tutorials?
Ethan C.
@RastaCakes
Mar 29 2018 03:08
@gsud773 are you trying to add in external libraries in codepen?
if you go to the settings on your codepen you can put in links to external libraries
jusgoose
@gusd773
Mar 29 2018 03:11
@RastaCakes well I am deconstructing a search box that animates via a youtube tutorial but it's weird, it adds some ajax thing via the the JS settings in codepen but also links something in the html
@RastaCakes this one https://codepen.io/cool_lazyboy/pen/gXEmra it has something in the settings and then links something else in the html
@RastaCakes I'm assuming the link in the html was the style sheet used for the css but I am unsure how they found the url they added as a resource in the JS settings
Ethan C.
@RastaCakes
Mar 29 2018 03:15
@gusd773 the jquery cloudflare resource?
jusgoose
@gusd773
Mar 29 2018 03:16
@RastaCakes yes what is that and why did they use that specific resource
@RastaCakes it says something about jquery but i'm not sure why they chose that specificly
Ethan C.
@RastaCakes
Mar 29 2018 03:17
@gusd773 if you go to jquery website you can get a link to load files over cdn. cdn is faster than loading files locally because they are hosted on the server. on jquery website it will give you a link to newest version. their specific version was probably the newest when they were making the pen. does that make sense?
jusgoose
@gusd773
Mar 29 2018 03:28
@RastaCakes kind of yes
@RastaCakes so he used that link for the ajax library in order to animate the seach box and button, correct?
Ethan C.
@RastaCakes
Mar 29 2018 03:33
@gsud773 he is linking to jQuery library to add the animation. The jquery is toggling an active class and animate class on the button when it is clicked. the styling for the classes has the different trasform properties that are used
@gusd773
@gusd773 here is the wikipedia for CDN: https://en.wikipedia.org/wiki/Content_delivery_network
@gusd773 here is link to specific jquery section on CDN: http://jquery.com/download/#using-jquery-with-a-cdn
@gusd773 this is where the actual CDNs live for jQuery and their respective versions: https://code.jquery.com/
most libraries and stylesheets are hosted on CDN including bootstrap and font awesome which are on the pen you were referencing.
jusgoose
@gusd773
Mar 29 2018 03:40
@RastaCakes thank you!!
CamperBot
@camperbot
Mar 29 2018 03:40
:cookie: 167 | @rastacakes |http://www.freecodecamp.org/rastacakes
gusd773 sends brownie points to @rastacakes :sparkles: :thumbsup: :sparkles:
Ethan C.
@RastaCakes
Mar 29 2018 03:40
@gusd773 no problem let me know if you have more questions
:smile:
Rajat
@rajataudichya
Mar 29 2018 04:07
hey there ! I am currently stuck on the generation random whole numbers challenge
the function performed here is ```js
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

 // Only change code below this line.
    return Math.floor(Math.random()*10);


}
which means that the number from which Math.random() is multiplied it automatically becomes the max limit of the function
can someone explain how?
abraham anak agung
@padunk
Mar 29 2018 04:20
@rajataudichya https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
The return value is random number between min (inclusive) and max (exclusive)
Donnie
@Donnie-D
Mar 29 2018 05:14
Hi! purpose in the code below is to change the background image depending upon the weather condition returned from the api server. Issue is that the switch statement is not executing the conditions correctly and goes to default case. Could somebody see to this please?
https://codepen.io/Donnie-D/pen/YaydRM
Markus Kiili
@Masd925
Mar 29 2018 05:21
@Donnie-D Check the errors on the browser developer tools console.
Donnie
@Donnie-D
Mar 29 2018 05:22

@Masd925

Access to Font at 'https://static.codepen.io/assets/telefon/bold/af889c53-1ee3-4868-8fdc-2b310d587b50-3-b7a87e0fbd213943fae0c0ef5985635dd43fa9c24876b2725127a13ccaf4ab6a.woff' from origin 'https://codepen.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://codepen.io' is therefore not allowed access.

there is only this error and for some reason this is coming up anyway. Even before I added the switch statement etc.

Markus Kiili
@Masd925
Mar 29 2018 05:23
@Donnie-D I see a mixed content error there.
Donnie
@Donnie-D
Mar 29 2018 05:24
warnings. and yes the answer is same as above for them too.
tbh i would like to get rid of them but not sure how at this point
@Masd925 GOT IT!
Markus Kiili
@Masd925
Mar 29 2018 05:26
@Donnie-D :+1:
Donnie
@Donnie-D
Mar 29 2018 05:26
lol it was the quote marks around the cases :smile:
its working now
grrr little things get undesired results
Nate
@MilitantMario
Mar 29 2018 06:03
So I'm doing the markdown previewer I got my input to work but when I setup the output it says setup error boundries.
marked didn't have any docs for any outputting but react had some docs on it, its called dangerouslysetinnerhtml
abraham anak agung
@padunk
Mar 29 2018 07:03
@MilitantMario your external marked source is wrong. try https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.19/marked.min.js in your JS setting
Nate
@MilitantMario
Mar 29 2018 07:16
thanks @padunk
CamperBot
@camperbot
Mar 29 2018 07:16
militantmario sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 482 | @padunk |http://www.freecodecamp.org/padunk
abraham anak agung
@padunk
Mar 29 2018 07:45
How to deepCompare an object?
say i have this object let obj = {here: {is: "an"}, object: 2}; and a function deepEqual(objOne, objTwo) how to compare that deepEqual(obj, {here: {is: "an"}, object: 2}) will return true.
Any hint?
this is i got so far but it didn't work
function deepEqual(firstObj, secondObj) {
    for(let o in secondObj) {
        if(typeof firstObj[o] === 'object' && typeof secondObj[o] === 'object'){
            if(deepEqual(firstObj[o], secondObj[o])){
                continue;
            }
        } else {
            return firstObj[o] === secondObj[o];
        }
    }
}
Sweet Coding :)
@SweetCodingInc
Mar 29 2018 08:13
@padunk looks like it's working for me
abraham anak agung
@padunk
Mar 29 2018 08:17
@SweetCodingInc not really, i mean if you change the value in is: null it will still return true.
idk if i doing right with the recursion
Blauelf
@Blauelf
Mar 29 2018 08:34

@SweetCodingInc Huh? https://repl.it/repls/LazyFunnyConsulting

@padunk Did you forget a else { return false; } after the continue; } and a final return true;? Also, your existing return should have an if like the other, so you don't stop the loop prematurely. Also, you probably want to check there are no extra keys in the second object. Something like

function deepEqual(firstObj, secondObj) {
    let keys1 = Object.keys(firstObj);
    let keys2 = Object.keys(secondObj);
    if (keys1.length !== keys2.length || keys1.some((key)=>keys2.indexOf(key)===-1)) {
        // different keys
        return false;
    }
    return keys1.every((key) => (firstObj[key] !== null && typeof firstObj[key] === "object" && typeof secondObj[key] === "object") ?
        deepEqual(firstObj[key], secondObj[key]) :
        firstObj[key] === secondObj[key]);
}

(circular references will crash this algo! Like let arr = []; arr[0] = arr; console.log(deepEqual(arr, arr));)

My solution usually is to JSON.stringify both. Not sure how this behaves with order of properties.

abraham anak agung
@padunk
Mar 29 2018 08:38
@Blauelf what is keys1.all? yes i think i forget to return false after continue, but did i do the right thing with the recursion?
Blauelf
@Blauelf
Mar 29 2018 08:38
That's a mistake. It's all in Python, but every in JavaScript.
Python knows all and any, JavaScript is every and some. They are second-order functions like filter and reduce, and they short-circuit, as soon as the result is clear, they stop the loop.
abraham anak agung
@padunk
Mar 29 2018 08:39
@Blauelf Ok, got it. i know every and some Thank you.
Markus Kiili
@Masd925
Mar 29 2018 08:40
@Blauelf Why null there?
Blauelf
@Blauelf
Mar 29 2018 08:42
@Masd925 Otherwise I'd pass null to deepEqual, and I guess deepEqual(null, {}) in my implementation would be true. So I don't want to have it called with null.
abraham anak agung
@padunk
Mar 29 2018 08:43
@Blauelf how to use JSON.stringify for this?
Sweet Coding :)
@SweetCodingInc
Mar 29 2018 08:43
Now it's fine
let obj1 = {here: {is: "an"}, object: 24, or_not: 23};
let obj2 = {here: {is: "an"}, object: 24, or_not: 43};

function deepEqual(obj1, obj2) {

    //compare primitives
    if(isPrimitive(obj1) && isPrimitive(obj2)){
      return obj1 === obj2;
    }

    // if total number of keys is not same, it's an inequality
    if(Object.keys(obj1).length !== Object.keys(obj2).length){
      return false;
    }

    for(let key in obj1) {
        //other object doesn't have this prop
        if(!(key in obj2)) return false;

        if(!deepEqual(obj1[key], obj2[key])) return false;
    }

    return true;
}

function isPrimitive(obj) {
    return (obj !== Object(obj));
}

deepEqual(obj1, obj2);
Michael Grienauer
@mgrienauer
Mar 29 2018 08:45
for my twitch streamer project i keep getting weird results, sometimes the twitch api returns that a streamer is currently streaming but sometimes not, it just depends when i reload the page
also the streamers from my array appear in different orders each time
is there a way to maybe make the function wait until the api has properly returned info?
heres the codepen
abraham anak agung
@padunk
Mar 29 2018 08:49
@SweetCodingInc @Blauelf thank you.
CamperBot
@camperbot
Mar 29 2018 08:49
padunk sends brownie points to @sweetcodinginc and @blauelf :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
:star2: 4688 | @blauelf |http://www.freecodecamp.org/blauelf
Blauelf
@Blauelf
Mar 29 2018 08:49
@padunk I thought about
function deepEqual(obj1, obj2) {
    try {
        return JSON.stringify(obj1) === JSON.stringify(obj2);
    } catch (_) {
        return false; // in case of circular references
    }
}
abraham anak agung
@padunk
Mar 29 2018 08:50
@Blauelf that will do for nested object?
Marianissimus
@Marianissimus
Mar 29 2018 08:51
@Blauelf hey, but you cannot count on the properties order in objects, can you? so stringify can return different results for the same object, right?
Markus Kiili
@Masd925
Mar 29 2018 08:51
Right.
Blauelf
@Blauelf
Mar 29 2018 08:53
@Marianissimus That's perfectly right, but if you control the creation of the objects, and properties are always added in the same order, it still works.
Markus Kiili
@Masd925
Mar 29 2018 08:56
@Blauelf Guaranteed by the standard, or something that browser implementations seem to be doing at the moment?
Blauelf
@Blauelf
Mar 29 2018 08:57
So I've seen this hack in some code out there. Still, even the concept of "deep equal" is subject to definition. Do only the enumerable properties count? What about constructor property, and what if those objects have same name, but are not the same (like arrays from different frames)?
Michael Grienauer
@mgrienauer
Mar 29 2018 09:03
anyone?
Markus Kiili
@Masd925
Mar 29 2018 09:05
@mgrienauer You wait for the api response by doing stuff inside the ajax success callback.
Leigh Hobson
@leighhobson89
Mar 29 2018 09:06

Hi guys, with this code for the "Where Art Thou" challenge:

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var i;
  var keyNames = Object.keys(source);
  console.log(keyNames);
  for (i in collection) {
    if(collection[i].hasOwnProperty(keyNames)) { 
      if (collection[i][keyNames] == source[keyNames]) {
      arr.push(collection[i]);
      console.log(arr);
      }
    }
    else {
      continue;
    }
  }

  // Only change code above this line
  return arr;
}

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

I get two tests passing, and two failing, as below. Even with the console logs, I cant for the life of me work out what's wrong. Any tips? The tests are as follows:

image.png
Markus Kiili
@Masd925
Mar 29 2018 09:07
@leighhobson89 keyNames is an array. You need a second nested loop over it.
Leigh Hobson
@leighhobson89
Mar 29 2018 09:07
the two that fail are returning an empty array for 'arr'
right let m e have a look
Markus Kiili
@Masd925
Mar 29 2018 09:07
Then some logic to keep those objects that have matching property values with source for all the source's keys.
Loops are fine but there are also very handy arrays methods that suit this problem.
Leigh Hobson
@leighhobson89
Mar 29 2018 09:08
i looked at the spoilers and couldnt make head or tail of them at my level lol
i just did what seemed right but as we know thats almost never the best way
Markus Kiili
@Masd925
Mar 29 2018 09:09
@leighhobson89 Start by making a loop over collection, and a nested loop over source's keys.
Michael Grienauer
@mgrienauer
Mar 29 2018 09:09
@Masd925 ok thanks
CamperBot
@camperbot
Mar 29 2018 09:09
mgrienauer sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4749 | @masd925 |http://www.freecodecamp.org/masd925
Leigh Hobson
@leighhobson89
Mar 29 2018 09:09
ok, am i not currently lopoing through collection?
Markus Kiili
@Masd925
Mar 29 2018 09:10
Simple for loop is better than for...in loop when looping over array elements, because the order is not guaranteed with for...in loop. Also for...in loop needlessly looks up the prototype chain for properties.
You are looping yes.
Leigh Hobson
@leighhobson89
Mar 29 2018 09:11
ok
Markus Kiili
@Masd925
Mar 29 2018 09:12
So a for...in loop is meant for looping over enumerable properties of an object and its prototype chain in no particular order. For iterating string or array elements, you should use simple for or while loops or array iterators.
Michael Grienauer
@mgrienauer
Mar 29 2018 09:13
@Masd925 would i use $.when(data).then(function(){ .....
and put my append functions in there?
Markus Kiili
@Masd925
Mar 29 2018 09:15
@mgrienauer You should use the response data inside the success callback. I am not too familiar with when or then.
Michael Grienauer
@mgrienauer
Mar 29 2018 09:19
@Masd925 ah..i am using the data inside the success callback, but im still getting weird responses, like soemtimes it will show properly but other times it will not
Michael Grienauer
@mgrienauer
Mar 29 2018 09:24
idk maybe it a problem with twitch's api but i think its something in my code
Stephen James
@sjames1958gm
Mar 29 2018 09:41
@mgrienauer There is no guarantee that the channel responses for a streamer will comeback before the stream responses.
You are firing off 16 requests and your code depends on the order of the responses being the same as the requests.
Blauelf
@Blauelf
Mar 29 2018 09:48
@Masd925 I think the standard doesn't guarantee any order, but browsers currently put the ordered numeric properties first, followed by the non-numeric in order of creation. I think there's a difference if you remove and re-add a property, if I remember correctly IE would treat that as if the property had not been removed at all.
Leigh Hobson
@leighhobson89
Mar 29 2018 09:54
thanks for before @Masd925 I did it
CamperBot
@camperbot
Mar 29 2018 09:54
leighhobson89 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4750 | @masd925 |http://www.freecodecamp.org/masd925
Nate Mallison
@NJM8
Mar 29 2018 11:44
Can anyone help me with my wikipedia viewer? I have an odd bug where sometimes after the iframes load the page layout gets all screwed up. I'm not really sure what is happening, it only occurs on some searched but is repeatable. Try searching for "whale songs". https://www.natethedev.com/FreeCodeCampFrontEndProjects/wikipediaViewer/
Christopher McCormack
@cmccormack
Mar 29 2018 14:29
@NJM8 yo I know it's much later than when you asked but maybe you're still having the issue? I tested using your search and it seemed fine, did you fix it?
FlashHero
@FlashHero
Mar 29 2018 15:01
@cmccormack you mind sharing what you used for your contact form in your personal portfolio. Does the email go right straight to you or database, I was trying to have it email me but with nodemailer, it looked like only authenticated user can send mail
Christopher McCormack
@cmccormack
Mar 29 2018 15:02
@FlashHero I just used a fairly generic PHP script I found and modified it until it worked. For some reason most don't work without tweaking
one sec
FlashHero
@FlashHero
Mar 29 2018 15:06
@cmccormack ok thanks, I don't use php but what do you think if I authenticate myself and send the email to myself with the email and message provided in the contact form so the person trying to contact me isn't really sending me email but rather I'm sending it to myself with its email and message provided
CamperBot
@camperbot
Mar 29 2018 15:06
flashhero sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1384 | @cmccormack |http://www.freecodecamp.org/cmccormack
Jason Luboff
@JLuboff
Mar 29 2018 15:10
Morning
Christopher McCormack
@cmccormack
Mar 29 2018 15:10
@JLuboff :wave:
@FlashHero should work, lots of ways you could do it
PHP is built into most web servers and is easy to install if you control your own server, fyi
Jason Luboff
@JLuboff
Mar 29 2018 15:12
@cmccormack What up
Christopher McCormack
@cmccormack
Mar 29 2018 15:12
nm man working
Jason Luboff
@JLuboff
Mar 29 2018 15:13
@cmccormack you get tomorrow off?
Christopher McCormack
@cmccormack
Mar 29 2018 15:13
haha we have no holidays
Jason Luboff
@JLuboff
Mar 29 2018 15:13
Whhhaaaattt?
Christopher McCormack
@cmccormack
Mar 29 2018 15:14
I mean, I can use my PTO If I wanted
Jason Luboff
@JLuboff
Mar 29 2018 15:14
That kind of sucks... lol
Christopher McCormack
@cmccormack
Mar 29 2018 15:14
what is tomorrow? good friday?
Jason Luboff
@JLuboff
Mar 29 2018 15:15
Ya I guess
Christopher McCormack
@cmccormack
Mar 29 2018 15:15
It's really not that bad, they give us a ton of PTO
Jason Luboff
@JLuboff
Mar 29 2018 15:16
How many days?
Christopher McCormack
@cmccormack
Mar 29 2018 15:17
almost a month for my position
Jason Luboff
@JLuboff
Mar 29 2018 15:17
Wow, thats nice
Christopher McCormack
@cmccormack
Mar 29 2018 15:17
yeah but most of us don't get or choose to use it, too much to do
FlashHero
@FlashHero
Mar 29 2018 15:18
@cmccormack thanks
CamperBot
@camperbot
Mar 29 2018 15:18
flashhero sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Jason Luboff
@JLuboff
Mar 29 2018 15:18
I get 10 days vacation and 5 days sick pay per year. I can carry over one week vacation and all my sick days but this year they implemented kind of a stupid plan with sick pay. Used to be able to get up to 30 days (From carrying over, and we'd get 8 days per year) but now you can only get up to 12 days and the rest goes into a "longterm" sick pay
Christopher McCormack
@cmccormack
Mar 29 2018 15:20
that's shitty
Jason Luboff
@JLuboff
Mar 29 2018 15:21
Ya... but I guess what're you going to do. Still have a decent amount of sick time and I can use bits and pieces (i.e 2 hours for going to the doctors )
Christopher McCormack
@cmccormack
Mar 29 2018 15:22
how many bank holidays do you get?
Jason Luboff
@JLuboff
Mar 29 2018 15:22
I think 8, I'd have to check
Christopher McCormack
@cmccormack
Mar 29 2018 15:23
what are you working on today?
Jason Luboff
@JLuboff
Mar 29 2018 15:24
Couple of new laptops to build up and continue working on the app
Christopher McCormack
@cmccormack
Mar 29 2018 15:25
close to done with it?
Jason Luboff
@JLuboff
Mar 29 2018 15:28
Ehhhhhhh I'd say I'm roughly 60-65% done.. Almost have all the frontend stuff done. I have all the pages built except for the final review page which should be quick. Then I still need to go in and get all the mailing working (they want wayyyyy too much mail but whatever) and also get cron jobs going to check daily on each request (if its pending or approved) to see if it's been longer than a week that an individual hasn't done anything that they'll get an email
Christopher McCormack
@cmccormack
Mar 29 2018 15:29
That's awesome
I did a little cron work with a node app, seems to still be working, love cron
Jason Luboff
@JLuboff
Mar 29 2018 15:30
Did you use cron package? Thats what I started playing with yesterday. Just testing with a simple log message but I'll need to have it run a query, etc etc
Christopher McCormack
@cmccormack
Mar 29 2018 15:30
no just built in
Jason Luboff
@JLuboff
Mar 29 2018 15:32
There's a built in one?
Christopher McCormack
@cmccormack
Mar 29 2018 15:32
for work they asked me to build a tool to query an api every hour and gather stats in a file so built the tool in node and run it from cron
in linux/unix there is
windows has its own scheduler
Jason Luboff
@JLuboff
Mar 29 2018 15:33
Ah
Christopher McCormack
@cmccormack
Mar 29 2018 15:34
id probably recommend using one of those unstead of a package but ive not used the packages
you're almost guaranteed they will run every boot of the server
Jason Luboff
@JLuboff
Mar 29 2018 15:41
Well I'm using cron package which seems to be quite popular ~345,000 downloads in the last week and then I can do everything within my app (i.e I don't need any special parameters or what not in my run script)
Christopher McCormack
@cmccormack
Mar 29 2018 15:42
is it a schedule for within your app?
I guess that would make sense if your app is always running
Mine didn't have to be always running so I used the OS tool
Jason Luboff
@JLuboff
Mar 29 2018 15:51
@cmccormack Ya its a schedule within the app, and the app is always running
Nate Mallison
@NJM8
Mar 29 2018 16:32
@cmccormack yes I did thanks. The wikipedia page being loaded for some reason scrolled automatically to a certain place on the page, this caused my layout to go all wacky, I'm not sure why that happened but adding the sandbox attribute to the iframes prevented the page from scrolling, so no layout errors
CamperBot
@camperbot
Mar 29 2018 16:32
njm8 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1385 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Mar 29 2018 16:32
@NJM8 awesome, looks pretty cool
Nate Mallison
@NJM8
Mar 29 2018 16:32
I guess whoever made the wikipedia page really wanted you to go to a certain section, that didn't really say anything. haha
Thanks, I'm proud to say that project is vanilla JS
Christopher McCormack
@cmccormack
Mar 29 2018 16:33
@NJM8 did you use xmlhttprequest?
Nate Mallison
@NJM8
Mar 29 2018 16:34
My portfoliopage needs some help though. currently trying to get rid of the terrible parallax choppyness. sadly this is resulting a huge re-write as I'm using MaterializeCSS and their parallax classes do a ton of work behind the scene
no Request and Fetch
Christopher McCormack
@cmccormack
Mar 29 2018 16:34
ok good :)
Nate Mallison
@NJM8
Mar 29 2018 16:35
yeah I went through xmlhttp in a tutorial then they did fetch, the answer for which to use seemed obvious, haha
Christopher McCormack
@cmccormack
Mar 29 2018 16:36
yeah fetch is much cleaner.
might as well use it!
Nate Mallison
@NJM8
Mar 29 2018 16:37
Heard back from github about that A record yesterday, the IP address I ended up using worked but they said it could still cause issues so they gave me proper address for the servers. They are still very different from the ip address that were in there to start with so IDK where that came from
Jason Luboff
@JLuboff
Mar 29 2018 16:37
Magic
Christopher McCormack
@cmccormack
Mar 29 2018 16:37
they actually talked to you?
Jason Luboff
@JLuboff
Mar 29 2018 16:37
Lol
Nate Mallison
@NJM8
Mar 29 2018 16:37
:sparkles:
just email support
Christopher McCormack
@cmccormack
Mar 29 2018 16:38
I just assumed they would only autorespond with a link to their help section
Nate Mallison
@NJM8
Mar 29 2018 16:39
Well, I think it helps that I give them like a 3 paragraph description of the problem and how it started. That way they know what is going on. If I emailed and said "is broke plz fix", I think I would get a different response. ha
Christopher McCormack
@cmccormack
Mar 29 2018 16:39
so did they point you to the relevent help section?
so you can bookmark for later or whatever?
Nate Mallison
@NJM8
Mar 29 2018 16:40
they did, as well as gave me the updated ip address
it was just the using a custom domain help article
Christopher McCormack
@cmccormack
Mar 29 2018 16:43
can you link the article so I can review?
if you still have it
What wasn't clear from the start is they told me to set up two A records, each pointing to the ip address of the server, then one CNAME record with www. pointing to njm8.github.io
that solved it
Christopher McCormack
@cmccormack
Mar 29 2018 16:54
@NJM8 the IP address of the github server?
Jason Luboff
@JLuboff
Mar 29 2018 17:09
Sometimes I stop and look at my project and go "...whats my next step?" and stare at it all day. lol
Nate Mallison
@NJM8
Mar 29 2018 17:18
@cmccormack yes
Jason Luboff
@JLuboff
Mar 29 2018 17:19
I just learned there is a for...of loop in JS
alpox
@alpox
Mar 29 2018 17:20
@JLuboff ES6 :)
Jason Luboff
@JLuboff
Mar 29 2018 17:21
Apparently lol
I was just reading this https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b talks about some points of google JS style guide
and its mentioned there
Christopher McCormack
@cmccormack
Mar 29 2018 17:22
@JLuboff yeah it's great
Jason Luboff
@JLuboff
Mar 29 2018 17:22
Also interesting they state that this:
// bad
let a = 1, b = 2, c = 3;

// good
let a = 1;
let b = 2;
let c = 3;
I like declaring let or const once and not having to retype it :joy:
alpox
@alpox
Mar 29 2018 17:26
I also prefer second version which they say is good
It looks cleaner to me
Jason Luboff
@JLuboff
Mar 29 2018 17:27
I still seperate on seperate lines
i.e
const express = require('express'),
      routes = require('./routes/routes'),
      orCheck = require('./helpers/orCheck'),
      nullCheck = require('./helpers/nullCheck'),
      submitCheck = require('./helpers/submitCheck'),
      actionCheck = require('./helpers/actionCheck'),
      userIsUserCheck = require('./helpers/userIsUserCheck'),
      cron = require('./controllers/cronJobs'),
      session = require('express-session'),
      chalk = require('chalk'),
      hbs = require('hbs'),
      port = process.env.PORT || 3000;
But I guess declaring const on each line does make it clearer
alpox
@alpox
Mar 29 2018 17:29
Yea it kinda does
Christopher McCormack
@cmccormack
Mar 29 2018 17:29
@JLuboff and commas can cause errors if you remove something but still have a dangling comma
alpox
@alpox
Mar 29 2018 17:29
And in vscode you have multicursor so you dont write it so many times :D
Jason Luboff
@JLuboff
Mar 29 2018 17:29
Welp. Google does know more than me... so I guess I'll be changing that :P
@cmccormack True
@alpox I believe atom has that too..I've accidently enabled it sometimes but never knew how or what it was called lol
Markus Kiili
@Masd925
Mar 29 2018 17:30
Yowning.
Brad
@bradtaniguchi
Mar 29 2018 17:30
@JLuboff You talking about/reading the google style guidelines?
Jason Luboff
@JLuboff
Mar 29 2018 17:31
@bradtaniguchi I read the medium article, ya. Didn't go too far into the actual style guide
Brad
@bradtaniguchi
Mar 29 2018 17:32
Yea me neither, I read the same article tho haha. (Ill leave the deep reading to my editor so it can tell me what I should do haha)
Jason Luboff
@JLuboff
Mar 29 2018 17:32
lol
Markus Kiili
@Masd925
Mar 29 2018 17:33
@JLuboff Both seem fine to me, but I dislike that there are two ways for one thing.
Jason Luboff
@JLuboff
Mar 29 2018 17:34
@Masd925 Thats coding though isn't it? Multiple ways to accomplish the same thing
Markus Kiili
@Masd925
Mar 29 2018 17:35
@JLuboff No, it is a design fault in the language or in the world.
Brad
@bradtaniguchi
Mar 29 2018 17:38
I blame the environment more than anything. Other languages have the benefit of breaking changes, but its really hard to make breaking changes on JS, since old sites/old browsers will be affected.
Markus Kiili
@Masd925
Mar 29 2018 17:58
@bradtaniguchi HTML is also nice, since you can write any crap and the browser still shows something.
Adel
@AdelMahjoub
Mar 29 2018 18:33
this disturbing, it looks like one orb is rotating around the other but it is not :dizzy: https://codepen.io/SultanCodeCamper/full/zWRgYM/
Christopher McCormack
@cmccormack
Mar 29 2018 18:37
@AdelMahjoub looks so cool for what it is
Adel
@AdelMahjoub
Mar 29 2018 18:37
@cmccormack :laughing: just messing around, maybe it could be used for a loading screen
Christopher McCormack
@cmccormack
Mar 29 2018 18:38
Sure!
Jason Luboff
@JLuboff
Mar 29 2018 18:48
@AdelMahjoub One orb is going up and down, and the other is going side to side, correct?
Adel
@AdelMahjoub
Mar 29 2018 18:48
@JLuboff yes
Jason Luboff
@JLuboff
Mar 29 2018 18:48
Neat
Nate Mallison
@NJM8
Mar 29 2018 18:50
How can I tell what element is causing double scroll on my site? only happens when I make the screen narrow, like less than 600 px
Markus Kiili
@Masd925
Mar 29 2018 18:52
@AdelMahjoub I made a whole physics engine with JS so I can rotate and bounce balls like that.
Brad
@bradtaniguchi
Mar 29 2018 18:52
@NJM8 Inspect the general area of where the scrollbar appears
Adel
@AdelMahjoub
Mar 29 2018 18:53
@Masd925 I'm actually interested to take a look at it, if it is simpler than box2D
Nate Mallison
@NJM8
Mar 29 2018 18:55
Huh. TIL it's important to actually use responsive design mode and not just make the browser screen narrower
Adel
@AdelMahjoub
Mar 29 2018 18:55
@Masd925 with hit detection and hit resolution too ?
Christopher McCormack
@cmccormack
Mar 29 2018 18:55
@NJM8 responsive design mode is actually pretty buggy, be warned
Markus Kiili
@Masd925
Mar 29 2018 18:55
@AdelMahjoub Yes.
Adel
@AdelMahjoub
Mar 29 2018 18:56
@Masd925 can you share it please :smile:
Nate Mallison
@NJM8
Mar 29 2018 18:56
Guess I'll have to head to best buy and pick up some spare devices, for uhh, research. :smile:
Markus Kiili
@Masd925
Mar 29 2018 18:57
@AdelMahjoub It is in use in my code portfolio page. You can steal it from there.
Adel
@AdelMahjoub
Mar 29 2018 18:57
@Masd925 cool, thanks
CamperBot
@camperbot
Mar 29 2018 18:57
adelmahjoub sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4751 | @masd925 |http://www.freecodecamp.org/masd925
Stephen James
@sjames1958gm
Mar 29 2018 20:00
@NJM8 You can use chrome dev tools to simulate all sorts of device sizes
Tell me what you think about it
Imran N. Huda
@removed~imran-n
Mar 29 2018 22:15

let cards = ['Diamond', 'Spade', 'Heart', 'Club'];
let currentCard = cards[1];
//Create a while loop. The condition should check if the currentCard is NOT a 'Spade'.
while (currentCard !== cards[1]) {

}

can someone help?
LuisHerasme
@LuisHerasme
Mar 29 2018 22:16
It works
Imran N. Huda
@removed~imran-n
Mar 29 2018 22:17
Codecademy is giving an error
"Make sure you have spelled everything correctly."
LuisHerasme
@LuisHerasme
Mar 29 2018 22:18
There's more code?
Imran N. Huda
@removed~imran-n
Mar 29 2018 22:19

just "Below the array cards, create a variable named currentCard and set it equal to 'Spade'.

This variable will hold the name of the card we just flipped. We are using 'Spade' as the first card."

that's step 1
I'm stuck at step 2
LuisHerasme
@LuisHerasme
Mar 29 2018 22:19
What is the step2?
let currentCard = 'Spade'
Imran N. Huda
@removed~imran-n
Mar 29 2018 22:24
step 2 is the comment i posted //Create a while loop. The condition should check if the currentCard is NOT a 'Spade'.
Imran N. Huda
@removed~imran-n
Mar 29 2018 22:34
Nevermind, I got it :)
thanks though
Mois├ęs Man
@moigithub
Mar 29 2018 22:52
any1 know similar to electron what other technology/platform r used to create desktop apps ? using javascript
Brad
@bradtaniguchi
Mar 29 2018 23:17
@moigithub Theres nw.js, I believe its older than electron. Idk what the differences are tho
Gulsvi
@gulsvi
Mar 29 2018 23:17
@moigithub Positron and Neutronium perhaps?
Oh wait... Positron is for layering HTML on top of a .NET app - need to use C#, not JavaScript I think
Stephen James
@sjames1958gm
Mar 29 2018 23:47
@moigithub there is CEF which we use on our project. nw.js is like electron, but I could never get it to work reliably.