These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Sep 2017
luccifer00
@luccifer00
Sep 05 2017 00:05
@Gersho thanks !! nice to hear that i am doing the right things!!
CamperBot
@camperbot
Sep 05 2017 00:05
luccifer00 sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 401 | @gersho |http://www.freecodecamp.com/gersho
luccifer00
@luccifer00
Sep 05 2017 00:07
@sjames1958gm i créate var index, but, just for test , if that return me what i want! :smile: i'm still checking almost each step , to understand if i know what i am doing!
Stephen James
@sjames1958gm
Sep 05 2017 00:08
ok
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",

    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
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.
Gersho
@Gersho
Sep 05 2017 00:41
hmm, you're not sorting them alphabetically
oh wait nvm i'm confusing with another challenge xD
Stephen James
@sjames1958gm
Sep 05 2017 00:44
@artoodeeto collection.tracks = [value]; this is the culprit
aRtoo
@artoodeeto
Sep 05 2017 00:44
@sjames1958gm i got bro. thanks
CamperBot
@camperbot
Sep 05 2017 00:44
artoodeeto sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8440 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Bryan Reese
@breese8009
Sep 05 2017 00:53
how do i target a data id using jquery?? heres my function so far...im trying it using current variable
function handleDeleteBjj(e) {
  let current = $(this).closest('.card').data('id');
console.log(current);
 $.ajax({
  method:"DELETE",
  url: '/api/bjj/'+current,
  success: current.remove()
 })
}
but its gettin me undefined
piteto
@piteto
Sep 05 2017 01:00

Hadn't seen .data() before, looks like it's the same as dataset in vanilla JS but the docs say to use .attr() to get the value as a string.

<div id="myDiv">
  <div id="hello" data-id="hello">Hello</div>
</div>

This works for the HTML above:

let current = $("#myDiv").closest("div").attr('data', 'id');
current.remove();
Bryan Reese
@breese8009
Sep 05 2017 01:05
@piteto thats what i have
piteto
@piteto
Sep 05 2017 01:59
Sorry, to be clear @breese8009 .data('id'); is different than .attr('data', 'id'). The docs suggest you need to use .attr() because 'id' is a string not an object.
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!
Marc
@MWBauer
Sep 05 2017 03:23
Hello everyone!
Not actually here.
lfvpCO
@lfvpCO
Sep 05 2017 03:27
new JS for newbies
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 03:31
After beta.fcc reactjs where do I go for a more simple but in depth course on reactjs
Andrew Kay
@andrewjkay
Sep 05 2017 03:32
@RoniqueRicketts what's the last thing they teach in the beta?
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 03:40
@andrewjkay react sections on beta has reduxjs I havemt started reduxjs
Andrew Kay
@andrewjkay
Sep 05 2017 03:42
@RoniqueRicketts if you're still feeling shaky about react in general I'd suggest the codecademy tutorial. If you know specifically where you're struggling, the react docs are really well written
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 03:43
Ok I'll try that codeacademy course in the morning
I am just going through to see what it's about. I still have 2 weeks to start learning it so all of what I've gone through with fcc I'll go over them. I want to have a solid understanding of the basics then I can work my way up with the library
Andrew Kay
@andrewjkay
Sep 05 2017 03:46
That's definitely a good call. Redux is awesome, but it can be a pain at first especially if you're not pretty solid in the basics of React
Claudio Restifo
@Marmiz
Sep 05 2017 03:47
@RoniqueRicketts I've personally learnt it from the official documentation, both react and the popular libraries (Redux-React Router...)
I tried a course on React but never retained anything from it.

@RoniqueRicketts as a matter of fact I've watched a couple of lessons about Redux from here:
In my opinion still one of the best resource I have found:
https://egghead.io/courses/building-react-applications-with-idiomatic-redux

Mind the author is the guy who created Redux ;)

Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 03:49
Welll @andrewjkay @Marmiz thank you both for your input. I'll work on my basic understanding in react. It should be fun in a few weeks from Now
CamperBot
@camperbot
Sep 05 2017 03:49
roniquericketts sends brownie points to @andrewjkay and @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1037 | @marmiz |http://www.freecodecamp.com/marmiz
:cookie: 297 | @andrewjkay |http://www.freecodecamp.com/andrewjkay
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 03:51
Wanna see how quickly I can get react so I can move on to the big and mighty nodejs.
Claudio Restifo
@Marmiz
Sep 05 2017 03:54

@RoniqueRicketts How confortable are you with JS?
React is easy to get on if you are already confident with JS, otherwise it can feel a bit "clunky".

If you feel lost I suggest you to refresh a bit about JS ES6 syntax :)

Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 03:57
Well I'd say I can do a thing or 2 with js if I understand es6 to an extent
Actually I started the beta.freecodecamp react class Saturday and I'm done with the react section it was a good introduction but I know fcc jus wet our toes with these languages, libraries and frameworks. I want to jump in after a good basic lesson on react
Long Nguyen
@longnt80
Sep 05 2017 04:42
@RoniqueRicketts how about doing the official React tutorial: https://facebook.github.io/react/tutorial/tutorial.html?
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 04:44
@longnt80 I am checking it out right now and I like it already it's not hard. I like it :smile:
Luis
@zdrifted
Sep 05 2017 08:09
What does it mean to post load images? Is that aka lazy loading?
Long Nguyen
@longnt80
Sep 05 2017 08:31
@Rushh I think it's different
LydaTech
@lydatech
Sep 05 2017 08:36
@Rushh It means to start loading after your page content is loaded or only load when the images are needed like when you scroll down a page
@Rushh its a way to get your content to display without the heavy loading of images first
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 08:50
hey guys need a littlle help forgetting the basics of math
imagine You wanna do 50/0.18 it will be equal = 9
but Imagine the result I wanna is the other part the 41 how can I proceed?
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 08:55
I can make 1-0.18 and the multiply the number by that I guess
alpox
@alpox
Sep 05 2017 08:58
@tiagocorreiaalmeida 50-(50/0.18)
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 08:58
yeah
:D
alpox
@alpox
Sep 05 2017 08:58
Or what you said
Works both :D
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 08:59
was using private page closed the kata dont know if is there a way of pick it again lol
alpox
@alpox
Sep 05 2017 09:02
@tiagocorreiaalmeida hmm there should be ^^ but i guess the code you wrote there would be lost
I usually write it in another editor
Tiago Correia
@tiagocorreiaalmeida
Sep 05 2017 09:02
yeah it was solved just forgot to run it np xd
found it .D
Ayush Bahuguna
@relentless-coder
Sep 05 2017 09:37
can anyone help me explain this piece of code
Array.from(Array(10).keys())
this creates an array from 0-9
how?
Markus Kiili
@Masd925
Sep 05 2017 09:43
@relentless-coder Array(10) makes an array with 10 holes, that is no elements and lenght of 10. ES6 .keys() makes an array iterator object from it. Array.from there makes an array from the iterator. Seems to be working. Not sure how. Using arrays with holes tends to make people wonder.
So the code is evil :imp:
Claudio Restifo
@Marmiz
Sep 05 2017 09:48
Anyone here familiar with testing with Jest? <3
alpox
@alpox
Sep 05 2017 10:08
@Marmiz A bit
Claudio Restifo
@Marmiz
Sep 05 2017 10:12

@alpox kk. Let's hope you can help me :)
I have written a function inside a reducer. Something like:

// reducer.js
case INITIALIZE_PAGE: {
      localStorage.clear();  // <--- I have written this function here
      const newstate = initialState;
      return newstate;
    }

But then in the test for this action I got a localStorage is not defined

// reducr.test.js
  it('should handle initializeLoginPage correctly', () => {
    const expectedResult = state;
    expect(logInPageReducer(state, initializeLoginPage())).toEqual(expectedResult);
  });

Foe what I can tell is that Jest has no idea of what that localStorage is since I have not declared it anywhere in the test.
But how to proceed?
Any feedback?

I should probably move out the function since I fear, despite not being wrong, is kind of an anti-pattern since Redux only care about data and not computation
alpox
@alpox
Sep 05 2017 10:28
@Marmiz Yea it doesn't know what it is. You would often use a mock for testing such things actually and inject the mock to the function
Claudio Restifo
@Marmiz
Sep 05 2017 10:32

@alpox wow great idea! Didn't thought about that.
But then how to run the mock inside Jest? I have never done it.

Thanks heaps :sparkles:

CamperBot
@camperbot
Sep 05 2017 10:32
marmiz sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1325 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Sep 05 2017 10:36
@Marmiz Well it should be using this mock instance when just assigning it to global.localStorage as shown in the stackoverflow answer
Claudio Restifo
@Marmiz
Sep 05 2017 10:37
so just adding (or importing it as a module) to the test file should do the trick?
trying right now
Yep apparently adding one of the solution provided did the trick
Thanks again :)
alpox
@alpox
Sep 05 2017 10:52
@Marmiz No problem :-)
Claudio Restifo
@Marmiz
Sep 05 2017 10:53

@alpox that makes it but still I should refactor it since

I should probably move out the function since I fear, despite not being wrong, is kind of an anti-pattern since Redux only care about data and not computation

alpox
@alpox
Sep 05 2017 11:00
@Marmiz Yes that would probably be better :-) I often use something like redux-thunk for such things
Side effects shouldn't happen in reducers
Abhinav Mishra
@abhinav-m
Sep 05 2017 11:48
can anyone help me figure out this weird bug
currently working on my d3 scatter plot graph
when i mouse over a particular dot in my graph , two things happen : a transition occurs on the circle itself, increasing its width,
and i have bound a mouseover event to it to display the tooltip
however, if you notice here if i go from one point to another (vertically) sometimes the tooltip and transition stops working
it works after coming back down
oh damn.. i figured it out.. nvm
Abhinav Mishra
@abhinav-m
Sep 05 2017 11:54
the previous tooltip blocks the next event.
@alpox :D
@alpox thats a nice read, ty
CamperBot
@camperbot
Sep 05 2017 11:54
abhinav-thinktank sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1326 | @alpox |http://www.freecodecamp.com/alpox
Nicolas Ramirez
@kamatheuska
Sep 05 2017 12:23

hello there! I have written something similar to the following

    this.showInfo = function() {
      var t = "";
      var temp_family = query.t_family.toString();
      var temp_category = query.t_category;
      var temp_subcategory =query.t_subcategory;
      $.getJSON("../javascript/stock.json", function(json) {

        console.log("Good luck! JSON: ", json[temp_family], query.t_family.toString());

      });
    }

where query is an (dinamic??) object. The issue is that when I log in the console the result from json[temp_family], logs undefined. But when I log query.t_family.toString() or simply json[{some_random_property}] (with a string of a property on the JSON file) it does log what I would expect...what is my error here?

Abhinav Mishra
@abhinav-m
Sep 05 2017 12:24
does the json object have temp_family property?
Nicolas Ramirez
@kamatheuska
Sep 05 2017 12:26
no,
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:26
i mean the value inside temp_family which you are assigning
Nicolas Ramirez
@kamatheuska
Sep 05 2017 12:26
but I though it would refer to the above variable
yes it does
whe I log query.t_family.toString it comes the property name that I want
Markus Kiili
@Masd925
Sep 05 2017 12:27
@kamatheuska Could you log and paste here contents of those variables that you use and also the object json.
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:28
what does the variable temp_family contain, and the json, can you log those too
This message was deleted
Nicolas Ramirez
@kamatheuska
Sep 05 2017 12:30
mmm....it is rather a large file...I linked the object query to a method in a constructor which pulls data from an html button when clicked
man it is confusing haha
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:30
nvm that, log temp_file and your json recieved inside your getJSON method
Nicolas Ramirez
@kamatheuska
Sep 05 2017 12:30
in any case, I am trying to reproduce the problem without having ti upload all online
okey :)
Margaret Greaney
@greaneym
Sep 05 2017 12:31
hi there, I am kind of confused about what is the best way to incorporate sass with reactjs. I've made my first react markdown challenge but it doesn't have sass yet.
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:31
are you confused as how to install it?
or how to use it part
Margaret Greaney
@greaneym
Sep 05 2017 12:33
I found a blog post by ben smithett that says to use it with webpack configuration. I'm using create-react-app to learn the env and it uses webpack. I just want to know if I am heading in the right direction with this approach. What is the way to use sass with reactjs? Thanks
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:33
youre heading in the correct direction
i used this to configure sass
when i used create-react-app
Adding a CSS Preprocessor (Sass, Less etc.) This is the section you want to look into
Margaret Greaney
@greaneym
Sep 05 2017 12:35
Also, I've learned how to use node-sass to convert .scss files to .css. Anyone can suggest a method to use sass with reactjs please?
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:35
the above link has everything.
Margaret Greaney
@greaneym
Sep 05 2017 12:35
@abhinav-thinktank , thank you I will read about this
CamperBot
@camperbot
Sep 05 2017 12:35
:cookie: 547 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
greaneym sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:36
you basically add a watch script to your package.json file, and sass will convert your .scss .sass files for you
Margaret Greaney
@greaneym
Sep 05 2017 12:37
@abhinav-thinktank one more question, when you use this method how do you access the styles, with className= or style={}? I can't find any good simple examples of use
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:40
oh, i use className =
haven't found a good usecase for inline styles (yet)
Margaret Greaney
@greaneym
Sep 05 2017 12:43
@abhinav-thinktank , thanks for your help
CamperBot
@camperbot
Sep 05 2017 12:43
greaneym sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:warning: greaneym already gave abhinav-thinktank points
Abhinav Mishra
@abhinav-m
Sep 05 2017 12:46
@greaneym :+1:
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 12:52
I went to a business meeting last week and I was asked what language can I code in and I said Javascript and a litter nodejs then everyone started laughing. Idk what the joke was about. Then the lead developer said if I can't code in php I shouldn't call myself a developer and I won't cut it as a developer. Do you guys this php developers feels threatened by nodejs/JavaScript developers? I am asking because it's not the first I got a reaction like that from a php/java developer.
Blauelf
@Blauelf
Sep 05 2017 13:05

PHP just has a long history, and people have learnt how to deal with flaws in the language, while JavaScript on server-side is relatively new (and has its own, different flaws).

I don't think PHP or Java are a must for server-side development, but most projects use those, and I wouldn't want to mix them. Also, concurrency might work differently for the various runtime environments.

Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:14
@RoniqueRicketts those devs are close minded
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:18
@jenkynolasco11 I belive so.. @Blauelf I am forced to learn php for my internship. The same person belive I can learn what is needed in 2 weeks. I am surely not comfortable with that notion because it's highly impossible to be comfortable with the language to build up a backend.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:19
PHP is easy to learn
Blauelf
@Blauelf
Sep 05 2017 13:19
For an existing project built on PHP or Java, I would not want to have somebody write code in NodeJS. For new projects (or those loosely coupled to the PHP/Java part), if it meets the specification, why not.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:19
The only flaw is that it has a lot of functions you have to learn xD
in my opinion
I mean, not that you're going to stuck the names in your head. You can always google them, but gee xD
str2int, int2str <--- I lol'd
@RoniqueRicketts don't let that to get you down. You will be able to do it in no time if you already have experience in any programming language.
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:21
@jenkynolasco11 I try not to memorize stuff. I just want to understand how things works the use the documentation to help me put together an application :) idk if this ifs a good thing or a bad thing.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:21
You're doing good lol
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:21
I just know some js and very little nodejs.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:22
Enough to get started lol
I went to a job technical interview where I was supposed to code in PHP
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:23
@jenkynolasco11 yes ifs can start a nodejs server and serve a static webpage. I can instsl, packages that's it. I am still new to all this.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:23
I never knew how to code in PHP and I had to learn in less than 1 week
That time was enough to finish the problem they got me to do
Create a shopping cart
And I was not familiar with PHP
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:24
Well I am in that predicament right now. I went to php.net but the team lead say I can't learn fro there I'd be confused he said I can't learn php that way like how I learn js
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:24
Yeah, don't learn in PHP.net
Blauelf
@Blauelf
Sep 05 2017 13:26
@jenkynolasco11 I have seen PHP code written like that, probably by a complete newbie. In the 15 years of that code being live, there have been several additions, but nobody even tried to fix the obvious SQL injection. The code was a mess.
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:26
Is w3schools.com updated for php lessons?
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:27
w3schools gives you a very basic introduction to PHP
Surely after finishing their tutorial, you should go and look for another advanced one
@Blauelf I've seen horribly coded programs in PHP throughout the years, dude xD...
I had a job where I was supposed to work in another language
But the integration with the CRUD part was entirely made in PHP
Cuz "easier to work with the DB"
The guys repeated the code and changed just a couple of lines
I'm talking about "senior" programmers that were working in the for more than 5 years
bilaal-s
@bilaal-s
Sep 05 2017 13:29
guys really quick question, if we dont pass a parameter to getResponseHeader, does it return null? e.g. var myHeader = XMLHttpRequest.getResponseHeader();
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:30
I read a little sql but for for the likes of me idk how to link it to the littlw frontend knowledge I have.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:31
@bilaal-s if you don't specify what property of the header you want to get, then yeah (I think)
bilaal-s
@bilaal-s
Sep 05 2017 13:31
@jenkynolasco11 thanks
CamperBot
@camperbot
Sep 05 2017 13:31
bilaal-s sends brownie points to @jenkynolasco11 :sparkles: :thumbsup: :sparkles:
:star2: 1249 | @jenkynolasco11 |http://www.freecodecamp.com/jenkynolasco11
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:31
@RoniqueRicketts just do the tutorial and you'll be fine. That's like the very first thing (after functions, variables and other stuff) that you are taught
Blauelf
@Blauelf
Sep 05 2017 13:32
@jenkynolasco11 Somebody even wrote the right SQL injection for that code in a comment, it was ' OR 1=1;-- (most basic example!) and would log you in into the first account in the database.
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:33
For a total newbie, where do you suggest I go to get a basic up to date php lesson
@Blauelf @jenkynolasco11 thanks for your help so far.
CamperBot
@camperbot
Sep 05 2017 13:33
roniquericketts sends brownie points to @blauelf and @jenkynolasco11 :sparkles: :thumbsup: :sparkles:
:star2: 1250 | @jenkynolasco11 |http://www.freecodecamp.com/jenkynolasco11
:star2: 4590 | @blauelf |http://www.freecodecamp.com/blauelf
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:35
I wasn't even ready to learn php as yet as I am just learning reactjs. Damm, I hope php don't confuse away the little reactjs I learnt.
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:36
@RoniqueRicketts you can start with w3schools if you want
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:36
i created my first hello Ronique with reactjs without looking back on any example. :) feeling proud
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 13:36
Then move on to an advanced one
Lol
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 13:39
Ok I'll work on it for 3 week and see how it goes. I wasn't even looking for a job as yet but a job found me, now I have to learn n php and I as nt ready... damn but at least I'll have working experience heheh :trollface:
Bryan Reese
@breese8009
Sep 05 2017 14:25

TUESDAY

@jenkynolasco11 where the h* u been
Stephen James
@sjames1958gm
Sep 05 2017 14:43
@breese8009 Feels like a monday
Ogundele Olumide
@Lumexralph
Sep 05 2017 14:58
@sjames1958gm same here
Kelechi Chinaka
@ke1echi
Sep 05 2017 14:59
:wave: guys
hws it been @Lumexralph
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:01
@kelechy brotherly, it's been great, you?
@kelechy how your side?
horo
@wolfHoro
Sep 05 2017 15:02
Why I can not match the regular expression to all - and _? restr='0_0 (: /-\ :) 0-0' restr=restr.replace(/\W+\s+/g);
Kelechi Chinaka
@ke1echi
Sep 05 2017 15:02
good, school resumes next week :smile:
so the code time drops again :smile: @Lumexralph
Stephen James
@sjames1958gm
Sep 05 2017 15:04
@wolfHoro \w is letters, numbers and _ so \W will not match _
@wolfHoro \W includes spaces, so you don't need \s
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:04
@kelechy let's see at work though
@sjames1958gm howdy?
Stephen James
@sjames1958gm
Sep 05 2017 15:05
@Lumexralph :wave: Premier league back
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:05
@sjames1958gm what's the best way to authenticate and authorize your web app?
@sjames1958gm yep yep.... Rashford came good for England :smile:
@sjames1958gm i have sessions, tokens
dyon3334
@dyon3334
Sep 05 2017 15:08
can someone explain me the radix parameter in parseInt(s,radix) ?
horo
@wolfHoro
Sep 05 2017 15:09
@sjames1958gm Thanks,I removed the /s, but there was an underscore that could not be removed. The result is 000_0
CamperBot
@camperbot
Sep 05 2017 15:09
wolfhoro sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8441 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Sep 05 2017 15:09
@dyon3334 radix is simply the base of the number it tries to interpret.
10 is decimal - "123" -> 123
2 is binary "101" -> 5
16 is hexadecimal "1f" -> 31
@wolfHoro You have to combind \W with underscore to remove it
/[\W_]/ or /\W|_/
@Lumexralph passportjs?
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:11
@dyon3334 radix is used to determine the number base system it'll be converted to
Stephen James
@sjames1958gm
Sep 05 2017 15:11
@Lumexralph Yes, the rest of the team was adequate.
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:11
@dyon3334 if no radix is provided it'll return the integer in base 10, but you can provide radix to return it in binary, hexadecimal etc...
horo
@wolfHoro
Sep 05 2017 15:12
@sjames1958gm That's great. It's right
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:12
@sjames1958gm Let's see if Man Utd will come out top again
dyon3334
@dyon3334
Sep 05 2017 15:12
thanks i still dont have my head totally wrapped it aroud it yet
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:13
@sjames1958gm yeah passportjs, yet to work with that though
Stephen James
@sjames1958gm
Sep 05 2017 15:13
@Lumexralph Liverpool / Man City looks to be a good game -
@Lumexralph I have only done some tutorials, so I am not real strong with it.
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:14
@sjames1958gm i won't watch, will just get YouTube highlights.... thinking Liverpool will come out top both horrible defending sides just attacking sense
dyon3334
@dyon3334
Sep 05 2017 15:14
@sjames1958gm @Lumexralph thanks but still i dont get it for 100 %
CamperBot
@camperbot
Sep 05 2017 15:14
dyon3334 sends brownie points to @sjames1958gm and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2054 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 8442 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:15

@Lumexralph I have only done some tutorials, so I am not real strong with it.

@sjames1958gm cool, we're growing to be honest, I'm really enjoying backside though React makes front side interesting too

Stephen James
@sjames1958gm
Sep 05 2017 15:15
@Lumexralph 5:30 AM here -
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:16
@dyon3334 why don't you try to play with it a bit with the example @sjames1958gm showed you?
@sjames1958gm are you going to watch it?
Stephen James
@sjames1958gm
Sep 05 2017 15:17
@Lumexralph You bet. I love the early morning soccer, with my coffee and no-one else up bothering me :)
dyon3334
@dyon3334
Sep 05 2017 15:17
@Lumexralph thanks but maybe a stupid question what does 10 has to do with a decimal i dont et the connection
CamperBot
@camperbot
Sep 05 2017 15:17
dyon3334 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave lumexralph points
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:20
@dyon3334 number bases 0 1 2 3 4 5 6 7 8 9
@dyon3334 base 2, binary 0 1
dyon3334
@dyon3334
Sep 05 2017 15:21
@Lumexralph okay ithink i understand now thanks im gonna lay with it now
CamperBot
@camperbot
Sep 05 2017 15:21
dyon3334 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave lumexralph points
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:22
@sjames1958gm the EPL matches starts from 1pm downwards here
Razvan Jackson
@RazvanJackson
Sep 05 2017 15:34
Hey guys!
What's the best template for node.js?
Jason Luboff
@JLuboff
Sep 05 2017 15:35
What do you mean by template?
Like template engine?
I like HBS (which is handlebars)
Razvan Jackson
@RazvanJackson
Sep 05 2017 15:36
@JLuboff Yap, but for a begginer like me idk if it's ok,
I saw that it doesn't have logical operators
you can check with if statement just if it's true or false right?
Jason Luboff
@JLuboff
Sep 05 2017 15:38
Mmm..I don't think it does have logical operators or at least I've never used them. But if it doesn't, you can always create your own helper function.
Yes it has iuf statements
Razvan Jackson
@RazvanJackson
Sep 05 2017 15:38
Can we talk in pm?
Jason Luboff
@JLuboff
Sep 05 2017 15:39
Sure
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:44
@RazvanJackson i think handle bar will be easy to grasp compared to engines like jade, like @JLuboff said handle bar will allow very few JS operations, I don't think it'll be too overwhelming once you get used to the syntax and remember they are compiled to html eventually
@JLuboff how're you?
Jason Luboff
@JLuboff
Sep 05 2017 15:45
@Lumexralph Good, had a decent three day weekend..you?
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:45
@JLuboff handlebar allows some JS operation, conditionals, loops, variable
@JLuboff yeah, same here.... had so much time to spend with the family, intentionally kept my laptop shut to utilize that moment before heading back to my location
@JLuboff how's the family? champ here yet to kick the world ?
Jason Luboff
@JLuboff
Sep 05 2017 15:48
@Lumexralph Ya I didn't use a computer all weekend heh. Nope, another two months to go until he is disrupting my sleep :joy:
Ogundele Olumide
@Lumexralph
Sep 05 2017 15:49
@JLuboff I'm waiting for him so far FCC allows me to be here :smile:
Jason Luboff
@JLuboff
Sep 05 2017 15:49
:D
Christopher McCormack
@cmccormack
Sep 05 2017 16:09
@Lumexralph @JLuboff :wave:
Jason Luboff
@JLuboff
Sep 05 2017 16:17
@cmccormack :wave:
Christopher McCormack
@cmccormack
Sep 05 2017 16:18
What's the haps?
Jason Luboff
@JLuboff
Sep 05 2017 16:19
Sad the weekends over :D You?
Christopher McCormack
@cmccormack
Sep 05 2017 16:21
Same. Had call first thing this morning and felt like my head was filled with cement after the long weekend haha
Jason Luboff
@JLuboff
Sep 05 2017 16:22
:joy:
I actually got straight to work today...unusual of me
But the AC isn't working in my part of the building so its pretty miserable
Christopher McCormack
@cmccormack
Sep 05 2017 16:23
Ouch... sick day?
Jason Luboff
@JLuboff
Sep 05 2017 16:23
Nah. I got a fan blowing on me at least
Christopher McCormack
@cmccormack
Sep 05 2017 16:23
Or maybe make up an off-site visit
Jason Luboff
@JLuboff
Sep 05 2017 16:23
Psh. Off site places don't have no AC or if they do it sucks
The heat was brutal this weekend, we had a week long heat wave that went through Sunday. Saturday/Sunday it was 90+F here which is not too common. Usually the hottest is maybe mid-80's
Christopher McCormack
@cmccormack
Sep 05 2017 16:26
That's one of the benefits and drawbacks of living somewhere with really nice summers - most places don't have AC :D
I went to Austria a few years ago and it was like that, I was there the hottest week of the year and people didn't even seem to know they could use fans to at least help cool down a little
Jason Luboff
@JLuboff
Sep 05 2017 16:27
Lol
Amsterdam was like that when we went. We were expecting 60's F weather and instead had I think 80
But I blame @forkerino for that one. ;)
Christopher McCormack
@cmccormack
Sep 05 2017 16:28
A floor unit is only a few hundred, you would think people would be willing to shell out the cash for a few months of uncomfortable heat
haha @forkerino always ruining a good time
Jason Luboff
@JLuboff
Sep 05 2017 16:29
Ya, luckily our apartment has central air. So wonderful on these few days of hot weather (and at night regardless)
Christopher McCormack
@cmccormack
Sep 05 2017 16:30
Agreed. I got spoiled living in Phx for so many years, everywhere has AC so when I moved to Flagstaff and discovered we didn't have it I panicked and bought three small units haha
Jason Luboff
@JLuboff
Sep 05 2017 16:31
oh man
Christopher McCormack
@cmccormack
Sep 05 2017 16:32
@JLuboff what project you working on currently? game trader?
Jason Luboff
@JLuboff
Sep 05 2017 16:33
@cmccormack Ya, haven't touched it since...Thursday? Need to finish getting my local authentication working. It technically works, but I don't think its storing the user in the session, or I need to handle it differently, not sure have to investigate. You?
Christopher McCormack
@cmccormack
Sep 05 2017 16:34
Been working on my webpack config, trying to make a template folder I can copy over for new projects, without using create-react-app. It's a lot more work than I expected
Jason Luboff
@JLuboff
Sep 05 2017 16:36
What exactly is the webpack config?
Christopher McCormack
@cmccormack
Sep 05 2017 16:40
Hah... all this time working on it and it's still a little abstract to me. My understanding is it preprocesses everything so you can control what goes into distribution. It has lots of plugins to handle various tasks like building your initial HTML page or handling images
I followed this guys tutorial, although I couldn't get everything working, probably because I'm also using react-bootstrap https://www.youtube.com/playlist?list=PLkEZWD8wbltnRp6nRR8kv97RbpcUdNawY
Jason Luboff
@JLuboff
Sep 05 2017 16:43
@cmccormack Looks like he has a video involving bootstrap?
Christopher McCormack
@cmccormack
Sep 05 2017 16:44
In the webpack playlist he does, you can use a bootstrap loader that lets you use custom scss if you like. I ended up using it but not sure if it provided much benefit
Jason Luboff
@JLuboff
Sep 05 2017 16:45
Ah
Eventually I'll get into all that react stuff
Christopher McCormack
@cmccormack
Sep 05 2017 16:46
Oh you didn't do the React stuff yet?
Jason Luboff
@JLuboff
Sep 05 2017 16:46
Nope
Went straight to backend after frontend
Christopher McCormack
@cmccormack
Sep 05 2017 16:47
I do recommend jumping into it next, React changes the way you setup your pages and now I can't see myself using the old ways again
Jason Luboff
@JLuboff
Sep 05 2017 16:47
My plan is to do so after I complete backend. At this point, I only have two projects left anyways
luccifer00
@luccifer00
Sep 05 2017 16:48
function uniteUnique(arr) {

  return arr;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
hi there, why when i return arr, i just recibe the first arr [1, 2, 3] i try to Access with arr[1] but i return a single number..... what i am missing here??
Jenky W. Nolasco
@jenkynolasco11
Sep 05 2017 16:49
what are you trying to do?
korzo
@korzo
Sep 05 2017 16:49
@luccifer00 You have to use arguments object
@luccifer00 to get rest of of the values passed to function https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
Christopher McCormack
@cmccormack
Sep 05 2017 16:50
@JLuboff even if you don't use React there are some cool things about Webpack you may like - the Hot Module Replacement plugin along with webpack-dev-server is awesome
Save a file > instant refresh in browser
luccifer00
@luccifer00
Sep 05 2017 16:52
@korzo thanks i will read it !
CamperBot
@camperbot
Sep 05 2017 16:52
luccifer00 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 452 | @korzo |http://www.freecodecamp.com/korzo
Jason Luboff
@JLuboff
Sep 05 2017 16:54
@cmccormack I had started the tutorial but didn't make it far. I will have to definitely spend some more time with it
Christopher McCormack
@cmccormack
Sep 05 2017 16:56
@JLuboff it makes me feel like a real developer, even if it is confusing as hell to get setup haha
Jason Luboff
@JLuboff
Sep 05 2017 16:56
hahaha
Ivanthadev
@ivanthemeh
Sep 05 2017 17:19
anyone in here able to help with react ?
luccifer00
@luccifer00
Sep 05 2017 17:21
@korzo i still no understanding.... i dont know if this function uniteUnique(arr, arr1, arr2, arr3) could be the begining of the solution or not.... but is the only thing i can do..... if there is an other way please tell me
korzo
@korzo
Sep 05 2017 17:21
@luccifer00 No
@luccifer00 because you don't know how many arguments function will have
luccifer00
@luccifer00
Sep 05 2017 17:22
@yes, you are right...
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]]
korzo
@korzo
Sep 05 2017 17:23
@luccifer00 All arguments are in arguments object
arguments[0] is arr, rest you can access as arguments[1], arguments[2] ....
luccifer00
@luccifer00
Sep 05 2017 17:24
but i test with arr[0] , arr[1] and i get a number.... also i tried arr.arguments[0]
korzo
@korzo
Sep 05 2017 17:24
@gogminsam return a+b[1];

@luccifer00 In this example

function uniteUnique(arr) {

  return arr;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

arr = [1, 3, 2]
arguments[1] = [5, 2, 1, 4]
arguments[2] = [2, 1]

@luccifer00
arguments[0] = arr = [1, 3, 2]
Grigor Minasyan
@gogminsam
Sep 05 2017 17:28
@korzo thanks, that was fast!
CamperBot
@camperbot
Sep 05 2017 17:28
gogminsam sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @korzo |http://www.freecodecamp.com/korzo
luccifer00
@luccifer00
Sep 05 2017 17:35
ok!! i understand everything!, i did a test check and i wrote wrong arguments that was i didnt understood nothing! @korzo thanks
CamperBot
@camperbot
Sep 05 2017 17:35
luccifer00 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: luccifer00 already gave korzo points
Pethaf
@Pethaf
Sep 05 2017 18:26
Time for sleep.
Stephen James
@sjames1958gm
Sep 05 2017 18:47
@Pethaf :sleepy:
Jason Luboff
@JLuboff
Sep 05 2017 18:48
:zzz:
Brian
@BrianCodes33
Sep 05 2017 19:10
does anyone know how to write your own TDD tests in codewars?
alpox
@alpox
Sep 05 2017 19:14
@BrianCodes33 you can just write them in the test panel
Brian
@BrianCodes33
Sep 05 2017 19:16
right but i don’t know how lol
Luis
@zdrifted
Sep 05 2017 19:27
Thanks @longnt80 @lydatech
CamperBot
@camperbot
Sep 05 2017 19:27
rushh sends brownie points to @longnt80 and @lydatech :sparkles: :thumbsup: :sparkles:
:cookie: 548 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 2407 | @lydatech |http://www.freecodecamp.com/lydatech
Margaret Greaney
@greaneym
Sep 05 2017 19:32
Hi, I am not able to login to FCC with either login method right now. It says there is a gateway problem. I'll try back later.
Christopher McCormack
@cmccormack
Sep 05 2017 19:32
@greaneym yeah I think they're having some issues right now
Margaret Greaney
@greaneym
Sep 05 2017 19:33
@cmccormack , thanks.
CamperBot
@camperbot
Sep 05 2017 19:33
greaneym sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1188 | @cmccormack |http://www.freecodecamp.com/cmccormack
Jake
@JakeDVirus
Sep 05 2017 19:39

i found no references or documentation regarding the text attribute of <option> element as shown in the code below (by pluralsight)

    $("nav a").each(function(){
        var $this = $(this);
        $("<option/>", {
            "value" : $this.attr("href"),
            "text" : $this.text()    //   <------- This "text" (not .text())
         }).appendTo("nav select");
    });

Can anyone please let me know what that is about??

Jason Luboff
@JLuboff
Sep 05 2017 19:42
@NeelDVirus It's just getting the text from that element: https://api.jquery.com/text/
Jake
@JakeDVirus
Sep 05 2017 19:42
@JLuboff no no i am talking about "text", not .text()
Jason Luboff
@JLuboff
Sep 05 2017 19:44
@NeelDVirus Ok.. so you're asking about the object then?
Jake
@JakeDVirus
Sep 05 2017 19:48
@JLuboff Yeah the key "text" of the object.
literally that statement would be equivalent to like this i guess
<option value=attr('href') text=this.text()> </option>
But i never saw the text attribute in option element
Jason Luboff
@JLuboff
Sep 05 2017 19:50
Hmmm..ya I've actually never seen that setup where an element is being selected and within the object selector there's an object
Jake
@JakeDVirus
Sep 05 2017 19:52
@JLuboff yeah and i also discovered that lately. you can find the information about it here http://api.jquery.com/jquery/#jQuery-html-attributes
Stephen James
@sjames1958gm
Sep 05 2017 19:53
@NeelDVirus No, what is happening is:
var $option = $("<option/>")
$option.value($this.attr("href"))
$option.text($this.text())
$option.appendTo("nav select")
I think :)
Jake
@JakeDVirus
Sep 05 2017 19:56
@sjames1958gm yeah that is equivalent too. But then also i couldn't find any information about element.text ... or may be i am overlooking sumthing.
do you know about it?
Christopher McCormack
@cmccormack
Sep 05 2017 19:56
Yeah that looks right, text is a property of the option element: <option>text</option>.
@NeelDVirus when in doubt, look in the developer tools at the element's properties
Stephen James
@sjames1958gm
Sep 05 2017 19:57
@NeelDVirus element.text is how you set the text content of an element.
Christopher McCormack
@cmccormack
Sep 05 2017 19:57
I believe when jquery uses .text() it's actually referencing textContent
but that may update .text as well
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 19:58
Jake
@JakeDVirus
Sep 05 2017 19:58
@cmccormack yeah i saw developer tool and i found <option value="">text</option>.
But i couldn't find any documentation regarding .text
Jason Luboff
@JLuboff
Sep 05 2017 19:58
.text() will get the text of the element. .text('some text') will set the text
Jake
@JakeDVirus
Sep 05 2017 19:59
@RoniqueRicketts nice to see you here man. Btw the link you provide is about element.textContent, not element.text
Ronique Ricketts
@RoniqueRicketts
Sep 05 2017 20:00
@NeelDVirus I presume its the same .text jquery use is the same as element.textContent which is the text a tag/element has.
Jake
@JakeDVirus
Sep 05 2017 20:00
@JLuboff i am not talking about .text(), i am refering too "text" in the statement
"text" = "$this.text()"
Jason Luboff
@JLuboff
Sep 05 2017 20:01
@NeelDVirus I know, I was just stating based on what @cmccormack was saying
Jake
@JakeDVirus
Sep 05 2017 20:03
@JLuboff @cmccormack @sjames1958gm @RoniqueRicketts sorry guys i had some misunderstanding here. things making sense to me now. Thanks
CamperBot
@camperbot
Sep 05 2017 20:03
neeldvirus sends brownie points to @jluboff and @cmccormack and @sjames1958gm and @roniquericketts :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Sep 05 2017 20:03
@JLuboff understood, but what I meant were the properties of the element - not sure if setting text using jQuery's .text('text') will update multiple properties like element.text, element.textContent, element.innerText, element.outerText, etc...
CamperBot
@camperbot
Sep 05 2017 20:03
:star2: 2184 | @jluboff |http://www.freecodecamp.com/jluboff
:cookie: 385 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
:star2: 1190 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 8444 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jason Luboff
@JLuboff
Sep 05 2017 20:03
@cmccormack Ah
Christopher McCormack
@cmccormack
Sep 05 2017 20:03
what a fun tangent :p
Mark Kubik
@KUBIX90
Sep 05 2017 20:04
$(document).ready(function(){

    $("#get-quote").on("click", function(){

        var API_URL = "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";

        //Pull quote from API
        $.ajax({
            url: API_URL,    
            success: function(post){
                $("#quote-title").text(post.title);
                $("#quote-content").html(post.content);
                    if (typeof post.custom_meta !== 'undefined' && typeof post.custom_meta.Source !== 'undefined') {
                        $('#quote-source').html('Source:' + post.custom_meta.Source);
                } else {
                  $('#quote-source').text('');
                }
            },
            cache:false
        })
    });
});

Doing the random quote generator, anyone know why I'm getting the error that ajax is not a function? I've run it through jshint and I've had no probles so no sure what the issue is.

Thanks!

Christopher McCormack
@cmccormack
Sep 05 2017 20:04
I would imagine most non-self-closing elements would have a text property
Jason Luboff
@JLuboff
Sep 05 2017 20:05
@KUBIX90 Do you have jquery loaded?
Mark Kubik
@KUBIX90
Sep 05 2017 20:06
@JLuboff I've run a test and it says that it is loaded
Jason Luboff
@JLuboff
Sep 05 2017 20:07
Do you have it in codepen?
Mark Kubik
@KUBIX90
Sep 05 2017 20:07
Yeah one sec
Jake
@JakeDVirus
Sep 05 2017 20:10

@cmccormack @RoniqueRicketts @JLuboff In case you guys would be interested in a substantial information, this is what i found regarding the text and indeed text was the reference to .text()

If the second argument is passed, the HTML string in the first argument must represent a simple element with no attributes. As of jQuery 1.4, any event type can be passed in, and the following jQuery methods can be called: val, css, html, text, data, width, height, or offset.

I'm wondering if its because I have the bootstrap jQuery file loaded but not the full version?
The standalone I mean
Christopher McCormack
@cmccormack
Sep 05 2017 20:14

@KUBIX90 I dno't see the same error you do:

VM41:1 Mixed Content: The page at '[codepen]' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&_=1504642365284'. This request has been blocked; the content must be served over HTTPS.

You need to use an https api

Stephen James
@sjames1958gm
Sep 05 2017 20:14
@KUBIX90 Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. the slim library doesn't have ajax
Mark Kubik
@KUBIX90
Sep 05 2017 20:15
@cmccormack @sjames1958gm hmmmm I think both of your suggestions are issues, I'll have a play around with it and see if the changes work, thanks
CamperBot
@camperbot
Sep 05 2017 20:15
kubix90 sends brownie points to @cmccormack and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8445 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1191 | @cmccormack |http://www.freecodecamp.com/cmccormack
Stephen James
@sjames1958gm
Sep 05 2017 20:16
@KUBIX90 https://blog.jquery.com/2016/09/22/jquery-3-1-1-released/
This page contains the text from above
Mark Kubik
@KUBIX90
Sep 05 2017 20:17
cheers!
Diego Mayer
@Chrono79
Sep 05 2017 21:08
:wave:
Jason Luboff
@JLuboff
Sep 05 2017 21:08
:wave:
Diego Mayer
@Chrono79
Sep 05 2017 21:08
How are you doing?
Jason Luboff
@JLuboff
Sep 05 2017 21:09
Doing alright...you?
Christopher McCormack
@cmccormack
Sep 05 2017 21:10
@Chrono79 :wave:
Diego Mayer
@Chrono79
Sep 05 2017 21:11
Tired of working, a lot of years until retirement tho
Christopher McCormack
@cmccormack
Sep 05 2017 21:11
Sounds like you need a more enjoyable job :)
Jason Luboff
@JLuboff
Sep 05 2017 21:11
:joy: Only another....40 years to go? (for me)
Diego Mayer
@Chrono79
Sep 05 2017 21:12
@cmccormack I'm seriously thinking that may be the case
Corey Smith
@CoreyCache
Sep 05 2017 21:12
anyone here familiar with getJSON?
Jason Luboff
@JLuboff
Sep 05 2017 21:13
@CoreyCache Yes, probably all three of us here right now
Christopher McCormack
@cmccormack
Sep 05 2017 21:13
@CoreyCache yeah @JLuboff is
:p
Corey Smith
@CoreyCache
Sep 05 2017 21:13
Im working on the random quote machine and have a quick question about that method
Jason Luboff
@JLuboff
Sep 05 2017 21:13
Lets hear it
Diego Mayer
@Chrono79
Sep 05 2017 21:13
or read it
Jason Luboff
@JLuboff
Sep 05 2017 21:13
:eyes: :ear:
Corey Smith
@CoreyCache
Sep 05 2017 21:14
let's say i use getJSON and declare a variable inside that JSON method to hold my json object, can i access that outside of the getJSON function?
Christopher McCormack
@cmccormack
Sep 05 2017 21:14
nope
Diego Mayer
@Chrono79
Sep 05 2017 21:14
short answer is no
Jason Luboff
@JLuboff
Sep 05 2017 21:14
Long answer...maybe
Christopher McCormack
@cmccormack
Sep 05 2017 21:14
nope, not if declared in that function
Corey Smith
@CoreyCache
Sep 05 2017 21:15
that's what i thought, wanted to be sure. so i have to do everything inside that function?
Jason Luboff
@JLuboff
Sep 05 2017 21:15
@cmccormack Ah...true
Corey Smith
@CoreyCache
Sep 05 2017 21:15
how would I use the JSON data?
Christopher McCormack
@cmccormack
Sep 05 2017 21:15
@CoreyCache you can store data in global variables as well, just be aware you won't be able to access that data until the ajax call is completed
Diego Mayer
@Chrono79
Sep 05 2017 21:15
nesting
Christopher McCormack
@cmccormack
Sep 05 2017 21:15
That's fine for something like a click event, but not for something that is supposed to happen right after
Jason Luboff
@JLuboff
Sep 05 2017 21:16
Nesting...leads to callbacks...leads to callback hell...
Corey Smith
@CoreyCache
Sep 05 2017 21:16
this was my first approach to the project, figured i can generate a random number to render something like data[0].quote
or data[i].quote
Diego Mayer
@Chrono79
Sep 05 2017 21:16
or using promises
Christopher McCormack
@cmccormack
Sep 05 2017 21:16
Promises are nice and easy
Jason Luboff
@JLuboff
Sep 05 2017 21:16
:heart: promises
Christopher McCormack
@cmccormack
Sep 05 2017 21:16
jQuery ajax calls return an object that implements the promise interface, so it's built right in
piteto
@piteto
Sep 05 2017 21:16
var myData = () => $.getJSON("https://wind-bow.glitch.me/twitch-api/channels/freecodecamp");

myData().then(function(data) {
  console.log(data);
});
that isn't really outside though is it?
Christopher McCormack
@cmccormack
Sep 05 2017 21:17
@piteto no need to make that a function
@piteto nope it's still in the same scope
well, sort of
piteto
@piteto
Sep 05 2017 21:17
Yeah, it seems like just an extension of the callback if that makes sense
Corey Smith
@CoreyCache
Sep 05 2017 21:18
so what would myData be in ur case? @piteto
Christopher McCormack
@cmccormack
Sep 05 2017 21:18
I believe that is exactly what it is
Corey Smith
@CoreyCache
Sep 05 2017 21:18
it'd be the json object? with keys and values?
Jason Luboff
@JLuboff
Sep 05 2017 21:18
He is using a promise
piteto
@piteto
Sep 05 2017 21:18
it's a promise object
Christopher McCormack
@cmccormack
Sep 05 2017 21:18
and what do you think promises are? :)
Diego Mayer
@Chrono79
Sep 05 2017 21:19
promises are made to break them (depending on who you ask about them) ;)
Christopher McCormack
@cmccormack
Sep 05 2017 21:19
@CoreyCache no the return from getJson is a jqXHR object
piteto
@piteto
Sep 05 2017 21:20
I just figure it's the same as fetch() but not promise/a+ compliant. Not sure to be honest
Christopher McCormack
@cmccormack
Sep 05 2017 21:20
@CoreyCache notice he calls .then on the response, .then is a method of jqXHR
fetch is a little bit more complicated in my opinion, as you have to return something in the .then method if you want to use another one
piteto
@piteto
Sep 05 2017 21:23
I tried using $.when with my twitch app over the weekend and it turned out to be way more complicated than promise.all
Christopher McCormack
@cmccormack
Sep 05 2017 21:23
although now that I think about it I never really used .then with jquery more than once...
Corey Smith
@CoreyCache
Sep 05 2017 21:24
ok thanks for the input im going to keep digging
i haven't learned the things u guys are mentioning yet so i'm reading on them now
piteto
@piteto
Sep 05 2017 21:24
Seems like what you want to do @CoreyCache is to pass the data you get back from getJSON to another function
less than 29 chars seems damn short
Jason Luboff
@JLuboff
Sep 05 2017 21:30
@Chrono79 They cheated and aren't letting me use .reverse()!
Diego Mayer
@Chrono79
Sep 05 2017 21:30
yes, that's what makes it hard ;)
Diego Mayer
@Chrono79
Sep 05 2017 21:37
any idea?
Gustavo Azevedo
@gustavoaz7
Sep 05 2017 21:37
You actually only have 13characters to code your answer. Thats insane
I can only do that in python lol
Jason Luboff
@JLuboff
Sep 05 2017 21:37
I didn't even try hahaha
Diego Mayer
@Chrono79
Sep 05 2017 21:38
hahaha, hard as hell
using concat is not an option, because some elements are empty arrays too
Christopher McCormack
@cmccormack
Sep 05 2017 21:45
I got it in 68 characters, just got to whittle it down haha
Aizaz Shahid
@aizazshahid
Sep 05 2017 21:46
How are you all ?
@cmccormack : )
Christopher McCormack
@cmccormack
Sep 05 2017 21:47
now 47
@forwebtech hi!
Doing great, except when @Chrono79 sidetracks me
Gustavo Azevedo
@gustavoaz7
Sep 05 2017 21:47
In python you can reverse a string like this: str[::-1]
There must be an equivalent to that in JS
Diego Mayer
@Chrono79
Sep 05 2017 21:50
I must share my headaches
Christopher McCormack
@cmccormack
Sep 05 2017 21:50
@forwebtech how are you doing?
I used a.map((v,i)=>a[a.length-i-1]) but far too long
Aizaz Shahid
@aizazshahid
Sep 05 2017 21:51
@cmccormack all good !
Jan Shah
@JanShah
Sep 05 2017 21:56
@gustavoaz7 split reverse join
Gustavo Azevedo
@gustavoaz7
Sep 05 2017 21:56
You are not allowed to use reverse()
Aizaz Shahid
@aizazshahid
Sep 05 2017 21:58
found that one but it has 30 characters:
a.map((v,i)=>a[a.length-1-i]);
same as @cmccormack : )
Jan Shah
@JanShah
Sep 05 2017 22:02
@gustavoaz7 is that part of the rules of that exercise?
piteto
@piteto
Sep 05 2017 22:03
I got it to exactly 29 chars...
weirdReverse=a=>a.sort(()=>1)
need to cut one char off of that...
Christopher McCormack
@cmccormack
Sep 05 2017 22:04
@piteto that's it! nice job!
weirdReverse=a=>a.sort(v=>1)
no need for two parens
piteto
@piteto
Sep 05 2017 22:04
nice!!!
awesome
Aizaz Shahid
@aizazshahid
Sep 05 2017 22:07
@piteto :+1:
Gustavo Azevedo
@gustavoaz7
Sep 05 2017 22:08
Well done!
Christopher McCormack
@cmccormack
Sep 05 2017 22:08
@piteto thanks, here's a brownie for allowing me to go back to what I was doing haha
CamperBot
@camperbot
Sep 05 2017 22:08
cmccormack sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Sep 05 2017 22:08
oh no!
Jason Luboff
@JLuboff
Sep 05 2017 22:08
@cmccormack Sneaky using a non-needed parameter to reduce it by an additional character
piteto
@piteto
Sep 05 2017 22:08
lol
Christopher McCormack
@cmccormack
Sep 05 2017 22:08
@JLuboff that's why they call me the parameter man
I mean, that's what someone might call me...
Jason Luboff
@JLuboff
Sep 05 2017 22:09
@cmccormack "Chris wasn't always known as Chris. See, he has a past that not many are aware of. A past that doesn't define who he is, but instead, what he is. For he is, Parameter Man!"
Christopher McCormack
@cmccormack
Sep 05 2017 22:17
Unfortunately I was never able to make the cut athletically... https://www.youtube.com/watch?v=LsAiCs66l40
piteto
@piteto
Sep 05 2017 22:25
image.png
might as well make it a meme
Jason Luboff
@JLuboff
Sep 05 2017 22:26
ughh...that one hasn't ran its course yet?
Christopher McCormack
@cmccormack
Sep 05 2017 22:27
@piteto HAH
luccifer00
@luccifer00
Sep 05 2017 22:42

function convertHTML(str) {
  var simb= /["&","<",">","",'']/;
  var simb1= ["&","<",">","",''];
  var repl=["&amp;","&lt;","&gt;","&quot;",'&apos;'];
  var final; 
    for (var i = 0;i <str.length;i++){
    if(str.split("")[i].search(simb)>-1){
      str.split("")[i].replace(simb, repl[simb1.indexOf(str.split("")[i])]);
      final +=str.split[i];
    }
  }

return final;
}

convertHTML("Dolce & Gabbana");
probably i am far to get the challenge... i am getting null agains, i would like to know if i am doing crazy things...
Jason Luboff
@JLuboff
Sep 05 2017 22:45
@luccifer00 Isn't .search() a string method not an array method?
oh sorry
You're splitting then accessing an element at a time
Part of the problem is this: final +=str.split[i];
luccifer00
@luccifer00
Sep 05 2017 22:46
@JLuboff yes, u're right .serch()is a string method
Jason Luboff
@JLuboff
Sep 05 2017 22:46
You can't add to undefined
luccifer00
@luccifer00
Sep 05 2017 22:47
but i need to Split, becouse if i dont, i can not acces to the string[i]
probably i need to restart the whole code :worried:
Jason Luboff
@JLuboff
Sep 05 2017 22:48

You don't have to split. str[i] will give you the element at i. But again, look at this:

Part of the problem is this: final +=str.split[i];

You can't add to undefined
Jan Shah
@JanShah
Sep 05 2017 22:48
@luccifer00 you could try regex matching
luccifer00
@luccifer00
Sep 05 2017 22:49
@JanShah it is what i want to do....
Jan Shah
@JanShah
Sep 05 2017 22:49
regexr.com is a good resource
@luccifer00
luccifer00
@luccifer00
Sep 05 2017 22:50
but i use the regex as variable... var simb= /["&","<",">","",'']/;
Jan Shah
@JanShah
Sep 05 2017 22:51
@luccifer00 idk, doesn't look right to me. regex matches elements in a string, no need for looping or splitting
luccifer00
@luccifer00
Sep 05 2017 22:54
how can i créate the or operator with the regex??
Jan Shah
@JanShah
Sep 05 2017 22:54
str.match(/(\&)/)
try that
that only matches &, str.replace can replace any part of the string
Jason Luboff
@JLuboff
Sep 05 2017 22:55
@luccifer00 | is the regex OR operator
luccifer00
@luccifer00
Sep 05 2017 22:56
@JLuboff is the | just once? or twice?? ||??
Jason Luboff
@JLuboff
Sep 05 2017 22:56
single
Jan Shah
@JanShah
Sep 05 2017 22:57
@luccifer00 (\&|d) tap that into regexr, it is quite simple when you see live results
even I don't pretend to understand it, just look on there for a match :)
luccifer00
@luccifer00
Sep 05 2017 22:57
@JanShah at first i use /\W/but that regex include the spaces
Jan Shah
@JanShah
Sep 05 2017 22:58
that matches the word following the matching regex
luccifer00
@luccifer00
Sep 05 2017 23:01
@JanShah i did, but the \&|d returns only the first "d"
Jan Shah
@JanShah
Sep 05 2017 23:02
that's an example, it's not the solution. you can use /g to match all
luccifer00
@luccifer00
Sep 05 2017 23:07
i have to read more abour regex and how to set it... or revise the older frecodecamp challenges! anyways! thanks for the tool! seems to be usefull for me! ,
luccifer00
@luccifer00
Sep 05 2017 23:14
 var reg = /\&|\<|\>|\"|\'/g;
finnaly i did this variable, but i have an alert(yellow one) saind "unexpected escaped carácter "<" in regular expression"
also thanks for the match() tip
Uriel Guzmán
@Burinson
Sep 05 2017 23:26
Guys, why can't I send an alert when the input user is not found on my Twitch API Project?
function searchCode() {
        $("#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 + "?callback?", // 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.
                    } else if (twitch.hasOwnProperty("error")) {
                        console.log(twitch.hasOwnProperty("error"));
                        alert("error");
                    } // End of else statement.
                } // End of success function.
            }); // End of ajax call.
    }
Jason Luboff
@JLuboff
Sep 05 2017 23:27
@Burinson does the console.log work?
Uriel Guzmán
@Burinson
Sep 05 2017 23:27
Nope
@JLuboff
Jason Luboff
@JLuboff
Sep 05 2017 23:28
Therefore, I would venture to guess that this: (twitch.hasOwnProperty("error") is never true?
Uriel Guzmán
@Burinson
Sep 05 2017 23:28
It doesn't log anything, yes
Here's the link
Jason Luboff
@JLuboff
Sep 05 2017 23:31
@Burinson Looking at the returned structure of the twitch I don't see where there would ever be a property "error"
Randell Dawson
@RandellDawson
Sep 05 2017 23:32
@Burinson - try adding the following to which ever ajax call you want to display an error for. Put it as another property under "success":
error: function() { alert("error") }
I failed
drhotdogMD
@drhotdogMD
Sep 05 2017 23:33
ES6: Explore Problems with the var Keyword
what is the answer to this
Jason Luboff
@JLuboff
Sep 05 2017 23:34
@Burinson Ah...so you need to check inside the second ajax call with the twitchOffline parameter instead of twitch
Uriel Guzmán
@Burinson
Sep 05 2017 23:35
@rmdawson71 Thank you!
CamperBot
@camperbot
Sep 05 2017 23:35
burinson sends brownie points to @rmdawson71 :sparkles: :thumbsup: :sparkles:
api offline
Uriel Guzmán
@Burinson
Sep 05 2017 23:35
Such a simple solution to a problem I've been trying to fix since last night
@JLuboff thanks
CamperBot
@camperbot
Sep 05 2017 23:35
burinson sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Randell Dawson
@RandellDawson
Sep 05 2017 23:38
@drhotdogMD - What code have you tried?
drhotdogMD
@drhotdogMD
Sep 05 2017 23:39
@rmdawson71 i have tried a lot
i cant get it to not display comet instead
id have to put the part i want into a function i think
Randell Dawson
@RandellDawson
Sep 05 2017 23:40
@drhotdogMD - Show the last thing you tried.
drhotdogMD
@drhotdogMD
Sep 05 2017 23:41
@rmdawson71
"use strict";
let favorite = redNosedReindeer + " is Santa's favorite reindeer.";
var redNosedReindeer = "Rudolph";
var redNosedReindeer = "Comet";
Randell Dawson
@RandellDawson
Sep 05 2017 23:41
You should not be using var anywhere
drhotdogMD
@drhotdogMD
Sep 05 2017 23:41
i tried let on all instead of var and included the use strict
Randell Dawson
@RandellDawson
Sep 05 2017 23:41
@drhotdogMD - only let
drhotdogMD
@drhotdogMD
Sep 05 2017 23:42
and it wouldnt pass
from what i understand making them all let would all let them all be declared
is that sorta true?
Randell Dawson
@RandellDawson
Sep 05 2017 23:43
@drhotdogMD - Because you are using let, you have to declare redNosedReindeer first
The solution has two lines of code plus the "use strict"; at the top. Both lines begin with let
drhotdogMD
@drhotdogMD
Sep 05 2017 23:44
so i do have to move stuff around?
i wasnt aware i could move or remove anything
Randell Dawson
@RandellDawson
Sep 05 2017 23:44
@drhotdogMD - Yes, that is what they are trying to teach you in this challenge.

@drhotdogMD - The instructions say:

Fix the code so that it only uses the let keyword and makes the errors go away.

drhotdogMD
@drhotdogMD
Sep 05 2017 23:45
@rmdawson71 "use strict";
let favorite = redNosedReindeer + " is Santa's favorite reindeer.";
let redNosedReindeer = "Rudolph";
is this the answer they want?
Randell Dawson
@RandellDawson
Sep 05 2017 23:46
@drhotdogMD - You technically should move the redNosedReindeer declaration before the favorite declaration
drhotdogMD
@drhotdogMD
Sep 05 2017 23:46
yes
Randell Dawson
@RandellDawson
Sep 05 2017 23:47
So it would be:
"use strict";
let redNosedReindeer = "Rudolph";
let favorite = redNosedReindeer + " is Santa's favorite reindeer.";
drhotdogMD
@drhotdogMD
Sep 05 2017 23:48
@rmdawson71 yes because we dont want redNosedReindeer to be global
?
Randell Dawson
@RandellDawson
Sep 05 2017 23:51
@drhotdogMD - It has nothing to do with global variables. When using "let" and "use strict"; you will get a warning/error if you try to use redNosedReindeer in your code before declaring it.
See the following for an example:
https://repl.it/KjPY/0
The first console.log displays Rudolph, but the second console.log displays undefined, because it was declared after using it with let.
drhotdogMD
@drhotdogMD
Sep 05 2017 23:53
@rmdawson71 @rmdawson71 i see
thanks