These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Aug 2017
korzo
@korzo
Aug 02 2017 00:01
@Anthony-Armfield you have to remove special characters from string and also case doesn't matter
John Tendik
@JohnTendik
Aug 02 2017 00:02
also wouldnt it make sense to check string rather than array ?
Anthony Armfield
@Anthony-Armfield
Aug 02 2017 00:03

@JohnTendik I will check to see how to do that (I am still very new to Javascript).

@korzo there are no special characters, and all characters passed in as "inputString" are lowercase.

korzo
@korzo
Aug 02 2017 00:04
@Anthony-Armfield sorry, non alphanumeric, as palindrome("five|_/|four")
John Tendik
@JohnTendik
Aug 02 2017 00:05
@Anthony-Armfield youre doing a bunch of unnecessary things :D simply create a new variable let myVar = inputString.split("").reverse().join(""); then check if inputString == myVar D:
split the string by each letter, this creates an array. Then reverse the array, then join each array item back into a string
korzo
@korzo
Aug 02 2017 00:05
@Anthony-Armfield they are not lowercase , see palindrome("A man, a plan, a canal. Panama")
John Tendik
@JohnTendik
Aug 02 2017 00:06
ahh ok then you can do myString.toLowerCase() == myVar.toLowerCase() inside you if check :D
Roxroy
@roxroy
Aug 02 2017 00:06
@Anthony-Armfield , you missed just one step. You cannot compare an array like that. Your best bet to change the arrays to a string and then compare the string. Use the array join function, if (arr.join('') == revArr.join('')) {
Anthony Armfield
@Anthony-Armfield
Aug 02 2017 00:10
@JohnTendik Thanks! That worked as I needed it. Can you walk me through what the split('') and join('') are doing here?
@korzo Thanks. I didn't have a need to that complex of a string, but I will work with it to make sure it works that out as well.
@roxroy Thanks for the response. I changed the code to fit what @JohnTendik recommended and it seemed to be a much leaner function. I do appreciate the response, though.
CamperBot
@camperbot
Aug 02 2017 00:10
anthony-armfield sends brownie points to @johntendik and @korzo and @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1083 | @roxroy |http://www.freecodecamp.com/roxroy
:cookie: 813 | @johntendik |http://www.freecodecamp.com/johntendik
Stephen James
@sjames1958gm
Aug 02 2017 00:10
@sfarnsworthkum Your returns inside the for loop will skip out of the function without checking other keys.
You should probably recurse on obj[key] so as to shrink the task with each recursion
korzo
@korzo
Aug 02 2017 00:11
@Anthony-Armfield split('') turns string to array of characters
join('') turns array to string
Stephen James
@sjames1958gm
Aug 02 2017 00:11
@sfarnsworthkum Also, shouldn't you be checking the typeof obj[key] not key?
Anthony Armfield
@Anthony-Armfield
Aug 02 2017 00:13
@korzo so, I am turning the string into an array, reversing it, then making it a string again. Then checking to see if the two are the same? I think I got that. Thanks!
CamperBot
@camperbot
Aug 02 2017 00:13
anthony-armfield sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: anthony-armfield already gave korzo points
Dovydas Stirpeika
@Giveback007
Aug 02 2017 00:25
index.js:3 Uncaught ReferenceError: require is not defined
at index.js:3
(anonymous) @ index.js:3
when I am trying to import Jquery
anyone know what's up with that?
Anthony Armfield
@Anthony-Armfield
Aug 02 2017 00:26
@Giveback007 what is the code on line 3?
Dovydas Stirpeika
@Giveback007
Aug 02 2017 00:26
what are the steps to using the package after npm install
var _jquery = require('jquery');
@Anthony-Armfield
@sjames1958gm
Adam Faraj
@adamfaraj
Aug 02 2017 00:35
Hello
I need help with a problem I'm having
so i have this JSON file
"dealers": [
        {
            "data": {
                "companyID": 401929,
                "name": "Aqua Experts",
                "phone1": "1-888-234-5678",
                "email": "info@aquaexperts.com",
                "addressLine1": "1234 Some Street",
                "addressLine2": "",
                "city": "Charlotte",
                "state": "North Carolina",
                "country": "US",
                "zipcode": "28205",
                "weekHours": {
                    "mon": "7:00am - 7:00pm",
                    "tue": "7:00am - 7:00pm",
                    "wed": "7:00am - 7:00pm",
                    "thu": "7:00am - 7:00pm",
                    "fri": "7:00am - 7:00pm",
                    "sat": "7:00am - 3:00pm",
                    "sun": ""
                },
                "certifications": [
                    "Installation Pro",
                    "Residential Pro",
                    "Service Pro"
                ]
            }
        }, {
            "data": {
                "companyID": 401928,
                "name": "Premium Pools & Spas of Charlotte",
                "phone1": "1-888-888-8888",
                "email": "info@premiumpoolscharlotte.com",
                "addressLine1": "1234 Some Street",
                "addressLine2": "",
                "city": "Charlotte",
                "state": "North Carolina",
                "country": "US",
                "zipcode": "28205",
                "weekHours": {
                    "mon": "7:00am - 7:00pm",
                    "tue": "7:00am - 7:00pm",
                    "wed": "7:00am - 7:00pm",
                    "thu": "7:00am - 7:00pm",
                    "fri": "7:00am - 7:00pm",
                    "sat": "",
                    "sun": "On Call"
                },
                "certifications": [
                    "Installation Pro",
                    "Commercial Pro",
                    "Residential Pro",
                    "Service Pro"
                ]
            }
        }
Simon Cordova
@gbsimon87
Aug 02 2017 00:39
What about the JSON file @adamfaraj
Adam Faraj
@adamfaraj
Aug 02 2017 00:39
i want to put each data of the dealers into it's separate div
this is my js code
var xhttp = new XMLHttpRequest();
xhttp.onload = function() {
    if (this.readyState == 4 && this.status == 200) {
       var response = JSON.parse(xhttp.responseText);
      for (var i=0; i<response.dealers.length;i++) {
        var dealersName = response.dealers[i].data.name;
        var dealersEmail = response.dealers[i].data.email;
        var dealersPhoneNum = response.dealers[i].data.phone1;
        var dealersHours = response.dealers[i].data.weekHours;
        var certs = response.dealers[i].data.certifications;
        console.log(dealersName);
        console.log(dealersPhoneNum);
        console.log(dealersEmail);
        console.log(dealersHours);
        console.log(certs);

        //console.log(response.dealers[i].data.email);

      }


    }
};
xhttp.open("GET", "src/js/dealers.json", true);
xhttp.send();
i can get all the info of the dealers
but i don't know how to have each dealer have its own <div> in my html
so like
<div>Aqua experts, etc etc</div>
<div>Premium Pools, phone number, etc etc </div>
Stephen James
@sjames1958gm
Aug 02 2017 00:41
@adamfaraj In the loop use document.createElement("div");
then add other elements using appendChild, then at the end of the loop
append to some HTML element
Simon Cordova
@gbsimon87
Aug 02 2017 00:41
Easiest way I can think of is to create an element div then append the elements
of course @sjames1958gm would beat me to it lolol
Adam Faraj
@adamfaraj
Aug 02 2017 00:42
@sjames1958gm document.createElement("div").appendChild(respone.dealers[0].data.name);
This message was deleted
Stephen James
@sjames1958gm
Aug 02 2017 00:42
Here is some sample code - the children would be other elements, "p" or "span"
function addIntent(intent) {
  // Add launch intent
  let intentDiv = document.querySelector("#intents");
  let d = document.createElement("div");
  d.classList.add('intentDiv');
  let b = document.createElement("button");
  b.classList.add("btn", "btn-primary", "btn-sm");
  b.textContent = "send";
  b.id = intent + "btn";
  b.addEventListener('click', onClick);
  d.appendChild(b);

  let s = document.createElement("span");
  s.textContent = intent.toLowerCase() + ": ";
  s.classList.add('intentLabel');

  d.appendChild(s);
  intentDiv.appendChild(d);

  return d;
}
The intentDiv is the element in the HTML where I hook in these new elements
where d is a wrapping div and I create buttons and spans.
Adam Faraj
@adamfaraj
Aug 02 2017 00:45
so have a <div id="intentDiv"></div>
oh no
wait
you're creating all the DOM elements in the JS
gotcha
Stephen James
@sjames1958gm
Aug 02 2017 00:46
The loop creates one set of elements from each dealer and appends to an element in the HTML already
let div = document.createElement("div")
let span = document.createElement("span");
span.textContent(respone.dealers[0].data.name));
div.appendChild(span);
let intentDiv = document.querySelector("#intentDiv");
intentDiv.appendChild(div);
FlashHero
@FlashHero
Aug 02 2017 00:48
what is the difference between req.checkBody(), req.assert() and req.checkQuery()in express-validator
Adam Faraj
@adamfaraj
Aug 02 2017 00:54
@sjames1958gm oh man, it's not like that code. not putting anything in my DOM?
zealsham
@zealsham
Aug 02 2017 01:05
in my express app, the index page loads all the css and js files and google fonts . but other html files fails to do so
Peter Bae
@MirinaeMiREU
Aug 02 2017 01:12
Hi, I'm having some trouble with the exact change problem.
The page freezes up on me and I'm guessing it's the while loop that I put in there
The console didn't catch the infinity loops and now I'm stuck, because the page loads with the bad code and is perpetually locked.
korzo
@korzo
Aug 02 2017 01:15
@MirinaeMiREU add ?run=disabled
Peter Bae
@MirinaeMiREU
Aug 02 2017 01:16
thank you!
Joseph
@revisualize
Aug 02 2017 01:19
Hello.
zealsham
@zealsham
Aug 02 2017 01:24
anybody ever come across an issue like this. my index.pug page loads with all the needed js,css,etc. but subsequent pages loads with no css,js,etc even though i entered the correct resources in the html link tags. am using express.js and all my static files are in a folder called public
Stephen James
@sjames1958gm
Aug 02 2017 01:26
@adamfaraj Can you share again?
Adam Faraj
@adamfaraj
Aug 02 2017 01:37
@sjames1958gm oh man, it's all messed up again. haha. let me try to clean it up
shivam gupta
@shivamg11000
Aug 02 2017 01:40
what are mixins in react
Adam Faraj
@adamfaraj
Aug 02 2017 01:41
@sjames1958gm
var xhttp = new XMLHttpRequest();
xhttp.onload = function() {
    if (this.readyState == 4 && this.status == 200) {
       var response = JSON.parse(xhttp.responseText);
      for (var i=0; i<response.dealers.length;i++) {
        var dealersName = response.dealers[i].data.name;
        var dealersPhoneNum = response.dealers[i].data.phone1;
        var dealersEmail = response.dealers[i].data.email;
        var dealersHours = response.dealers[i].data.weekHours;
        var certs = response.dealers[i].data.certifications;
        console.log(dealersName);
        //console.log(dealersPhoneNum);
        //console.log(dealersEmail);
        //console.log(dealersHours);
        //console.log(certs);
        function addIntent(intent){
        let parentDiv = document.getElementsByClassName('intentDiv');
        let span = document.createTextNode(dealersName);
        console.log(span)
        parentDiv.appendChild(span);
        document.getElementsByClassName('intentDiv').appendChild(parentDiv);

        span.textContent(response.dealers[0].data.name);
        document.parentDiv.appendChild(para);
        let intentDiv = document.querySelector("#intentDiv");
        intentDiv.appendChild(div);
        // console.log("poop");
      }
      addIntent();

        //console.log(response.dealers[i].data.email);

      }



    }
  };
xhttp.open("GET", "src/js/dealers.json", true);
xhttp.send();
Stephen James
@sjames1958gm
Aug 02 2017 01:44
@adamfaraj You don't need the function - it was really just some code I pulled from one of my projects.
What element do you have in the HTML where you want to put this?
Adam Faraj
@adamfaraj
Aug 02 2017 01:45
@sjames1958gm
<div class="intentDiv">
  <div class="dealer1"></div>
  <div class="dealer2"></div>
  <div class="dealer3"></div>
  <div class="dealer4"></div>
  <div class="dealer5"></div>
  <div class="dealer6"></div>
  <div class="dealer7"></div>
</div>
Stephen James
@sjames1958gm
Aug 02 2017 01:45
So, let's get rid of the function and just put the code inline.
Adam Faraj
@adamfaraj
Aug 02 2017 01:46
parentDiv.appendChild is not a function at XMLHttpRequest.xhttp.onload
Stephen James
@sjames1958gm
Aug 02 2017 01:47
instead of the function just try this:
When you use getElementsByClassName you get a nodeList not a single element (Elements is plural in the name)
as opposed to getElementById where you get only one
let div = document.getElementsByClassName('dealer' + (i + 1))[0]; // because this returns a list of nodes
let span = document.createTextNode(dealersName);
div.appendChild(span);
'dealer' + (i + 1) this creates your class names dealer1 - dealer7
Adam Faraj
@adamfaraj
Aug 02 2017 01:52
@sjames1958gm it worked!
Stephen James
@sjames1958gm
Aug 02 2017 01:52
@sjames1958gm Because createTextNode - creates the node and sets the text you can do
div.appendChild(document.createTextNode(dealersName));
@adamfaraj :+1:
Adam Faraj
@adamfaraj
Aug 02 2017 01:52
please explain let div = document.getElementsByClassName('dealer' + (i + 1))[0]; // because this returns a list of nodes
Ronique Ricketts
@RoniqueRicketts
Aug 02 2017 01:52
YdKjs is such a good read
Adam Faraj
@adamfaraj
Aug 02 2017 01:52
why the [0];
you're getting the div class dealer and adding (i+1) to get the class names
but then the [0]...not sure what that does. you said returning the list of nodes?
Marcus Parsons
@marcusparsons
Aug 02 2017 01:55
@adamfaraj, the [0] selects the very first node returned from getElementsByClassName
You can look at the collection of elements returned by returned the output of document.getElementsByClassName('dealer' + (i + 1)).
var els = document.getElementsByClassName('dealer' + (i + 1));
console.log(els.length); //check how many elements were returned
Adam Faraj
@adamfaraj
Aug 02 2017 01:59
@marcusparsons i consoled.log(typeof els) and it says object?
console.log(els) is giving me an array
Marcus Parsons
@marcusparsons
Aug 02 2017 02:00
@adamfaraj, els is a collection of elements that you access just like an array
@adamfaraj, you can call array functions on it but you have to use Array.prototype.<method-here>.call
John
@AnonymousLords
Aug 02 2017 02:03
Guys how would i get the index of a something in a array?
[40, 60]
Adam Faraj
@adamfaraj
Aug 02 2017 02:03
@AnonymousLords arrayName[0] or arrayName[1]
Marcus Parsons
@marcusparsons
Aug 02 2017 02:03
@AnonymousLords, use the indexOf method to grab the index
John
@AnonymousLords
Aug 02 2017 02:03
i know 60 is in the 1 piston, but what command will allow me to get 1 as the piston?
Adam Faraj
@adamfaraj
Aug 02 2017 02:03
oh
haha
man, nvm
Marcus Parsons
@marcusparsons
Aug 02 2017 02:04
@adamfaraj, no worries, Adam, you're on the right track though!
John
@AnonymousLords
Aug 02 2017 02:04
@marcusparsons like array[i].indexOf();
Adam Faraj
@adamfaraj
Aug 02 2017 02:04
@marcusparsons i meant for @AnonymousLords
John
@AnonymousLords
Aug 02 2017 02:04
:point_up: August 1, 2017 10:04 PM correct :p?
Marcus Parsons
@marcusparsons
Aug 02 2017 02:05
@AnonymousLords here's an example:
var arr = [30,40,50,60];
console.log(arr.indexOf(30)); //will return 0 as it is the first index
@AnonymousLords, if you have an array with 2 dimensions, then yes you can call it that way
John
@AnonymousLords
Aug 02 2017 02:05
Okay
Thanks @marcusparsons @adamfaraj @marcusparsons @adamfaraj @marcusparsons @adamfaraj
CamperBot
@camperbot
Aug 02 2017 02:05
anonymouslords sends brownie points to @marcusparsons and @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
:cookie: 436 | @marcusparsons |http://www.freecodecamp.com/marcusparsons
Adam Faraj
@adamfaraj
Aug 02 2017 02:07
@marcusparsons
var els = document.getElementsByClassName('dealer' + (i + 1));
        console.log(els);
gives me
Marcus Parsons
@marcusparsons
Aug 02 2017 02:07
var arr = [[30,40],[50,60]];
for (let i = 0; i < arr.length; i++) {
 console.log(arr[i].indexOf(40)); //outputs 1 on first iteration, -1 on second
}
Adam Faraj
@adamfaraj
Aug 02 2017 02:08
[div.dealer1]
[div.dealer2]
[div.dealer3]
[div.dealer4]
[div.dealer5]
[div.dealer6]
[div.dealer7]
John
@AnonymousLords
Aug 02 2017 02:09
@marcusparsons why -1?
Marcus Parsons
@marcusparsons
Aug 02 2017 02:09
@adamfaraj, so that's of course in a loop?
@AnonymousLords, in the second iteration of the loop (the second array inside the larger array), 40 doesn't exist.
@AnonymousLords, when indexOf can't find a value in the array, then it returns -1
John
@AnonymousLords
Aug 02 2017 02:10
Okay
Adam Faraj
@adamfaraj
Aug 02 2017 02:10
@marcusparsons right, because i is looping through the length of dealers
Marcus Parsons
@marcusparsons
Aug 02 2017 02:10
@adamfaraj, do you have a codepen setup for what you're trying to do?
Adam Faraj
@adamfaraj
Aug 02 2017 02:11
nope. doing it locally
Marcus Parsons
@marcusparsons
Aug 02 2017 02:11
@adamfaraj, I'd need more information to help ya out man.
John
@AnonymousLords
Aug 02 2017 02:11
what are you guys dealing O_o
Stephen James
@sjames1958gm
Aug 02 2017 02:11
@adamfaraj The name of the function is revealing. Elements means you get the nodeList
Marcus Parsons
@marcusparsons
Aug 02 2017 02:11
@sjames1958gm, which is what I said lol
Adam Faraj
@adamfaraj
Aug 02 2017 02:12
@sjames1958gm would it have been easier to use an Id instead of class?
Marcus Parsons
@marcusparsons
Aug 02 2017 02:12
technically it's an HTMLCollection not a NodeList
Stephen James
@sjames1958gm
Aug 02 2017 02:13
@adamfaraj Yes, but you already had the class, so I didn't want to make too many changes
@sjames1958gm If you use querySelector then you get only one element.
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
Adam Faraj
@adamfaraj
Aug 02 2017 02:14
and the [0] is selecting the first element in the nodeList of dealers?
Stephen James
@sjames1958gm
Aug 02 2017 02:14
@adamfaraj Yes, or HTMLCollection as @marcusparsons pointed out.
@adamfaraj There is only one element, but you still have to use [0] as it is a collection.
Adam Faraj
@adamfaraj
Aug 02 2017 02:19
image.png
so the [0] is accessing all of that?
Marcus Parsons
@marcusparsons
Aug 02 2017 02:20
Yes
@adamfaraj, you can access its inner HTML by calling innerHTML conveniently :D
els[0].innerHTML returns that div's content
There's a whole mess of accessors you can use with the element once you have a reference to it like that
which is what you're seeing when you output the reference to it in the console
Adam Faraj
@adamfaraj
Aug 02 2017 02:22
@marcusparsons @sjames1958gm so why does this work document.getElementsByClassName('dealer' + (i + 1))[0] and not this document.getElementsByClassName('dealer' + (i + 1)) if there's only one thing in the node?
why do i have to access all of it with [0]
Marcus Parsons
@marcusparsons
Aug 02 2017 02:23
@adamfaraj, document.getElementsByClassName returns an array like object, so even if there is only one element, you still have to access it with its index.
Adam Faraj
@adamfaraj
Aug 02 2017 02:23
@marcusparsons lightbulb
gotcha

@marcusparsons so if

<div class="dealer1"></div>
  <div class="dealer2"></div>
  <div class="dealer3"></div>
  <div class="dealer4"></div>
  <div class="dealer5"></div>
  <div class="dealer6"></div>
  <div class="dealer7"></div>

was instead id's instead of classes

Marcus Parsons
@marcusparsons
Aug 02 2017 02:24
@adamfaraj, I love those lightbulb moments! I've been having them with .NET and C# lol
Adam Faraj
@adamfaraj
Aug 02 2017 02:25
i could use document.getElementById('dealer' + (i + 1))
John
@AnonymousLords
Aug 02 2017 02:25
@adamfaraj How many tabs do you need lol
Adam Faraj
@adamfaraj
Aug 02 2017 02:25
@AnonymousLords all the tabs
@adamfaraj it looks cleaner to me with tabs. haha
John
@AnonymousLords
Aug 02 2017 02:26
:trollface:
Marcus Parsons
@marcusparsons
Aug 02 2017 02:26
@adamfaraj, no document.getElementById returns only one element as indicated in the name.
Adam Faraj
@adamfaraj
Aug 02 2017 02:27
@marcusparsons right, so need for [0]
Marcus Parsons
@marcusparsons
Aug 02 2017 02:27
If you see elements in the name, expect an array like object. If you see just element, expect just that element.
Adam Faraj
@adamfaraj
Aug 02 2017 02:27
just straight document.getElementById('dealer + (i+1));
would work with Id
i see why it would be easier
Marcus Parsons
@marcusparsons
Aug 02 2017 02:27
@adamfaraj, yea if you use that it will totally work with an id that's set the same way as that class. Just remember to start at 1 instead of 0
Adam Faraj
@adamfaraj
Aug 02 2017 02:28
@marcusparsons thanks man!
CamperBot
@camperbot
Aug 02 2017 02:28
adamfaraj sends brownie points to @marcusparsons :sparkles: :thumbsup: :sparkles:
:cookie: 437 | @marcusparsons |http://www.freecodecamp.com/marcusparsons
Marcus Parsons
@marcusparsons
Aug 02 2017 02:28
@adamfaraj, no worries man! :)
John
@AnonymousLords
Aug 02 2017 02:31
How would i got about getting the last item in any array's index without even nothing what the array will be
Christopher McCormack
@cmccormack
Aug 02 2017 02:31
@AnonymousLords
> [1,2,3].slice(-1)
[ 3 ]
John
@AnonymousLords
Aug 02 2017 02:31
why-1?
Christopher McCormack
@cmccormack
Aug 02 2017 02:32
if less than 0, slice will add the length to the argument
John
@AnonymousLords
Aug 02 2017 02:32
Okay
Thanks @cmccormack
CamperBot
@camperbot
Aug 02 2017 02:32
anonymouslords sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1095 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Aug 02 2017 02:33
note that appears to return an array
if you have your array stored you can just use the length-1 as well:
> var arr = [1,2,3]
> arr[arr.length-1]
3
John
@AnonymousLords
Aug 02 2017 02:35
Okay
John
@AnonymousLords
Aug 02 2017 02:44
I just notciced i was doing the wrong basic algorithm challenge
instead of doing Return Largest Numbers in Arrays i was doing Where do I belong :worried:
Which is a harder challange
and is 10 challanges above teh one i was supposed to eb doing :P
:trollface:
CamperBot
@camperbot
Aug 02 2017 02:46
:trollface: troll problems? notify admins here
John
@AnonymousLords
Aug 02 2017 02:50
k
Marcus Parsons
@marcusparsons
Aug 02 2017 02:51
Oh no! :D
John
@AnonymousLords
Aug 02 2017 02:51
im done 75% of it
im almost done it to :+1:
Marcus Parsons
@marcusparsons
Aug 02 2017 02:53
That is definitely awesome! You got this!
John
@AnonymousLords
Aug 02 2017 02:53
i think
John
@AnonymousLords
Aug 02 2017 03:09
Okay why isnt my code working?
function getIndexToIns(arr, num) {
  arr = arr.sort();
  var place = 0;
  var arrTwo = arr.slice(-1);


  for (var i = 0; i < arr.length; i++) {
  if (num > arr[i] &&  num < arr[i] + 1) {
    place = arr[i];
  }
  else (num > arrTwo) 
   place = arr.length;
  }
  return place;
}

getIndexToIns([40, 60, 65], 50);
If i remove
else (num > arrTwo) 
   place = arr.length;
It works fine, but not with numbers bigger then teh last number in teh array
Manish Giri
@Manish-Giri
Aug 02 2017 03:11
that is very complicated code for a simple challenge
arr.sort(); - also, this doesn't sort numbers
John
@AnonymousLords
Aug 02 2017 03:11
Why>]
Its not very complcaited t me :P
Manish Giri
@Manish-Giri
Aug 02 2017 03:13
you could do it in 3 lines
John
@AnonymousLords
Aug 02 2017 03:13
;O
intcreate
@intcreate
Aug 02 2017 03:13
Can anyone help me with nodejs
authentication
John
@AnonymousLords
Aug 02 2017 03:14
I accidentally skipped to the 2nd to last challenge when i'm on the 6th in basic algorithm scripting. It had already been 30 minutes so i continued with doing it...
Ill just go back to Return Largest Numbers in Arrays thanks anyways
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:19
  componentWillMount = () => {
    var h = this.state.h, w = this.state.w;
    for ( var i = 0, len = h; i < len; ++i ) {
      this.state.world[i] = new Array (w);
      for ( var j = 0, len1 = w; j < len1; ++j ) {
        this.state.world[i][j] = Math.round(Math.random());
      }
    }
  }
  nextgen = () => {
    var world = this.state.world,
        worldNext = [];
    for ( var i = 0, len = this.state.world.length; i < len; ++i ) {
      worldNext[i] = new Array (this.state.world[i].length);
    }
    for ( var x = 0, len1 = world.length; x < len1; ++x ) {
      for ( var y = 0, len2 = world[x].length; y < len2; ++y ) {
        var n = 0;

        for ( var dx = -1; dx <= 1; ++dx ) {
          for ( var dy = -1; dy <= 1; ++dy ) {
            if ( dx === 0 && dy === 0 ) {}
            else if ( world[x + dx] !== undefined && world[x + dx][y + dy] !== undefined && world[x + dx][y + dy]) {
              ++n;

            }
          }
        }

      var g = world[x][y];
      switch (n) {
        case 0:
        case 1:
          g = 0;
          break;
        case 2:
          break;
        case 3:
          g = 1;
          break;
        default:
          g = 0;
      }
      worldNext[x][y] = g;
      }
    }
    let count = this.state.generations + 1;
    this.setState({ generations: count});
    this.setState({ world: worldNext.slice() });
  }
I'm having some trouble optimizing this code, anyone have any pointers? It's for the logic for the Game of Life
John
@AnonymousLords
Aug 02 2017 03:19
Wow that looks complicated
lol on only basic algorithm
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:21
oh and I should mention that's ReactJS, if that helps. I keep getting [Violation] 'setInterval' handler took 51ms or similar in the console. It's not a huge deal but I want to scale up a bit and I think it'll be problematic later on.
Jim Tryon
@jimtryon
Aug 02 2017 03:29
@znicholasbrown is that in a refactored state? that looks overly complicated in some parts
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:34
@jimtryon refactored? It's only a portion of the component for sure. I'm not sure I understand the question!
Cody Seibert
@codyseibert
Aug 02 2017 03:44
@znicholasbrown how large is your grid?
shivam gupta
@shivamg11000
Aug 02 2017 03:45
what's happening here with the arrow functions
let add = x => y => x + y;
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:45
@codyseibert at this stage it's only 32 by 32, so 1024 spaces. I'd like to increase to 100 by 100 but I see a definite performance drop.
Cody Seibert
@codyseibert
Aug 02 2017 03:46
and it's taking 51ms to run nextgen function?
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:46
It is, it's running it like this:
componentDidMount = () => {
    this.startTime();
  }
  freezeTime = () => {
    this.setState({on: false});
    clearInterval(this.state.interval);
  }
  startTime = () => {
    if ( this.state.on == "true" ) {
    } else {
      this.setState({on: "false"});
      this.setState({ interval: setInterval(function (){
        this.nextgen();
      }.bind(this), 150) })
    }
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:47
@shivamg11000 .. so can be expanded in to normal function as
let add = function(x){ return function(y){ return x +y; }
Cody Seibert
@codyseibert
Aug 02 2017 03:48
@shivamg11000 that's basically the same as this:
let add = (x) => {
  return (y) => {
    return x + y;
  }
}
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:48
I'm not sure if it's better for me to call new Array() or to initialize an array literal
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:49
Can you tell me how do we write this in fat arrow
         if(isNumber(c)){

        return function(arg2){

            return aOrbUndefined(c, arg2);    

        };

    }
JD Flick
@jdflick
Aug 02 2017 03:50
can anyone assist me with my mutation code? it seems like everything is written properly, but one aspect doesn't work
Jim Tryon
@jimtryon
Aug 02 2017 03:50
Fat arrow? do you mean arrow notation?
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:50
@jimtryon yeah.

this is what I wrote

if(isNumber(c)){ return (arg2) => aOrbUndefined(c, arg2); }

Jim Tryon
@jimtryon
Aug 02 2017 03:51
that looks right to me
Cody Seibert
@codyseibert
Aug 02 2017 03:51
@znicholasbrown your code looks already pretty optimized
you're probably seeing slowdowns from react trying to render the template on your grid which keeps changing assuming that's how you are drawing you grid?
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:52
@jimtryon yeah. This works, though. But I was wondering if we can avoid that word return also
Cody Seibert
@codyseibert
Aug 02 2017 03:53
@znicholasbrown try commenting these lines out and see how fast your function runs:

    this.setState({ generations: count});
    this.setState({ world: worldNext.slice() });
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:53
like
if(isNumber(c)){ (arg2) => aOrbUndefined(c, arg2); }
Cody Seibert
@codyseibert
Aug 02 2017 03:53
just to verify if the slowdown is because of react
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:53
@codyseibert It is. I might try a different rendering method, chrome developer tools was telling me the script was the slowdown though
Let me try that
Jim Tryon
@jimtryon
Aug 02 2017 03:53
@Venkateshwaran You don’t need the return keyword… so you could take it out and do (arg2) => aOrbUndefined(c, arg2);
Long Nguyen
@longnt80
Aug 02 2017 03:54
@jimtryon where do you learn es6 syntax?
Jim Tryon
@jimtryon
Aug 02 2017 03:54
I would learn it from the ES6 docs or take Wes Bos course on ES6
Cody Seibert
@codyseibert
Aug 02 2017 03:55
@znicholasbrown also, at the start and end of your method, you can do this to see how long it took:
console.time('step');
// run code here
console.timeEnd('step');
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:55
@jimtryon No. It is not working. It is throwing error. Expecting an assignment or function call instead saw a statement
Long Nguyen
@longnt80
Aug 02 2017 03:55
@jimtryon is it this one: http://es6-features.org
Cody Seibert
@codyseibert
Aug 02 2017 03:55
which will print out the time elasped ^
Jim Tryon
@jimtryon
Aug 02 2017 03:55
@Venkateshwaran See if you can rewrite your function using this keyword in place of the return
Venkateshwaran
@Venkateshwaran
Aug 02 2017 03:56
aOrbUndefined this function?
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:56
@codyseibert I just did both. It's definitely React. So I'm gonna have to figure out a better method of rendering.
@codyseibert Thanks, btw
CamperBot
@camperbot
Aug 02 2017 03:56
znicholasbrown sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
:cookie: 38 | @codyseibert |http://www.freecodecamp.com/codyseibert
JD Flick
@jdflick
Aug 02 2017 03:57
anyone up for taking a look at my mutations code to clue me in on why it fails on only one array?
Cody Seibert
@codyseibert
Aug 02 2017 03:58
@znicholasbrown np, I'd suggest using canvas if you want performance
or, you could just call that setState method every second instead of every 150ms
Nicholas Brown
@znicholasbrown
Aug 02 2017 03:59
@codyseibert At this point I'm committed but I'll look into it for the next one. I think cutting out one of the setState functions seems to boost performance by about half so I'm gonna do that.
@jdflick I'll take a look, go ahead and post your code
Venkateshwaran
@Venkateshwaran
Aug 02 2017 04:00
function addTogether(){

    let isNumber = (item) =>
             typeof item !== 'number' ? undefined : item;

    let aOrbUndefined = (item1, item2) =>
            item1 === undefined || isNumber(item2) === undefined ? undefined : item1 + item2;



    if(arguments.length>1){
        var a = isNumber(arguments[0]);
        var b = isNumber(arguments[1]);
        return aOrbUndefined(a, b);
    }
    else{
        var c = arguments[0];
        if(isNumber(c)){  
            return (arg2) => aOrbUndefined(c, arg2);
//           (arg2) => aOrbUndefined(c, arg2);
        }
    }

}
Cody Seibert
@codyseibert
Aug 02 2017 04:00
@znicholasbrown actually, why are you calling "worldNext.slice()"
Venkateshwaran
@Venkateshwaran
Aug 02 2017 04:00
@jimtryon this is my working code
Cody Seibert
@codyseibert
Aug 02 2017 04:00
can't you just modify the underlying array instead of creating new ones?
JD Flick
@jdflick
Aug 02 2017 04:00

function mutation(arr) {

  var array1 = arr[0];
  array1 = array1.toLowerCase();
  var array2 = arr[1];
  array2 = array2.toLowerCase().split('');

  for (var i = 0; i < array2.length; i++){

  if (array1.indexOf(array2[i]) !== -1){

    return true;

  }

    return false;
  }


}

mutation(["hello", "hey"]);
it fails on the first check, but all other checks it works so I'm not sure if I have a count wrong or something else
Nicholas Brown
@znicholasbrown
Aug 02 2017 04:02
@codyseibert Hold on, let me see. I wrote that this morning, I'm hoping I had a good reason. Shit.
@jdflick Can you link to the challenge?
Long Nguyen
@longnt80
Aug 02 2017 04:02
@jimtryon thanks
CamperBot
@camperbot
Aug 02 2017 04:02
longnt80 sends brownie points to @jimtryon :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @jimtryon |http://www.freecodecamp.com/jimtryon
Cody Seibert
@codyseibert
Aug 02 2017 04:02
I would think you can just do another double loop over your worldNext and update your this.state.world elements to match it
react might have to do a lot of extra work if you keep setting world to a new array
Jim Tryon
@jimtryon
Aug 02 2017 04:03
@codyseibert That is not a bad way to go about it
only some overhead from the iterations but that should work
Cody Seibert
@codyseibert
Aug 02 2017 04:04
@jdflick you can't return true in your loop. you need to check all characters first before returning true
return false is also causing issues
your loop will only execute for the first character and then return true or false
JD Flick
@jdflick
Aug 02 2017 04:06
ahhh ok, that helps, I can break it down and start working on it again
thanks I'm gonna rebuild and start over
Nicholas Brown
@znicholasbrown
Aug 02 2017 04:13
@jdflick Sorry it took me a min. My advice would be to set a variable outside the scope of the for loop like var check = true and only modify that variable inside the if(array1.indexOf(array2[i]) === -1) to false if that catches something. Then just return the variable.
In that case you'd have to be looking for -1 values instead of not looking for them, though
JD Flick
@jdflick
Aug 02 2017 04:16
so I fixed it. would you like me to post the solution?
it was pretty stupid really
Nicholas Brown
@znicholasbrown
Aug 02 2017 04:17
Definitely, let's see. Hey we all do stupid stuff no worries.
JD Flick
@jdflick
Aug 02 2017 04:17
function mutation(arr) {

  var array1 = arr[0];
  array1 = array1.toLowerCase();
  var array2 = arr[1];
  array2 = array2.toLowerCase().split('');

  for (var i = 0; i < array2.length; i++){

  if (array1.indexOf(array2[i]) == -1)

    return false;
  }
    return true;
  }




mutation(["hello", "hey"]);
so I had used !== and had created another loop in the if incorrectly
heroiczero
@heroiczero
Aug 02 2017 04:18
:+1: nice job :clap: Keep going
Nicholas Brown
@znicholasbrown
Aug 02 2017 04:18
You caught it! Nice! That kinda stuff can be really annoying. But it happens.
JD Flick
@jdflick
Aug 02 2017 04:18
thanks for the hints, it helped me to relook at it
telling me that I was looping the single item helped me to understand to broaden my loop
Cody Seibert
@codyseibert
Aug 02 2017 04:19
@jdflick I'd also suggest to always make sure to indent nested blocks correctly
for example, the if statement should be indented in that foor loop
JD Flick
@jdflick
Aug 02 2017 04:20
yep, I normally do, I had been cutting and pasting it around for an hour or 2 trying to figure out what I was doing wrong
I thank you all, time for me to take a break
Nicholas Brown
@znicholasbrown
Aug 02 2017 04:29
@codyseibert So I've stopped calling setState in the nextGen function completely. That's led to about a 10ms performance boost. I have to call it once in the setInterval though, or react doesn't update the DOM at all. However at least at 32 by 32 I've stopped getting Violation warnings. Thanks man!
CamperBot
@camperbot
Aug 02 2017 04:29
znicholasbrown sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
:warning: znicholasbrown already gave codyseibert points
Cody Seibert
@codyseibert
Aug 02 2017 04:34
:shipit:
Brad
@bradtaniguchi
Aug 02 2017 05:21

Hi All, I am on the symmetric difference challenge and don't get how:

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

has the symmetric difference of:

[1, 4, 5]

Why is there the 5 there?

Markus Kiili
@Masd925
Aug 02 2017 05:22
@bradtaniguchi First two are symdiffed and the result with the third etc.
Brad
@bradtaniguchi
Aug 02 2017 05:22
@Masd925 I do not understand
Markus Kiili
@Masd925
Aug 02 2017 05:24
@bradtaniguchi Symmetric difference of the first two elements is [1,3]. Symmetric difference with that result and the third element [3,4,5] is [1,4,5].
Brad
@bradtaniguchi
Aug 02 2017 05:24
Oh I see, thank you
@Masd925 thanks
CamperBot
@camperbot
Aug 02 2017 05:24
bradtaniguchi sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4365 | @masd925 |http://www.freecodecamp.com/masd925
Kelechi Chinaka
@ke1echi
Aug 02 2017 05:46
:wave: @Masd925 i am trying to grasp the consept of oop in js..what is the meaning of enumerable?
Read the first answer, should clear up any confusion
Markus Kiili
@Masd925
Aug 02 2017 05:48
@kelechy It basically means properties that are not built-in properties (like toString). If you make new properties they are by default enumerable.
Enumerable properties show up in for...in loop and Object.keys(obj)
Kelechi Chinaka
@ke1echi
Aug 02 2017 05:51
:+1: @jimtryon @Masd925
Markus Kiili
@Masd925
Aug 02 2017 05:53
@kelechy There is an internal property attribute enumerable that determines if a property is enumerable or not. Properties made by literals or assignment are configurable, writable, and enumerable. With Object.defineProperty() you can specify those property attributes.
Kelechi Chinaka
@ke1echi
Aug 02 2017 05:55
pls break it down
whats the concept of enumerable?
docs said property that can be added during for..in loops?
Markus Kiili
@Masd925
Aug 02 2017 05:57
@kelechy It means whether the property is found when you iterate with for...in loop or Object.keys(obj). We don't wan't properties like toString to be iterated over there. So such properties are set non-enumerable.
Kelechi Chinaka
@ke1echi
Aug 02 2017 06:00
ok
Markus Kiili
@Masd925
Aug 02 2017 06:00
@kelechy Plain objects for example have 12 inherited non-enumerable properties. You don't wan't those on your loops over property keys.
Kelechi Chinaka
@ke1echi
Aug 02 2017 06:03
ok am reading ydkjs series and some of the terms and concepts are new to me..ty @Masd925
Joseph
@revisualize
Aug 02 2017 06:48
@Masd925 ty
CamperBot
@camperbot
Aug 02 2017 06:48
revisualize sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4366 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Aug 02 2017 06:48
@Masd925 Get you that bp from @kelechy
Markus Kiili
@Masd925
Aug 02 2017 06:49
@revisualize , our :cookie: :police_car:
Kelechi Chinaka
@ke1echi
Aug 02 2017 06:55
:smile: camperbot seems to be sleeping @revisualize thanks @Masd925
CamperBot
@camperbot
Aug 02 2017 06:55
kelechy sends brownie points to @revisualize and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4397 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 4367 | @masd925 |http://www.freecodecamp.com/masd925
sky1095
@sky1095
Aug 02 2017 07:21
/// var result = "My " + myNoun + "saw a " + myAdjective + " man and " + myVerb + "inside the home" + myAdverb + " to call me" ; ///
any mistakes??
Markus Kiili
@Masd925
Aug 02 2017 07:22
@sky1095 Check the spaces on the result.
sky1095
@sky1095
Aug 02 2017 07:22
figured it out
thanx @Masd925
CamperBot
@camperbot
Aug 02 2017 07:22
sky1095 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4369 | @masd925 |http://www.freecodecamp.com/masd925
Emmanuel Akodia
@akodiaemma
Aug 02 2017 07:29
guys i wanted to add pop up send email button to my page once someoe clicks something..any ideas
Markus Kiili
@Masd925
Aug 02 2017 07:36
@akodia488 Do you mean to confirm it or get some input?
Emmanuel Akodia
@akodiaemma
Aug 02 2017 07:38
th button when clicked should bring a brilliant pop up screen, when types in the question, it sends to my email
check the site and notice the login and register button
if u like mention and i will give u the code snippets @akodia488
Emmanuel Akodia
@akodiaemma
Aug 02 2017 07:50
@sky1095 yes exactly like that
how do i get that for a button
Rinor Bivolaku
@RinorNotorious
Aug 02 2017 07:57
Hello guys, I've been stuck in this project (The Weather API project) for a while, and I can't figure out how to access the icons of Darksky API. My codepen is as follows:
https://codepen.io/Reenor/pen/RgmzPo
-
I've been trying to access the classes, but for some reason, I can't.
Abhinav Mishra
@abhinav-m
Aug 02 2017 08:33
@RinorNotorious where are you calling IconGen..
maybe im missing something
Rinor Bivolaku
@RinorNotorious
Aug 02 2017 08:38
@abhinav-thinktank You're right, I must've removed it. Take a look at it now, if you can and have the time.
https://codepen.io/Reenor/pen/RgmzPo
Abhinav Mishra
@abhinav-m
Aug 02 2017 08:41
Im a bit confused on what you're trying to do here
few things that are wrong in my opinion:
the api is returning Overcast in my case
that case is not handled in your switch statement
also the prepend() expects a return call
Jon
@jonandrepedersen
Aug 02 2017 08:43
Anyone doing the "Sorted Union" challenge?
Abhinav Mishra
@abhinav-m
Aug 02 2017 08:43
it expects a parameter to be returned
which you don't seem to be providing
Markus Kiili
@Masd925
Aug 02 2017 08:54
@jonandrepedersen It is a familiar challenge.
Jon
@jonandrepedersen
Aug 02 2017 08:57
@Masd925 cool, I don't have any direct issues as I've just started it. However, I would be interested in knowing a tad more about how you approached it. E.g. did you use SORT and REDUCE in some ways?
Markus Kiili
@Masd925
Aug 02 2017 08:58
@jonandrepedersen Sort is such a costly process, so I have used filter and/or reduce.
Jon
@jonandrepedersen
Aug 02 2017 08:58
Kk, I'm way too noob to grasp what's costly or not, but I will have a go at filter then
Markus Kiili
@Masd925
Aug 02 2017 09:00
@jonandrepedersen Rule of thumb is that you should avoid sorting if you don't really need the sorted array.
Jon
@jonandrepedersen
Aug 02 2017 09:04
@Masd925 gotcha!
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:09
Anyone familiar with React?
class RecipesSection extends React.Component {
  constructor() {
    super();
    this.state = {
      recipes: [{title:"bc",ingredients:"b,c"},{title:"cake",ingredients:"chocolate,cream"}],
      makingRecipe: false
    }
  }

  deleteRecipe(index){
  this.setState({
    recipes: this.state.recipes.slice(index,1)
  })
  }

  addRecipe(){
    var newRecipes =this.state.recipes;
    newRecipes.push({title:"cake",ingredients:"chocolate,cream"});
    this.setState({
     recipes: newRecipes
    })
  }

    render(){
      if(this.state.makingRecipe)
        return<div className="recipeMaker">MAKING RECIPE RIGHT NOW </div>
        else
      return(
        <div className="recipesSection">
          <div className="addButton" onClick ={this.addRecipe}>Add</div>
       { this.state.recipes.map((recipeDetails,i)=> <RecipeInfo isExpanded={true} recipeDetails = {recipeDetails} deleteFn={this.deleteRecipe}  />)}
        </div>
      )
    }
}
var newRecipes =this.state.recipes; getting error here
cannot get state of null
won't this refer to recipeSection component in this case
Manish Giri
@Manish-Giri
Aug 02 2017 09:12
@abhinav-thinktank you need to bind the function
 constructor() {
    super();
    this.state = {
      recipes: [{title:"bc",ingredients:"b,c"},{title:"cake",ingredients:"chocolate,cream"}],
      makingRecipe: false
    }

this.addRecipe = this.addRecipe.bind(this);
}
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:13
@Manish-Giri oh..
Manish Giri
@Manish-Giri
Aug 02 2017 09:13
same for the rest
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:13
@Manish-Giri another quick thing
this.deleteRecipe
is intended to delete the recipe when i click on that button
Manish Giri
@Manish-Giri
Aug 02 2017 09:14
yea
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:14
note that since it is a different component
how will i change the state of this RecipesSection component on that button click
this is a part im struggling to think about
Manish Giri
@Manish-Giri
Aug 02 2017 09:15
um
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:15
class RecipeInfo extends React.Component {

render(){
      if(this.props.isExpanded===false)
  return( <div className="recipeTitle">{this.props.recipeDetails.title}</div>
        )
    else
      return(<div className="recipeWrapper">
      <div className="recipeTitle">{this.props.recipeDetails.title}</div>
      {this.props.recipeDetails.ingredients.split(",").map((ingred,i) => <div className="ingredientName">{ingred}</div> )}
      </div>
  )
}

}
this is the recipeInfo comoonent
component *
Manish Giri
@Manish-Giri
Aug 02 2017 09:16
different component?
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:16
yea
it's nested inside the upper section
Manish Giri
@Manish-Giri
Aug 02 2017 09:16
deleteRecipe is a part of RecipesSection itself
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:16
it is
i want to pass deleteRecipe as a prop to my RecipeInfo component
Manish Giri
@Manish-Giri
Aug 02 2017 09:16
okay
then?
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:17
i want to render a button in my recipeInfo component, which on click would fire this prop
however there is a catch, it should delete the particular index upon which it is fired upon
hmmm
Manish Giri
@Manish-Giri
Aug 02 2017 09:17
create a function in RecipeInfo
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:17
oh ok i can pass the index as a prop too i guess
:D
ill try something out and ask if i get stuck
@Manish-Giri ty!
CamperBot
@camperbot
Aug 02 2017 09:18
:star2: 6349 | @manish-giri |http://www.freecodecamp.com/manish-giri
abhinav-thinktank sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Aug 02 2017 09:18
handleDelete(event) {
 this.props.onDelete(event.target.value);
}
Simon Cordova
@gbsimon87
Aug 02 2017 09:18
Hey guys, anybody know a resource such as the debugger or pythontutor where I can see my code execution step by step?
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:18
ok ill see how this works too
@Manish-Giri :+1:
Manish Giri
@Manish-Giri
Aug 02 2017 09:18
onDelete will be your deleteRecipe prop
event.target.value will give you the index of the recipe in the array
rest you already have
@abhinav-thinktank
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:19
@Manish-Giri ok thanks again!
CamperBot
@camperbot
Aug 02 2017 09:19
abhinav-thinktank sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: abhinav-thinktank already gave manish-giri points
Manish Giri
@Manish-Giri
Aug 02 2017 09:19
:+1:
sky1095
@sky1095
Aug 02 2017 09:33
@akodia488
Emmanuel Akodia
@akodiaemma
Aug 02 2017 09:35
@sky1095 yes
sky1095
@sky1095
Aug 02 2017 09:35
<section class="header-w3ls"> 
            <button id="trigger-overlay" type="button"><i class="fa fa-bars" aria-hidden="true"></i></button>
            <div class="bottons-agileits-w3layouts">
            <a class="page-scroll" href="#myModal2" data-toggle="modal"><i class="fa fa-sign-in" aria-hidden="true"></i>Login</a>.
            <a class="page-scroll" href="#myModal3" data-toggle="modal"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>Register</a>
            </div>
        <h1><a href="index.php">Injustice</a></h1>
        <div class="clearfix"> </div>
        </section>
<!-- //menu -->
<!-- modal -->
    <div class="modal about-modal w3-agileits fade" id="myModal2" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>                        
                </div> 
                <div class="modal-body login-page "><!-- login-page -->     
                                    <div class="login-top sign-top">
                                        <div class="agileits-login">
                                        <h5>Login</h5>
                                        <form action="login.php" method="POST">
                                            <input type="text" class="email" name="email" placeholder="Email" required=""/>
                                            <input type="password" class="password" name="pass" placeholder="Password" required=""/>
                                            <div class="wthree-text"> 
                                                <ul> 
                                                    <li>
                                                        <label class="anim">
                                                            <input type="checkbox" class="checkbox">
                                                            <span> Remember me ?</span> 
                                                        </label> 
                                                    </li>
                                                    <li> <a href="#">Forgot password?</a> </li>
                                                </ul>
                                                <div class="clearfix"> </div>
                                            </div>  
                                            <div class="w3ls-submit"> 
                                                <input name="login" type="submit" value="LOGIN">      
                                            </div>    
                                        </form>

                                        </div>  
                                    </div>
                        </div>  
                </div> <!-- //login-page -->
            </div>
        </div>
    <!-- //modal --> 
    <!-- modal -->
    <div class="modal about-modal w3-agileits fade" id="myModal3" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>                        
                </div> 
                <div class="modal-body login-page "><!-- login-page -->     
                                    <div class="login-top sign-top">
                                        <div class="agileits-login">
                                        <h5>Register</h5>
                                        <form action="signup.php" method="POST">
                                            <input type="text" name="firstName" placeholder="First Name" required=""/>
                                            <input type="text" name="lastName" placeholder="Last Name" required=""/>
                                            <input type="text" name="userName" placeholder="Username" required=""/>
                                            <input type="email" name="Email" placeholder="Email" required=""/>
                                            <input type="text" name="rollNo" placeholder="Roll No." required=""/>
                                            <input type="text" name="college" placeholder="College" required=""/>
                                            <input type="password" name="pass" placeholder="Password" required=""/>
                                            <div class="wthree-text"> 
                                                <ul> 
                                                    <li>
                                                        <label class="anim">
                                                            <input type="checkbox" class="checkbox" required="#">
                                                            <span> I accept the terms of use</span> 
                                                        </label> 
                                                    </li>
                                                </ul>
                                                <div class="clearfix"> </div>
                                            </div>  
                                            <div class="w3ls-submit"> 
                                                <input type="submit" value="Register">      
                                            </div>    
                                        </form>

                                        </div>  
                                    </div>
                        </div>  
                </div> <!-- //login-page -->
            </div>
        </div>
    <!-- //modal -->
@akodia488 here is the code that i have used for the same
Kelechi Chinaka
@ke1echi
Aug 02 2017 09:56
function factorial(n) {
  //base case
  if (n === 0) {
    return 1;
  }
  //recursive case
  return n * factorial(n - 1);
};
hey guys pls what is wrong with the recursion
oh nvm..editor issue
Abhinav Mishra
@abhinav-m
Aug 02 2017 09:59
@kelechy seems fine
Markus Kiili
@Masd925
Aug 02 2017 09:59
@kelechy No need for that ending semicolon.
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:00
if ((n === 0) || (n ===1))
should add a base case for 1 as well..
but it is non trivial..
Markus Kiili
@Masd925
Aug 02 2017 10:01
@abhinav-thinktank Why?
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:01
there is no need to compute 1 * 0!
1! = 1
Markus Kiili
@Masd925
Aug 02 2017 10:02
@abhinav-thinktank With the same logic you should start to store other values too on a list. Just having one terminating value is the best imo.
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 10:03
good morning everyone
can someone check my pen?got a issue and can't think of a easy way to solve it only comes to my head big works around, https://codepen.io/tiagocorreia/pen/LjGwmg this is my pomodoro clock the only thing im missing iswhen the pomodoro is started and then stoped and I increse the clock time or break time it will obviously pick the variable clock that I decrese every second and add it 1 minute or remove, but what It's like know what was the last clock/break time I choose and increse the time on those, hope it wanst confusing :D
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:05
@Masd925 not really.. you can avoid one extra computation step , but as i mentioned, it's non trivial and doesn't matter in the big picture..
oops
*trivial
:D
Kelechi Chinaka
@ke1echi
Aug 02 2017 10:10
semi colon is non trivial too @Masd925 :smile:
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:10
trivial *
Markus Kiili
@Masd925
Aug 02 2017 10:10
@abhinav-thinktank But why you just avoid one? Why not two on three etc. I think that the simplest way is very clear or have all the factorials of integers on an array (that is used when factorial is needed a lot, or an approximation is used on large values). Having something in between just makes more code.
Kelechi Chinaka
@ke1echi
Aug 02 2017 10:10
trivial rather :smile:
Markus Kiili
@Masd925
Aug 02 2017 10:10
@kelechy On function declarations it is not needed.
Kelechi Chinaka
@ke1echi
Aug 02 2017 10:14
ok
this oop style in js is beginining to make sense to me @Masd925 be ready for lotta oop questions from me :smile:
shivam gupta
@shivamg11000
Aug 02 2017 10:15

in this

Array.prototype.myFilter = function(callback, context) {
    arr = [];
    for (var i = 0; i < this.length; i++) {
        if (callback.call(context, this[i], i, this))
            arr.push(this[i]);
    }
    return arr;
};

what's happening here
if (callback.call(context, this[i], i, this))

what's context here
Markus Kiili
@Masd925
Aug 02 2017 10:16
@shivamg11000 It executes the callback function and sets value of this on the execution context to context and passes those values this[i], i, this as arguments. Because myFilter is a method, this there points to the calling object (array it was called upon).
You should check methods call/bind/apply that all functions have.
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:21
@shivamg11000 also, you're inheriting up the Array prototype chain, all arrays will have myFilter available to them as a method
shivam gupta
@shivamg11000
Aug 02 2017 10:26
@Masd925 what is context here?
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:27
@shivamg11000 an argument passed to the function
@shivamg11000 the call method will call it using the context passed to this function
from the link given to you earlier
function.call(thisArg, arg1, arg2, ...) Parameters thisArg The value of this provided for the call to a function. Note that this may not be the actual value seen by the method: if the method is a function in non-strict mode , null and undefined will be replaced with the global object and primitive values will be converted to objects.
go through the abovementioned link for more examples
Markus Kiili
@Masd925
Aug 02 2017 10:31
@shivamg11000 That is an implementation of filter function. So context is similar to built-in filter functions thisArg. So with it you can pass a value to the callback function as this.
Stephen James
@sjames1958gm
Aug 02 2017 10:32
@shivamg11000 context will become the this value when the callback function is invoked.
Similar to when you call a function on an object. Like context[callback](this[i], i, this)
Markus Kiili
@Masd925
Aug 02 2017 10:32
myFilter keeps those array elements that return a truthy value when passed into the callback function.
shivam gupta
@shivamg11000
Aug 02 2017 10:35
in (context, this[i], i, this)
this[i] is the value at index i in the array
i is the index
this is the array
but what is context
is it a js keyword
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:35
no..
Array.prototype.myFilter = function(callback, context) {
your function accepts a context in which it is invoked
Markus Kiili
@Masd925
Aug 02 2017 10:36
@shivamg11000 It is any value that you wan't to use inside the callback function when you decide what elements to keep. context parameter is for holding that value.
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:37
@shivamg11000 this might help understanding about context
shivam gupta
@shivamg11000
Aug 02 2017 10:42
I know we can set a function context with bind()
Markus Kiili
@Masd925
Aug 02 2017 10:43
@shivamg11000 Same goes for call and apply. They all can set the value of thison the execution context.
Nikola
@nikola663
Aug 02 2017 10:44
Hello, has anyone made any experience with saving an editable table cell on when you press enter? Can I just put an onclick on the "<td>" and gather the value of it and send to the server?
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:45
@shivamg11000 go through this once.. will be a help http://ryanmorr.com/understanding-scope-and-context-in-javascript/
Markus Kiili
@Masd925
Aug 02 2017 10:46
@nikola663 You can collect the info from an element and send it. Are you looking for a mouse click or a keypress on enter?
Rinor Bivolaku
@RinorNotorious
Aug 02 2017 10:52
Hello guys, I don't really have much experience using APIs, and what I would like to know is whether you guys know a good tutorial for Darksky API?
Nikola
@nikola663
Aug 02 2017 10:54
@Masd925 Enter, my bad with the onclick made no sense if I want to trigger a function on keypress
Keypress on enter only obviously
Stephen James
@sjames1958gm
Aug 02 2017 10:57
@nikola663 You will need to distinguish from event.target and event.currentTarget
event.target will be the cell that had focus when you pressed enter (probably the element you will get the value from)
event.currentTarget will be the element that you put the keypress handler on (you could put this on a container of the td, rather than each td
Abhinav Mishra
@abhinav-m
Aug 02 2017 10:59
@RinorNotorious you were doing fine on that api..
@RinorNotorious just see what it's typical response looks like and try to parse it in your code
@RinorNotorious they would have the response on their site
Michael Baxter
@baxt01
Aug 02 2017 11:00
Nikola
@nikola663
Aug 02 2017 11:02
Okay I'll try that after lunch, thanks for the advice!
(i can't @ you somehow)
Stephen James
Stephen James
@sjames1958gm
Aug 02 2017 11:03
@nikola663 :+1:
shivam gupta
@shivamg11000
Aug 02 2017 11:05
Ok so in this
https://gitter.im/FreeCodeCamp/HelpJavaScript?at=5981a642614889d475102094
callback.call() is passing the context to the callback function but initially it is passed here
Array.prototype.myFilter = function(callback, context) {
from where it is passed here
or it is passed automatically
Markus Kiili
@Masd925
Aug 02 2017 11:06
@shivamg11000 It is first stored on the context parameter and then set as value of this when callback is executed by the call line there.
When myFilter is executed, arguments from the function call are stored on those parameters callback, context.
Markus Kiili
@Masd925
Aug 02 2017 11:12
@shivamg11000 Here is an example of using the myFilter to keep only friend names:
Array.prototype.myFilter = function(callback, context) {
    arr = [];
    for (var i = 0; i < this.length; i++) {
        if (callback.call(context, this[i], i, this))
            arr.push(this[i]);
    }
    return arr;
};

var myFriends = ["Cat", "John", "Tom"];

var func = function (elem) {
  return this.indexOf(elem)>-1;
};

["Jim", "Cat", "Milton", "John"].myFilter(func, myFriends); // [ 'Cat', 'John' ]
So we tell myFilter to keep elements that are found on array this and we set this to be myFriends array.
Stephen James
@sjames1958gm
Aug 02 2017 11:15
@shivamg11000 Following on to @Masd925 example, you could certainly reference myFriends directly in func but that would
func useful in only one situation, by using the context, func becomes generic and usable anytime you need a function that
tests if values are in a context that supports indexOf
zealsham
@zealsham
Aug 02 2017 11:20
anybody ever come across an issue like this. my index.pug page loads with all the needed js,css,etc. but subsequent pages loads with no css,js,etc even though i entered the correct resources in the html link tags. am using express.js and all my static files are in a folder called public
AdamCS
@csikos3d
Aug 02 2017 11:21
Hi, if I use each() method on a json than I am receiving a list. Is it possible to handle the list elements indepentendly (append in different divs ). Here is my code what I want to change :
$.each(json, function (index, value) {
  $("#container").append(value.number +" "+ value.type + "; ");
cykins4good
@cykins4good
Aug 02 2017 11:22
Counting Cards   freeCodeCamp.jpg
Hi to you all i have stuck in this for a while now.Please do assist.
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 11:27
got this ```
<p class="Timer"><h2>Session</h2><span>00:25:00<span></p>
if I want change the content inside the span I have to go like this
   $(".Timer span").html("00:00:00");
right?
shivam gupta
@shivamg11000
Aug 02 2017 11:28

@Masd925 the example you gave myFriends is context here but if it is not passed like
in

[1,2,3].myFilter(val => val>3)

then what is context passed as to the myFilter function

Stephen James
@sjames1958gm
Aug 02 2017 11:32
@shivamg11000 undefined
shivam gupta
@shivamg11000
Aug 02 2017 11:32
it gives context undefined
@sjames1958gm yeah
Stephen James
@sjames1958gm
Aug 02 2017 11:32
@cykins4good increment count when card is 2-6 not return
Markus Kiili
@Masd925
Aug 02 2017 11:33
@shivamg11000 When myFilter is executed callback parameter holds the function func and context parameter holds myFriends array.
Michael Weiner
@mkw2000
Aug 02 2017 11:33
@tiagocorreiaalmeida give the span its own class or id and set the .html() of that
Stephen James
@sjames1958gm
Aug 02 2017 11:34
@csikos3d You could replace "#container" with something that depends on index such as "#container" + index
which would append to id="container0", id=container1", etc.
Markus Kiili
@Masd925
Aug 02 2017 11:35
@shivamg11000 If you do [1,2,3].myFilter(val => val>3), this would be [1,2,3], callback would be val => val>3, and context would be undefined, when myFilter is executed.
Stephen James
@sjames1958gm
Aug 02 2017 11:36
@cykins4good Also, you are missing space between count and Hold or Bet
AdamCS
@csikos3d
Aug 02 2017 11:39
@sjames1958gm thank You :-) Sounds great, I will try it immediately! :-)
CamperBot
@camperbot
Aug 02 2017 11:39
csikos3d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8222 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
cykins4good
@cykins4good
Aug 02 2017 11:41
Counting Cards   freeCodeCamp-1.jpg
@sjames1958gm I have changed it but it seems not working.
AdamCS
@csikos3d
Aug 02 2017 11:42
@sjames1958gm works great! thank You again! I fought with this at least for 4 hour :-)
CamperBot
@camperbot
Aug 02 2017 11:42
csikos3d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: csikos3d already gave sjames1958gm points
AdamCS
@csikos3d
Aug 02 2017 11:42
@sjames1958gm (and you have great avatar also ;-))
shivam gupta
@shivamg11000
Aug 02 2017 11:47
@Masd925 ok thanx @sjames1958gm
CamperBot
@camperbot
Aug 02 2017 11:47
shivamg11000 sends brownie points to @masd925 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4370 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 8223 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
shivam gupta
@shivamg11000
Aug 02 2017 11:55
next question the code for higher order react component not working
https://codepen.io/shivamg11000/pen/QMEYrv
hiteshthakur8888
@hiteshthakur8888
Aug 02 2017 12:49
Question:Your p element should contain the first few words of the provided additional kitty ipsum text. https://www.freecodecamp.org/challenges/change-the-font-size-of-an-element
hillsie
@Hillsie
Aug 02 2017 13:02
Hi there, could someone critique my code? This is the profile lookup problem.
https://gist.github.com/anonymous/ef454b216b7d8560a2fd3d1bfa54f655
Is there a better way to do it with a try: catch: block perhaps?
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:23
@Hillsie You have background in Java?
hillsie
@Hillsie
Aug 02 2017 13:23
Python
I guess that is a java construct
python is try: except: finally: … very small bit of Java
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:25
Here is jS way
function lookUpProfile(firstName, prop) {
  for(let i=0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop]
      } else {
        return 'No such property';
      }
    }
  }
  return 'No such contact';
};
hillsie
@Hillsie
Aug 02 2017 13:26
mmm, much nicer. Thanks @AdiSkywalker
CamperBot
@camperbot
Aug 02 2017 13:26
hillsie sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @adiskywalker |http://www.freecodecamp.com/adiskywalker
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:27
And here is slightly less efficient but cleaner example
function lookUpProfile(firstName, prop) {
  const contact = contacts.find( c => c.firstName === firstName);

  return contact ? contact.hasOwnProperty(prop) ? contact[prop] : 'No such property' : 'No such contact';
};
hillsie
@Hillsie
Aug 02 2017 13:28
why the use of const
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:28
@Hillsie Because you don't want to change reference of this variable.
you could just do let on it
hillsie
@Hillsie
Aug 02 2017 13:30
@AdiSkywalker thanks. Yes I have seen it used with const a few times. Let me play around with your previous example.
CamperBot
@camperbot
Aug 02 2017 13:30
hillsie sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
:warning: hillsie already gave adiskywalker points
hillsie
@Hillsie
Aug 02 2017 13:33
@AdiSkywalker I see you use === , I was wondering are there likely to be cases where == would fail?
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:34
@Hillsie Nope.. in this case it wouldn't fail
as both are strings
hillsie
@Hillsie
Aug 02 2017 13:34
:thumbsup:
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:34
but I got into practice of strict comparison as a standard development practice
hillsie
@Hillsie
Aug 02 2017 13:35
Yip, ta
hillsie
@Hillsie
Aug 02 2017 13:45
@AdiSkywalker I noticed in some js coders add (0); at the end of a function. Do you know why that is?
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:46
@Hillsie example?
hillsie
@Hillsie
Aug 02 2017 13:47
I thought you’d ask me that :) I’ll have to search and get back to you
If it doesn’t come immediately to mind, when I see it again I’ll post :)
Someone did explain it to me once, but at the time I didn’t do the dive into JS. Was something to do with security on the web. Don’t clearly recall, so never mind for now.
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:49
@Hillsie Are you referring to this pattern?
(function(){
  // some brilliant piece of code as follows
  return 2+2;
})();
hillsie
@Hillsie
Aug 02 2017 13:49
Yip
Darth Skywalker
@AdiSkywalker
Aug 02 2017 13:49
Its called an IIFE
Immediately Invoked Function Expression
(function(){}) is your function expression
an you invoke it immediately with trailing ()
It is used to create a namespace of sort
hillsie
@Hillsie
Aug 02 2017 13:51
aah, ok, thanks. I’ll do some more research into it.
a7n007
@a7n007
Aug 02 2017 13:55
function truthCheck(collection, pre) {
   for(var i=0;i<collection.length;i++)
    {
  if((!collection[i].hasOwnProperty(pre))||(collection[i].pre=="")||(collection[i].pre=="null")||(collection[i].pre=="NaN"));
    return false;
  }
    return true;
}

truthCheck([{"single": "yes"}], "single") ;
can anyone tell what is wrong with my code https://www.freecodecamp.org/challenges/everything-be-true
Stephen James
@sjames1958gm
Aug 02 2017 14:08
@a7n007 semi colon at end of if line
@a7n007 Also, review bouncy filter ("null" and "NaN" are strings not values)
Blauelf
@Blauelf
Aug 02 2017 14:10
  1. It's null and NaN, not "null" and "NaN"
  2. you cannot check for NaN like this, as NaN equals nothing not even itself
  3. You have a semicolon after your if, this is the empty statement and the only thing executed conditionally
  4. You don't check correctly for all truthy/falsy values. Use something like if (!collection[i].hasOwnProperty(pre) || !collection[i][pre]) to check for all at once.
BTW, []=="", with [] being truthy, while "" is falsy. So never use == unless you know what you do.
Stephen James
@sjames1958gm
Aug 02 2017 14:15
@a7n007 Also, .pre is wrong it should be [pre] as pre is a variable.
a7n007
@a7n007
Aug 02 2017 14:16
function truthCheck(collection, pre) {
   for(var i=0;i<collection.length;i++)
    {
  if((!collection[i].hasOwnProperty(pre))||collection[i][pre])
    return false;
  }
    return true;
}

truthCheck([{"single": "yes"}], "single") ;
still not working
Stephen James
@sjames1958gm
Aug 02 2017 14:16
@a7n007 You can reduce it down to if (!(collection[i][pre]))
your code need ! for the second condition
a7n007
@a7n007
Aug 02 2017 14:17
got it thanks
@sjames1958gm thanks
CamperBot
@camperbot
Aug 02 2017 14:17
a7n007 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8224 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 02 2017 14:18
@a7n007 :+1:
a7n007
@a7n007
Aug 02 2017 14:23
@Blauelf thanks
CamperBot
@camperbot
Aug 02 2017 14:23
a7n007 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4552 | @blauelf |http://www.freecodecamp.com/blauelf
AdamCS
@csikos3d
Aug 02 2017 14:34
Some one may can help me with this if statement? The else is working fine but the N/A part don't
if (json.length == 0){
    $("#container"+index).append("N/A");
  }else{  
    $("#container"+index).append( value.trainType + value.trainNumber);
       }
Ken Haduch
@khaduch
Aug 02 2017 14:44
@csikos3d - where does the index come from? Perhaps if there is no data in the json - there is no index value? Just a guess without seeing all of the code...
AdamCS
@csikos3d
Aug 02 2017 14:45
@khaduch
$.getJSON(sloUrl, function(json) {
$.each(json, function (index, value) {

  if (json.length == 0){
    $("#container"+index).append("N/A");
  }else{  
    $("#container"+index).append( value.trainType + value.trainNumber);
       }
});
Stephen James
@sjames1958gm
Aug 02 2017 14:47
@csikos3d If json.length == 0 then there is no each to loop over
AdamCS
@csikos3d
Aug 02 2017 14:47
@khaduch my gola to mark those cells what dont have data from the jason
Stephen James
@sjames1958gm
Aug 02 2017 14:48
@csikos3d json is an 'array', so you will not get into the loop for any that don't have data.
AdamCS
@csikos3d
Aug 02 2017 14:48
@sjames1958gm aham! make sense. But than I have no idea how to do this :-)
Ken Haduch
@khaduch
Aug 02 2017 14:48
@csikos3d - well, if there is no data, as @sjames1958gm points out, then you'll never get into the callback for the $.each()
you would just have to test for data first, and put a separate case to put the N/A value into the output?
Stephen James
@sjames1958gm
Aug 02 2017 14:50
@csikos3d Give them all a common class and before the loop
$(".commonclass").text("N/A")
Then the loop will override (I would change the loop from append to .text()
AdamCS
@csikos3d
Aug 02 2017 14:51
@khaduch sounds great :-) I am tring to figure it out how to do that. But honestly on my level this code start to get confusing so maybe I will not bother the things with this just leav the cells empty :-)
@sjames1958gm :-D oh my...that is so obvious..thank You again! :-)
CamperBot
@camperbot
Aug 02 2017 14:52
csikos3d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8225 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
AdamCS
@csikos3d
Aug 02 2017 14:52
@khaduch thank You, I will try to go for this :-)
CamperBot
@camperbot
Aug 02 2017 14:52
csikos3d sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3158 | @khaduch |http://www.freecodecamp.com/khaduch
Ene Catalin
@EneCatalin
Aug 02 2017 15:21
question: if my javascript doesn't execute in order (for some reason it executes my ajax function last) do I need to use a callback ?
Jason Luboff
@JLuboff
Aug 02 2017 15:21
@EneCatalin Your code is most likely running in order, but ajax is async, so it takes time to execute. While its executing, the rest of the code runs
Ene Catalin
@EneCatalin
Aug 02 2017 15:22
right, thanks
so how do I "wait" for it to execute ?
nvm
included it in the ajax itself
thanks @JLuboff
CamperBot
@camperbot
Aug 02 2017 15:23
enecatalin sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2124 | @jluboff |http://www.freecodecamp.com/jluboff
Darth Skywalker
@AdiSkywalker
Aug 02 2017 15:23
@EneCatalin You can simulate waiting either by callback or promise
Ene Catalin
@EneCatalin
Aug 02 2017 15:23
I just copied the last part of my function in the ajax and it worked
:D
Darth Skywalker
@AdiSkywalker
Aug 02 2017 15:24

included it in the ajax itself

Yes.. That's the representative of waiting :laughing:

Will Hawks
@willfalcon
Aug 02 2017 16:19
Yo… what does “pair program” mean? Just noticed in the js algorithm challenges, it throws that phrase there in the instructions…. “Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
Tony Brackins
@mrbrackins
Aug 02 2017 16:20
like, program with a partner @willfalcon
Will Hawks
@willfalcon
Aug 02 2017 16:20
Oooh
Tony Brackins
@mrbrackins
Aug 02 2017 16:20
yep. Checkout screen hero. multiple people can program at the same time etc
Sandun
@SandunWebDev
Aug 02 2017 16:24
hi, guys
FlashHero
@FlashHero
Aug 02 2017 16:24
anyone here knows nodejs
Jason Luboff
@JLuboff
Aug 02 2017 16:25
@FlashHero A bit. I'm working on the backend projects
Cody Seibert
@codyseibert
Aug 02 2017 16:26
@FlashHero I know nodejs, do you have a question?
Kelechi Chinaka
@ke1echi
Aug 02 2017 16:26
how do you see the ydkjs series @mrbrackins
FlashHero
@FlashHero
Aug 02 2017 16:27
@JLuboff @codyseibert do you know the difference between req.checkBody(),req.checkQuery()and req.assert() in express-validator
Jason Luboff
@JLuboff
Aug 02 2017 16:27
@kelechy https://github.com/getify/You-Dont-Know-JS You can read them all on this github
Kelechi Chinaka
@ke1echi
Aug 02 2017 16:28
have u read it @JLuboff
Jason Luboff
@JLuboff
Aug 02 2017 16:28
@FlashHero I've never used it, but looking at the code..
checkBody only checks req.body; none of the other req parameters
// Similarly checkParams only checks in req.params (URL params) and
// checkQuery only checks req.query (GET params).
@kelechy I've read the first book, and started the second one but got sidetracked
FlashHero
@FlashHero
Aug 02 2017 16:29
@JLuboff @codyseibert what is req.query, meaning what does query mean ?
Kelechi Chinaka
@ke1echi
Aug 02 2017 16:30
ok @JLuboff hows your backend projects going?
Jason Luboff
@JLuboff
Aug 02 2017 16:32
@FlashHero req.query is where query parameters would be stored such as in the url http://localhost:3000/api/?myquery=potato so
console.log(req.query.myquery); // potato
@kelechy They're coming along. Should be finishing up my Nightlife app today or tomorrow
My syntax for the query param url might be off. But thats the general idea
Cody Seibert
@codyseibert
Aug 02 2017 16:33
@FlashHero in express, there are three different ways to send data to the backend, in the body, in the query string, or as a parameter, so checkBody, checkQuery, and checkParam will check against one of those three
Tony Brackins
@mrbrackins
Aug 02 2017 16:33
@kelechy https://github.com/getify/You-Dont-Know-JS You can read them all on this github
Kelechi Chinaka
@ke1echi
Aug 02 2017 16:33
have you read it? @mrbrackins
Cody Seibert
@codyseibert
Aug 02 2017 16:34
it seems like req.assert will check all three
Tony Brackins
@mrbrackins
Aug 02 2017 16:34
I’ve done the first 3 so far @kelechy
Kelechi Chinaka
@ke1echi
Aug 02 2017 16:35
am i currently taking object and this...and its making my head spin :smile: @mrbrackins
Tony Brackins
@mrbrackins
Aug 02 2017 16:38
Yep, they’ll definitely be a reference for me. Because there’s a TON I didn’t understand lol @kelechy
like there was an example and they expect you to understand the example. And I just didn't
lol
but I just keep going anyway
haha
Sandun
@SandunWebDev
Aug 02 2017 16:40
Side Question : Anyone use Multi-Monitor setup for easier coding/learning process?
Jason Luboff
@JLuboff
Aug 02 2017 16:41
@SandunWebDev I have 3 monitors. Two horizantal, one vertical
Sandun
@SandunWebDev
Aug 02 2017 16:42
@JLuboff Cool. Same here. But all three monitors are horizontal.
Cody Seibert
@codyseibert
Aug 02 2017 16:43
1 monitor here, but many virtual desktops
less eye movement
Jason Luboff
@JLuboff
Aug 02 2017 16:43
I use the vertical for coding. I can see more
Pieter Stokkink
@forkerino
Aug 02 2017 16:45
:wave:
Jason Luboff
@JLuboff
Aug 02 2017 16:46
Morning (afternoon)!
Sandun
@SandunWebDev
Aug 02 2017 16:46
@JLuboff Yeah. Unfortunately my monitors external shape don't allow vertical sitting.
Pieter Stokkink
@forkerino
Aug 02 2017 16:47
I switched to Ubuntu on my new laptop and can't get the external screen to work
But multiple workspaces works.
Jason Luboff
@JLuboff
Aug 02 2017 16:47
@forkerino Does it have a supported video driver?
Pieter Stokkink
@forkerino
Aug 02 2017 16:48
@JLuboff it does, but I got both an intel and nvidia geforce chipset and somehow it messes everything up.
I tried a few ways to solve it, but couldn't get it to work, so I just got used to working on one screen for now.
My colleague is very good with Ubuntu, will ask him when he's back from holiday
Jason Luboff
@JLuboff
Aug 02 2017 16:49
I'd remove the intel driver or if you can specify the driver to default to the nvidia (its been a long time since I've played with Ubuntu)
Pieter Stokkink
@forkerino
Aug 02 2017 16:49
I can try that
later
when I'm not on a train
and actually have a second monitor
and second laptop to look up docs if needed
Jason Luboff
@JLuboff
Aug 02 2017 16:50
Lol
How's everything? Work, life, etc?
Pieter Stokkink
@forkerino
Aug 02 2017 16:51
but overall very happy with Ubuntu.
Work's a lot of fun, but the commute is killing me. Really need to find appropriate housing in the Hague soon
Life's good, too. Girlfriend and daughter are at her moms for a few weeks
so I have some time to think
and not be interrupted
every 3 seconds
Jason Luboff
@JLuboff
Aug 02 2017 16:53
You seem annoyed at being interrupted :D
Pieter Stokkink
@forkerino
Aug 02 2017 16:54
@JLuboff One of the things I learned when becoming a father was not to care too much about my own plans and to be okay with being interrupted, but it's been a bit much lately.
Very little downtime
Jason Luboff
@JLuboff
Aug 02 2017 16:54
I gotcha. Is the time to think in reference to what we spoke about a little while ago?
Pieter Stokkink
@forkerino
Aug 02 2017 16:55
@JLuboff all is good on that front.
I mean think more like having time to myself after working all day.
Jason Luboff
@JLuboff
Aug 02 2017 16:56
Glad to hear thats all good. But ya if you're working 8 hours a day, and have 3-4? hours of commute per day...thats a long day to then come home and not be able to relax some
Pieter Stokkink
@forkerino
Aug 02 2017 16:57
@JLuboff Indeed... how's the wife?
Daniel Romero
@Ranacode
Aug 02 2017 16:59
I have an error with CORS request from a XMlHttpRequest object, I'm trying to get data from the TV Maze api (it doesn't need an API key) and return me this error:
XMLHttpRequest cannot load http://api.tvmaze.com/shows. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5500' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
How can I add custom headers for this object?
Jason Luboff
@JLuboff
Aug 02 2017 17:00
Good! Started a new job this week (did orientation last thursday). She's liking it thus far. She'll get an actual maternity leave (3 months at 90% pay, and can take additional 2? months at 60%) which is awesome (and a lot less stressful for us in turn). She has nicknamed him Bam Bam as he is quite active throughout the night/day making sure she doesn't forget he is in there :joy:
Working full time again too
Daniel Romero
@Ranacode
Aug 02 2017 17:00
Ok nothing, I just fix it changing the boolean atribute of withCredentials to false xD
Pieter Stokkink
@forkerino
Aug 02 2017 17:01
@Ranacode :+1:
@JLuboff sounds good!
Jason Luboff
@JLuboff
Aug 02 2017 17:02
@forkerino Yup! And I'm on track for multiple raises over the next 6 months as I complete some certification tests which is going to make things much less stressful too
Pieter Stokkink
@forkerino
Aug 02 2017 17:05
@JLuboff ahhh, I'm happy for you!
Jason Luboff
@JLuboff
Aug 02 2017 17:06
@forkerino Thanks! We had a very good Wednesday last week haha. Still some other things we can't change (grandma's still in the hospital..) but we're making the best of what we have and what we can make
CamperBot
@camperbot
Aug 02 2017 17:06
jluboff sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2908 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Aug 02 2017 17:12
train's almost in Amsterdam. See you later!
Jason Luboff
@JLuboff
Aug 02 2017 17:12
Have a good one
forkerino @forkerino :train::train:
Pieter Stokkink
@forkerino
Aug 02 2017 17:12
:wave:
a7n007
@a7n007
Aug 02 2017 18:02
can anyone explain me how this below code is working
Nicholas Brown
@znicholasbrown
Aug 02 2017 18:02
Put ``` on separate lines
a7n007
@a7n007
Aug 02 2017 18:03
          function makeAdder(x) {
  return function(y) {
    return x + y;
  };
}

var add5 = makeAdder(5);
var add10 = makeAdder(10);

console.log(add5(2));  // 7
console.log(add10(2)); // 12
when i press enter it is posting the message
Nicholas Brown
@znicholasbrown
Aug 02 2017 18:06
You're essentially using a function which includes another function and passing it just one of the required variables with your declaration of var add5 or add10. Then the function completes when you pass it the second variable through your outside function. So it's holding the number in the declared variable (be it 5 or 10) and using that as the second number to add when you pass another number
a7n007
@a7n007
Aug 02 2017 18:07
is add5 a variable or a function
Nicholas Brown
@znicholasbrown
Aug 02 2017 18:08
Also you can press shift + enter to make a new line without sending
a7n007
@a7n007
Aug 02 2017 18:08
got it
Nicholas Brown
@znicholasbrown
Aug 02 2017 18:09
I'm sure there's a more technical answer to that, but it's a variable which is a function. When you call that variable, you're calling that function.
(I'm open to correction if anyone cares to elaborate)
a7n007
@a7n007
Aug 02 2017 18:11
and where does the make adder function store the value of x
i mean how does it take two values and execute them at a time
Nicholas Brown
@znicholasbrown
Aug 02 2017 18:13
The makeAdder function only has values when you pass them through add5 or add10. Otherwise it's just a function which takes two arguments.
a7n007
@a7n007
Aug 02 2017 18:15
sorry i didnt understand that
a7n007
@a7n007
Aug 02 2017 18:16
thanks @znicholasbrown
CamperBot
@camperbot
Aug 02 2017 18:16
a7n007 sends brownie points to @znicholasbrown :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @znicholasbrown |http://www.freecodecamp.com/znicholasbrown
AdamCS
@csikos3d
Aug 02 2017 18:17
I have a json kind of question: What should I do if i have to get out subsubsubsub attribut´s each attributs from the json ? I am understand i can navigat in the "path" like json.sub.sub[0].atribut... but what if I need not just the [0] but the [0][1][2][3][4] too?
a7n007
@a7n007
Aug 02 2017 18:21
@csikos3d use a for loop
Stephen James
@sjames1958gm
Aug 02 2017 18:23
@csikos3d
json.sub.sub.forEach(function(item) {});
AdamCS
@csikos3d
Aug 02 2017 18:24
@a7n007 thanks, I am trying with `each() in jquery but it is not working :-(
CamperBot
@camperbot
Aug 02 2017 18:24
csikos3d sends brownie points to @a7n007 :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @a7n007 |http://www.freecodecamp.com/a7n007
Nicholas Brown
@znicholasbrown
Aug 02 2017 18:25
@csikos3d You will have to make nested for loops to go more than one level down.
AdamCS
@csikos3d
Aug 02 2017 18:25
@sjames1958gm thank You again! :-D it was not working becaus i made it in a very bad way, but it looks much better :-D
CamperBot
@camperbot
Aug 02 2017 18:25
csikos3d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8226 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 02 2017 18:26
@a7n007 When you return the function, it "remembers" (google js closure) the context in which it was defined.
so it remembers the value of x.
@csikos3d :+1:
a7n007
@a7n007
Aug 02 2017 18:27
@a7n007 When you return the function, it "remembers" (google js closure) the context in which it was defined.
so it remembers the value of x. and will it retrieve the value when it is called again
right
a7n007
@a7n007
Aug 02 2017 18:36
https://www.freecodecamp.org/challenges/arguments-optional
can anyone please explain me how to approach this question
i didnt even understand how to take the args to above function
Muhammad Hasham
@MohammadHasham
Aug 02 2017 18:37
can anyone recommend me some good apps to make in redux
i have already made a inventory system
just to get a more solid grasp
ThePineal
@ThePineal
Aug 02 2017 18:45
im trying to add a fadeout and back in to a button for the quote machine, but whenever i try to add even just the fade-out, the button stops working
$(document).ready(function(){
  $("#newQuoteBtn").click(function(){
    randomNum();    
    $("#quote").fadeout(),
    //gets the random quote and author//
    $(".quote").html('<i class="fa fa-quote-left" aria-hidden="true"></i>' + quotes[quoteNum].quote),
    //image must be in quotes to actually work//
    $(".author").html("- " + quotes[quoteNum].author),
      //changes the colors of the background and buttons randomly//
    $("body, .btn-primary").css("background-color", bgColors[colorNum].bgColor),
      //changes the colors of the buttons on hover//
    $(".btn-primary").hover(function(){
      $(this).css("background-color", bgColors[colorNum].hoverColor);
    }, function(){
      $(this).css("background-color", bgColors[colorNum].bgColor);
    });
    //changes text to mach bgColor//
    $("h2, h5").css("color", bgColors[colorNum].bgColor);
  });  
});
Jason Luboff
@JLuboff
Aug 02 2017 18:47
@ThePineal It's fadeOut() not fadeout()
ThePineal
@ThePineal
Aug 02 2017 18:48
doh!
@JLuboff thanks
CamperBot
@camperbot
Aug 02 2017 18:48
thepineal sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2125 | @jluboff |http://www.freecodecamp.com/jluboff
ThePineal
@ThePineal
Aug 02 2017 18:55
how can i slow down my script? in the one i previously linked it fades in and out fine, but all of the other changes happen before its even faded out
how can i make it so .quote fades out, THEN changes colors, THEN fades back in?
Stephen James
@sjames1958gm
Aug 02 2017 18:59
@ThePineal .fadeOut( [duration ] [, complete ] )
You can provide a complete function (callback) that you can then take action when the fadeOut is complete, e.g. Change color and start fadeIn
Nicholas Brown
@znicholasbrown
Aug 02 2017 19:00
@ThePineal One of the arguments jQuery's .fadeOut() takes is a duration. Set that in milliseconds to determine the speed of the transition
Stephen James
@sjames1958gm
Aug 02 2017 19:00
@a7n007 You have to use arguments object to get the values passed in.
Use arguments.length to determine whether 1 or 2 values are passed in to the function
Nicholas Brown
@znicholasbrown
Aug 02 2017 19:02
@ThePineal for example: $('#quote').fadeOut(200);
You can also pass in "slow" or "fast" if you don't want to worry about manual transitions.
ThePineal
@ThePineal
Aug 02 2017 19:08
@sjames1958gm what do you mean by complete function?
and/or how to use the callback
Stephen James
@sjames1958gm
Aug 02 2017 19:08
@ThePineal It is a callback function that is called when the fadeOut is complete - complete is the name referenced in the jquery docs.
ThePineal
@ThePineal
Aug 02 2017 19:09
so complete is built in?
nevermind i just found the w3schools on callbacks
Stephen James
@sjames1958gm
Aug 02 2017 19:10
@ThePineal no, complete is just the parameter name.
$("#quote").fadeOut(400, () => {
   // you add code here that runs when the fade out is complete 
   // allows you to sequence effects, like fade out then fade in
})
ThePineal
@ThePineal
Aug 02 2017 19:10
lol and the example is literally something happening before the fade is done
kao720302
@kao720302
Aug 02 2017 19:23
can anyone check my code and tell me what did i do wrong please?
function calculateGrossPay() {
    itemRecord = openEmployeePayrollRecords();
    total = INITIAL_VALUE;

    while (itemRecord.readNextRecord()) {
        employeeHoursWorked = itemRecord.getEmployeeHoursWorked()
        employeeHoulyWage = itemRecord.getEmployeeHourlyWage();
        if (employeeHoursWorked > FULL_TIME) {
            total = employeeHoursWorked * (employeeHoulyWage +(employeeHoulyWage / 2));
        } else {
            totalt = employeeHoulyWage * employeeHoursWorked;
        }
        document.write(total + "\n");
    }

}
ThePineal
@ThePineal
Aug 02 2017 19:31
@sjames1958gm so ive changed my code, but the text still changes too fast, far as i can tell im doing it right
$(".quote").fadeOut("fast",function(){
      html('<i class="fa fa-quote-left" aria-hidden="true"></i>' + quotes[quoteNum].quote)}
      .fadeIn()
Christopher McCormack
@cmccormack
Aug 02 2017 19:40
@ThePineal 'fast' is 200ms, maybe try 'slow'? Do you have a pen?
monkeyfingerz
@monkeyfingerz
Aug 02 2017 19:42

function checkCashRegister(price, cash, cid) {
  var change;
  var penny = 0;
  var nickle = 0;
  var dime = 0;
  var quarter = 0;
  var one = 0;
  var five = 0;
  var ten = 0;
  var oneHundred= 0;

 var tcid= penny+nickle+dime+quarter+one+oneHundred; 
 var diff = tcid-price;
  for(var i =0; i<cid.length; i++){
  switch (cid[i][0]){
     case "PENNY": penny += cid[i][1]*100;
     break;
     case "NICKEL": nickle += Math.round(cid[i][1]*100)/5;
     break;
     case "DIME": dime += cid[i][1]*10;
     break;
     case "QUARTER": quarter += (cid[i][1]*100)/25;
     break;
     case "ONE" : one += cid[i][1]/1;
     break;
     case "FIVE": five += cid[i][1];
     break;
     case "TEN" : ten += cid[i][1];
     break;
     case "ONE HUNDRED": oneHundred += cid[i][1];
  }
  }
if(tcid < price){
  return one;
}else if (tcid === price) {
  return "Closed";
}else {

  return one.length;
}
}


checkCashRegister(19.50, 20.00, [["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]]);
Wh y can't i add the totals up to get the total amount of money in cash drawer?
ThePineal
@ThePineal
Aug 02 2017 19:43
@cmccormack i can see the quote change, then it fades out
then fades back in
Joseph
@revisualize
Aug 02 2017 19:44
@monkeyfingerz You know when you do this: var tcid= penny+nickle+dime+quarter+one+oneHundred; ... tcid is 0
@monkeyfingerz diff is = 0 - price
@monkeyfingerz So, why are you making those variables?
Aizaz Shahid
@aizazshahid
Aug 02 2017 19:45
@cmccormack @revisualize how are you ? :wave:
Joseph
@revisualize
Aug 02 2017 19:45
Sore.
monkeyfingerz
@monkeyfingerz
Aug 02 2017 19:45
@revisualize yeah i realize that why isn't it adding up in the tcid variable?
Christopher McCormack
@cmccormack
Aug 02 2017 19:46
@forwebtech hi long time!
Joseph
@revisualize
Aug 02 2017 19:46
@monkeyfingerz Where in your code do you modify the tcid value?

@monkeyfingerz Look at this code:

var a = 0;
var b = 0;
var c = 0;

var z = a+b+c;

What is the value of z?

0+0+0 = 0
Aizaz Shahid
@aizazshahid
Aug 02 2017 19:47
@cmccormack yeah, got busy in some stuff !
Joseph
@revisualize
Aug 02 2017 19:48

@monkeyfingerz

  var penny = 0;
  var nickle = 0;
  var dime = 0;
  var quarter = 0;
  var one = 0;
  var five = 0;
  var ten = 0;
  var oneHundred= 0;

 var tcid= penny+nickle+dime+quarter+one+oneHundred;

0+0+0+0+0+0 .... 0

monkeyfingerz
@monkeyfingerz
Aug 02 2017 19:48
@revisualize I think i see. It's because it is before the part of the function that populates the money variables
Aizaz Shahid
@aizazshahid
Aug 02 2017 19:49
@cmccormack but what's your progress here ?
Joseph
@revisualize
Aug 02 2017 19:49
Okay. It's lunch time for me. I need to jet.
@monkeyfingerz Good luck. :)
monkeyfingerz
@monkeyfingerz
Aug 02 2017 19:50
@revisualize thanks
CamperBot
@camperbot
Aug 02 2017 19:50
monkeyfingerz sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4400 | @revisualize |http://www.freecodecamp.com/revisualize
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 19:52
hey can you guys test my pen and point any error that you find? https://codepen.io/tiagocorreia/pen/LjGwmg
Stephen James
@sjames1958gm
Aug 02 2017 19:53
@ThePineal
 //gets the random quote and author////image must be in quotes to actually work// 
$(".quote").fadeOut("slow",function(){
      $(".quote").html('<i class="fa fa-quote-left" aria-hidden="true"></i>' + quotes[quoteNum].quote); 
     $(".quote").fadeIn()
});
$(".author").fadeOut("slow",function(){
          $(".author").html("- " + quotes[quoteNum].author)
        $(".author").fadeIn()
})
ThePineal
@ThePineal
Aug 02 2017 19:57
@sjames1958gm the timing is still off to me :/
Stephen James
@sjames1958gm
Aug 02 2017 19:58
@ThePineal There is a whole bunch of options http://api.jquery.com/fadeout/#fadeOut-options
ThePineal
@ThePineal
Aug 02 2017 20:00
i know, i dont exactly get how i would use them though :(
Christopher McCormack
@cmccormack
Aug 02 2017 20:01
@forwebtech not a ton, been working on react projects mostly
Aizaz Shahid
@aizazshahid
Aug 02 2017 20:03
well in that time i tried node.js and made one api : )
but it took 3 to 4 days, to complete.
Christopher McCormack
@cmccormack
Aug 02 2017 20:04
@forwebtech that doesn't seem so bad, I've been working on the same React project for almost two months :D
Stephen James
@sjames1958gm
Aug 02 2017 20:04
@ThePineal Here is the same code using the object instead, for the .quote
$(".quote").fadeOut({duration: "fast",
                     complete: function(){
                        $(".quote").html('<i class="fa fa-quote-left" aria-hidden="true"></i>' + quotes[quoteNum].quote);
                        $(".quote").fadeIn()}
   })
Jason Luboff
@JLuboff
Aug 02 2017 20:04
@cmccormack Two months? what a loser! ;)
Aizaz Shahid
@aizazshahid
Aug 02 2017 20:05
@cmccormack surely you don't have enough time, @JLuboff its not a loser he didn't loose anything but surely, gained.
Stephen James
@sjames1958gm
Aug 02 2017 20:05
@ThePineal You pass an object with the various configuration paramters
Jason Luboff
@JLuboff
Aug 02 2017 20:05
I'm just messing around :D
Aizaz Shahid
@aizazshahid
Aug 02 2017 20:05
@JLuboff but what about your progress on which section are you ?
Jason Luboff
@JLuboff
Aug 02 2017 20:06
Just finished my nightlife app. Just running through a few last things but it should be sufficient
Christopher McCormack
@cmccormack
Aug 02 2017 20:06
no I'm a loser he's right :D
I'm about 95% done though! https://mackville.net/react/dungeon
Nicholas Brown
@znicholasbrown
Aug 02 2017 20:14
@cmccormack that's my next project, yours is very impressive!
Christopher McCormack
@cmccormack
Aug 02 2017 20:14
@znicholasbrown thanks
CamperBot
@camperbot
Aug 02 2017 20:14
cmccormack sends brownie points to @znicholasbrown :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @znicholasbrown |http://www.freecodecamp.com/znicholasbrown
Nicholas Brown
@znicholasbrown
Aug 02 2017 20:15
Make sure the textbox with the dialogue autoscrolls to the bottom when new lines are added, probably the only issue I saw
Christopher McCormack
@cmccormack
Aug 02 2017 20:15
new status text appears on top not bottom
Nicholas Brown
@znicholasbrown
Aug 02 2017 20:17
Oh lol
Christopher McCormack
@cmccormack
Aug 02 2017 20:17
I could probably make that more clear
Nicholas Brown
@znicholasbrown
Aug 02 2017 20:19
I could also just be an idiot, now that you say it I can see it. Maybe some sort of small animation when the text appears? That would make it easier to separate new from old information
Christopher McCormack
@cmccormack
Aug 02 2017 20:20
yeah maybe, right now I just shift the new status onto an array and highlight just the first entry, super simple implmeentation that I haven't touched since
Jason Luboff
@JLuboff
Aug 02 2017 20:27
Here's my nightlife app if anyone wants to check it out https://nightlife-app.glitch.me/
Jim Tryon
@jimtryon
Aug 02 2017 20:33
@JLuboff No auto populating of cities in the search box?
Christopher McCormack
@cmccormack
Aug 02 2017 20:33
@JLuboff That's awesome! I recognize some of the places in my area, and know they are great places to go for a night out, so I think it's working!
Jason Luboff
@JLuboff
Aug 02 2017 20:34
@jimtryon No, not a requirement and not one I'd like to implement either lol
Jim Tryon
@jimtryon
Aug 02 2017 20:34
@JLuboff lol
Jason Luboff
@JLuboff
Aug 02 2017 20:34
@cmccormack :+1:
Jim Tryon
@jimtryon
Aug 02 2017 20:34
I thought it would be a nice touch is all
for those who typo a city
like I did with seattle
Jason Luboff
@JLuboff
Aug 02 2017 20:34
@jimtryon Thats true. Thank you for the suggestion, I may in the future implement it :)
CamperBot
@camperbot
Aug 02 2017 20:34
jluboff sends brownie points to @jimtryon :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @jimtryon |http://www.freecodecamp.com/jimtryon
Jason Luboff
@JLuboff
Aug 02 2017 20:34
@cmccormack Thank you also
CamperBot
@camperbot
Aug 02 2017 20:34
jluboff sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1096 | @cmccormack |http://www.freecodecamp.com/cmccormack
Jim Tryon
@jimtryon
Aug 02 2017 20:34
really clean and minimal design, I like it :)
Are you going to have a sign up feature?
I tried to login but it’s under development
Jason Luboff
@JLuboff
Aug 02 2017 20:36
Ya someone else pointed that out, I need to change something in facebook...should be working in a minute after I figure it out
Jim Tryon
@jimtryon
Aug 02 2017 20:37
@JLuboff Yeah, there are some places I’ve never even heard of on the list. Where do you pull the data?
Jason Luboff
@JLuboff
Aug 02 2017 20:38
@jimtryon Try logging in now. And it's pulled from the Yelp API
Jim Tryon
@jimtryon
Aug 02 2017 20:38
@JLuboff I was thinking Yelp API or Google API
It works now
Jason Luboff
@JLuboff
Aug 02 2017 20:40
:+1:
AdamCS
@csikos3d
Aug 02 2017 20:46
hi, What if i have to iterate throw url variations (string queries) to have the JSON values what I need. Can i define an JSON url with a "variable" ending?
Jason Luboff
@JLuboff
Aug 02 2017 20:46
Yes

You can either use string concatenation

var url = "http://myurl/whatever?=" + myVar;

or Template Strings/Literals

var url = `http://myurl/whatever?=${myVar};`
Guderian Raborg
@hypercuber
Aug 02 2017 20:48
I have a question. You can do 3d stuff with vanilla javscript but there is also three.js? So which one should I pick?
Stephen James
@sjames1958gm
Aug 02 2017 20:48
@csikos3d I would suggest template strings, they are becoming more and more common.
@hypercuber Pick three.js - written in vanilla js.
Jason Luboff
@JLuboff
Aug 02 2017 20:49
@sjames1958gm I :heart: template strings they make things much easier
Caleb David
@microworlds
Aug 02 2017 20:49

Hello please, I have a problem rendering a jade view. I have setup the view engine correctly because other pages are being rendered well, except for this piece of code. I want to render a new page after doing a very simple validation. the server just spits the html back to me, I am using angular js, here's my code below:

Client

// User sign in
        $scope.newUserInfo = {};
        $scope.sign_In = function(){
            $http.post('/api/newUserSignIn', $scope.newUserInfo).success(function(info){
                //console.log(info);
                //$scope.newUserInfo = null;
            });
        }

Server

//Sign in user to account
router.post('/newUserSignIn', function(req, res){
    var data = req.body;
    var id = data._id;

    //console.log(data);

    db.users.find({ "pass" : data.pass }).toArray(function(err, user){
        if (err) {
            res.json({"success" : false, "message": "Sorry, invalid username or email"});
        } else {
            res.render('user', {"user" : user});
            //res.json(user);
        }
    });
});

The code is responding with both json data and html as requested, but it is not being rendered. Any help would greatly be appreciated, thank you.

Stephen James
@sjames1958gm
Aug 02 2017 20:49
@JLuboff And for me much less error prone.
Jason Luboff
@JLuboff
Aug 02 2017 20:49
:+1:
Guderian Raborg
@hypercuber
Aug 02 2017 20:51
@sjames1958gm pros and cons?
Stephen James
@sjames1958gm
Aug 02 2017 20:51
@hypercuber You'll get more done quicker.
AdamCS
@csikos3d
Aug 02 2017 20:51
@sjames1958gm @JLuboff thank You guys :-) I will try both, thank again!
CamperBot
@camperbot
Aug 02 2017 20:51
csikos3d sends brownie points to @sjames1958gm and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2126 | @jluboff |http://www.freecodecamp.com/jluboff
:star2: 8227 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Guderian Raborg
@hypercuber
Aug 02 2017 20:52
@sjames1958gm since it is a library it is slower right?
I am just thinking of doing simple 3d puzzles and mazes
Stephen James
@sjames1958gm
Aug 02 2017 20:53
@hypercuber I am pretty sure that the people that developed the code have a good grasp
on the 3d technology and it is probably pretty well optimized.
Guderian Raborg
@hypercuber
Aug 02 2017 20:53
@sjames1958gm Okay, thanks for your help. Right now I am learning 2d stuff in canvas. Later want to start with 3d :)
CamperBot
@camperbot
Aug 02 2017 20:53
hypercuber sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8228 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 02 2017 20:54
I program in c++ I don't distinguish between vanilla c++ and using libraries.
Libraries are looked at, generally, as good tools to use, for some reason with javascript there is this weird
purist pechant.
Guderian Raborg
@hypercuber
Aug 02 2017 20:54
@sjames1958gm I used to work with p5.js and it would be slow
Caleb David
@microworlds
Aug 02 2017 20:57

Hello please, I have a problem rendering a jade view. I have setup the view engine correctly because other pages are being rendered well, except for this piece of code. I want to render a new page after doing a very simple validation. the server just spits the html back to me, I am using angular js, here's my code below:

Client

// User sign in
        $scope.newUserInfo = {};
        $scope.sign_In = function(){
            $http.post('/api/newUserSignIn', $scope.newUserInfo).success(function(info){
                //console.log(info);
                //$scope.newUserInfo = null;
            });
        }

Server

//Sign in user to account
router.post('/newUserSignIn', function(req, res){
    var data = req.body;
    var id = data._id;

    //console.log(data);

    db.users.find({ "pass" : data.pass }).toArray(function(err, user){
        if (err) {
            res.json({"success" : false, "message": "Sorry, invalid username or email"});
        } else {
            res.render('user', {"user" : user});
            //res.json(user);
        }
    });
});

The code is responding with both json data and html as requested, but it is not being rendered. Any help would greatly be appreciated, thank you.

Austin Wiggins
@austinwiggins
Aug 02 2017 20:58
cbot
CamperBot
@camperbot
Aug 02 2017 20:58
you called?
Caleb David
@microworlds
Aug 02 2017 20:59
cbot
CamperBot
@camperbot
Aug 02 2017 20:59
you called?
Caleb David
@microworlds
Aug 02 2017 20:59

Hello please, I have a problem rendering a jade view. I have setup the view engine correctly because other pages are being rendered well, except for this piece of code. I want to render a new page after doing a very simple validation. the server just spits the html back to me, I am using angular js, here's my code below:

Client

// User sign in
        $scope.newUserInfo = {};
        $scope.sign_In = function(){
            $http.post('/api/newUserSignIn', $scope.newUserInfo).success(function(info){
                //console.log(info);
                //$scope.newUserInfo = null;
            });
        }

Server

//Sign in user to account
router.post('/newUserSignIn', function(req, res){
    var data = req.body;
    var id = data._id;

    //console.log(data);

    db.users.find({ "pass" : data.pass }).toArray(function(err, user){
        if (err) {
            res.json({"success" : false, "message": "Sorry, invalid username or email"});
        } else {
            res.render('user', {"user" : user});
            //res.json(user);
        }
    });
});

The code is responding with both json data and html as requested, but it is not being rendered. Any help would greatly be appreciated, thank you.

@camperbot
Hello please, I have a problem rendering a jade view. I have setup the view engine correctly because other pages are being rendered well, except for this piece of code. I want to render a new page after doing a very simple validation. the server just spits the html back to me, I am using angular js, here's my code below:

Client

// User sign in
        $scope.newUserInfo = {};
        $scope.sign_In = function(){
            $http.post('/api/newUserSignIn', $scope.newUserInfo).success(function(info){
                //console.log(info);
                //$scope.newUserInfo = null;
            });
        }

Server

//Sign in user to account
router.post('/newUserSignIn', function(req, res){
    var data = req.body;
    var id = data._id;

    //console.log(data);

    db.users.find({ "pass" : data.pass }).toArray(function(err, user){
        if (err) {
            res.json({"success" : false, "message": "Sorry, invalid username or email"});
        } else {
            res.render('user', {"user" : user});
            //res.json(user);
        }
    });
});

The code is responding with both json data and html as requested, but it is not being rendered. Any help would greatly be appreciated, thank you.

CamperBot
@camperbot
Aug 02 2017 20:59
microworlds sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3378 | @camperbot |http://www.freecodecamp.com/camperbot
Stephen James
@sjames1958gm
Aug 02 2017 21:01
@microworlds You see the raw template file in the browser?
Moisés Man
@moigithub
Aug 02 2017 21:04

@microworlds

because other pages are being rendered well

can u show what code u use soo those pages gets rendered.. to compare

Caleb David
@microworlds
Aug 02 2017 21:04
@sjames1958gm Not exactly, but when I checked the "Network" tab, the response preview displays the html or the json depending on what I requested
Stephen James
@sjames1958gm
Aug 02 2017 21:05
@microworlds The html is there in the browser, but not rendered by angular?
Caleb David
@microworlds
Aug 02 2017 21:06
@sjames1958gm Exactly my point!!!
Stephen James
@sjames1958gm
Aug 02 2017 21:06
@microworlds I was thinking you meant that the .render function wasn't working.
Caleb David
@microworlds
Aug 02 2017 21:07
@moigithub This is the code for the other pages that are not requested using angular $http
router.get('/blogarea', isAuthenticated, function(req, res) {
  res.render('blogarea', { title: 'Admin' });
});
@sjames1958gm No, I tried using POSTMAN, it only spits the html too.
Moisés Man
@moigithub
Aug 02 2017 21:08
soo thats a browser request...
res.render spits html... n browsers gets back html which it can understand.. so it "renders well" @microworlds
AdamCS
@csikos3d
Aug 02 2017 21:09
@sjames1958gm I have to put the today date(dd-mm-yyyy) also at the end of the query string in the url. is there any human way to do that with template strings?
Moisés Man
@moigithub
Aug 02 2017 21:09
ur other case.. is not the same.. u originating request from http service.. u should pass json from ur server..and on client process that json, updating some angular $scope.variables, so angular can autorefresh client @microworlds
Jason Luboff
@JLuboff
Aug 02 2017 21:09
@csikos3d Yes you would put it inside of ${}
Caleb David
@microworlds
Aug 02 2017 21:11
@moigithub I want to load an entire new page after the $http service call. I didn't get you said please, can you correct my code please
AdamCS
@csikos3d
Aug 02 2017 21:14
@JLuboff yes thanks, sorry but i said wrongly. so my question is HOW to get the today date :-) I will define it in a variable and i will put the variable name in the ${} but i have no idea how to get the date in this simple format it seems rocket science according to google :-)
CamperBot
@camperbot
Aug 02 2017 21:14
csikos3d sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:warning: csikos3d already gave jluboff points
Jason Luboff
@JLuboff
Aug 02 2017 21:15
@csikos3d Personally..I like to use moment.js
@csikos3d Its a great library

@csikos3d With moment, you would have

moment().format("DD-MM-YYYY")

That would output the current date

In the format you want
AdamCS
@csikos3d
Aug 02 2017 21:20
@JLuboff thank you! this was great help! I never heard about this...:-/ I am working one project . In every hour i m thinking "ok it´s almost done" and every second hour turns out there is a twist again and again :-) so i feel a bit lost in every second hour :-)
CamperBot
@camperbot
Aug 02 2017 21:20
csikos3d sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:warning: csikos3d already gave jluboff points
Stephen James
@sjames1958gm
Aug 02 2017 21:21
@csikos3d You are getting the real feeling of being a developer
Jason Luboff
@JLuboff
Aug 02 2017 21:21
Thats programming :D
AdamCS
@csikos3d
Aug 02 2017 21:21
@sjames1958gm @JLuboff :-D
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 21:31
image.png
im creating a account in c9 like freecodecamp tells us to
should this be reeally asked or im doing it wrong?
Jason Luboff
@JLuboff
Aug 02 2017 21:32
@tiagocorreiaalmeida Yes it requires a credit card, but you don't have to use c9, you can do everything locally on your computer
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 21:32
aaaa ok :D but dont they ask links of the stuff further ?
Jason Luboff
@JLuboff
Aug 02 2017 21:33
The projects will be hosted on heroku
or you can alternatively use glitch
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 21:33
should I create a acc then in heroku?
Jason Luboff
@JLuboff
Aug 02 2017 21:34
You can but you won't need it until you start doing the projects.
Nicholas Brown
@znicholasbrown
Aug 02 2017 21:35
@cmccormack I just went and looked at the example project for the dungeon crawler and yours is loads better. Good job!
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 21:35
so here I have to do nothing?
image.png
or install node.js locally?
confusing to me sorry to bother you
Jason Luboff
@JLuboff
Aug 02 2017 21:36
Install node locally then you'll be able to run the commands from the node.js command prompt that gets installed
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 21:37
ok will give a try thanks once again, new to this
Jason Luboff
@JLuboff
Aug 02 2017 21:37
No problem
Tiago Correia
@tiagocorreiaalmeida
Aug 02 2017 21:47
image.png
:(
@JLuboff any idea?
Jason Luboff
@JLuboff
Aug 02 2017 21:48
Are you an admin on your computer?
I mean..you could just ignore it, its just saying it can't add a shortcut to your start menu.