These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Apr 2017
Jakub Kałamarz
@kkalamarz
Apr 20 2017 00:05
@revisualize Sorry, but i still have a problem
Joseph
@revisualize
Apr 20 2017 00:06
@kkalamarz You do.
Jakub Kałamarz
@kkalamarz
Apr 20 2017 00:06
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var 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";
    } 
  } else  {
    return "No such contact";
  }
  }
Joseph
@revisualize
Apr 20 2017 00:06
@kkalamarz Let me just state. This challenge isn't a simple answer challenge.
@kkalamarz Okay.
I know how to solve that problem.
@kkalamarz Let me show you some things.
Jakub Kałamarz
@kkalamarz
Apr 20 2017 00:07
when i add last else, the prop dont return
When i delete last else, it works well
Joseph
@revisualize
Apr 20 2017 00:07
@kkalamarz First off.
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead

@kkalamarz

for ( ..... ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }

This exact loop.. Does not loop.

Stephen James
@sjames1958gm
Apr 20 2017 00:07
@lpy1994 That was challenging when you had to consider unequal array length.
Joseph
@revisualize
Apr 20 2017 00:07
@kkalamarz
  // code before a for loop.
for (..........) {
  // Code inside of a for loop.
}
  // code after a for loop.
@kkalamarz You are NOT required to have all of your code inside of the for loop.
Cynthia
@cyanste
Apr 20 2017 00:15
Woah, I came in to ask about the same activity... I've been pulling my hair about it for two days
Jakub Kałamarz
@kkalamarz
Apr 20 2017 00:16
@cyanste Really hard...
Cynthia
@cyanste
Apr 20 2017 00:16
@kkalamarz I keep coming back to the same answer as you, as well... even after trawling google
EK Azubuike
@ekazubuike
Apr 20 2017 00:17
Hey everyone. CLOSURES ARE DRIVING ME CRAZY! I understand them generally (using the rules of scope to call a function outside of where it as declared). I'm at a complete loss when it comes to understanding how it works in for loops though. Here's an example: http://www.pythontutor.com/visualize.html#mode=display My understanding breaks down between steps 5 and 6. When add() is called, why does the computer sip over the variable declaration and move directly to executing the return function?
Cynthia
@cyanste
Apr 20 2017 00:18
I guess what got me was that looking up the name works without the return, but when you try to get to matching the prop, it says undefined
Jakub Kałamarz
@kkalamarz
Apr 20 2017 00:18
@cyanste It would be great to write loop: if (any.contacts !== contacts.firstname) { return „no contact”
@cyanste No propery - works fine; no contact - dont work at all
Cynthia
@cyanste
Apr 20 2017 00:24
for (var i = 0; i < contacts.length; i++){
  if (contacts[i].firstName == firstName){
    if(contacts[i].hasOwnProperty(prop)){
      return contacts[i].firstName + " " + contacts[i].prop;
    }
  }
}
that's as fas as I got. I noticed that when you look up the prop in the return, it seems like it's actually looking for "prop" rather than whatever you input
i'm just trying to troubleshoot what's appearing :worried:
Jakub Kałamarz
@kkalamarz
Apr 20 2017 00:28
@cyanste Look, at same prop, like likes: its an array.
Stephen James
@sjames1958gm
Apr 20 2017 00:33
@cyanste don't return the firstName property and .prop is wrong as prop is a variable
@ekazubuike Can you share the code?
Joseph
@revisualize
Apr 20 2017 00:35
@cyanste This return contacts[i].firstName + " " + contacts[i].prop; isn't a correct return statement.
@cyanste Also. re: contacts[i].prop ... Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Stephen James
@sjames1958gm
Apr 20 2017 00:36
@kkalamarz If you return when you match the firstName (prop or no such property) then you can only get to the end of the loop
if there is no firstName match.
@ekazubuike The link came up with blank editor
Dubsteppa4Life
@Dubsteppa4Life
Apr 20 2017 00:38

hi im having trouble converting celsius to fahrenheit, tried this code:

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit = celsius*(9/5)+35;
F = fahrenheit;
// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(-30);

doesnt seem to work

Luv Suneja
@chiz
Apr 20 2017 00:39
32?
Aizaz Shahid
@aizazshahid
Apr 20 2017 00:39
@Dubsteppa4Life its 32 not 35
Dubsteppa4Life
@Dubsteppa4Life
Apr 20 2017 00:39
oh dang you are both right thanks @chiz and thanks @forwebtech
CamperBot
@camperbot
Apr 20 2017 00:39
dubsteppa4life sends brownie points to @chiz and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @forwebtech |http://www.freecodecamp.com/forwebtech
:cookie: 284 | @chiz |http://www.freecodecamp.com/chiz
Dubsteppa4Life
@Dubsteppa4Life
Apr 20 2017 00:39
musta misread it
Manish Giri
@Manish-Giri
Apr 20 2017 00:40
@Dubsteppa4Life also, delete this - F = fahrenheit;
Dubsteppa4Life
@Dubsteppa4Life
Apr 20 2017 00:40
yeah will do, thanks @Manish-Giri
CamperBot
@camperbot
Apr 20 2017 00:40
dubsteppa4life sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5220 | @manish-giri |http://www.freecodecamp.com/manish-giri
Aizaz Shahid
@aizazshahid
Apr 20 2017 00:41
@Dubsteppa4Life its just:

function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  fahrenheit = (9/5) * celsius + 32;

  // Only change code above this line
  return fahrenheit;
}
other code is unnecessary !
Karan Nandha
@karann7
Apr 20 2017 00:43
@derhallim just type in the url to the private chat in your address bar if you click on my name it should update the address bar with the link then just press enter
Kyle Naumovski
@egnarodrinksOJ
Apr 20 2017 00:55
@revisualize Thx!
CamperBot
@camperbot
Apr 20 2017 00:55
egnarodrinksoj sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3790 | @revisualize |http://www.freecodecamp.com/revisualize
Louis Gagliano
@lgagliano41
Apr 20 2017 01:02
trouble with if else chains with switch challenge
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:02
@lgagliano41 yes !
show your code please !
Louis Gagliano
@lgagliano41
Apr 20 2017 01:03

function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "bob":
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1:
answer = "There is no #1";
break;
case 99:
answer = "Missed me by this much!";
break;
case 7:
answer = "Ate Nine";
break;
default:
answer= "empty string";
} return answer;
}

// Change this value to test
chainToSwitch(156);

Cynthia
@cyanste
Apr 20 2017 01:03
@revisualize TY
CamperBot
@camperbot
Apr 20 2017 01:03
cyanste sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3791 | @revisualize |http://www.freecodecamp.com/revisualize
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:04
@lgagliano41 what is the instruction ?
Louis Gagliano
@lgagliano41
Apr 20 2017 01:04
it works fine but wont let me continue
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:05
ok then copy your page and press reset button, and then try it
sorry code, first copy it
Jakub Kałamarz
@kkalamarz
Apr 20 2017 01:06
@sjames1958gm thanks
CamperBot
@camperbot
Apr 20 2017 01:06
kkalamarz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6828 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Louis Gagliano
@lgagliano41
Apr 20 2017 01:06
wont that foul up everything ive done so far
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:06
@lgagliano41 so copy your solution first and then reset the page and paste it, hope it will works
Louis Gagliano
@lgagliano41
Apr 20 2017 01:07
does reset only effect that page?
Dubsteppa4Life
@Dubsteppa4Life
Apr 20 2017 01:07
thanks @forwebtech
CamperBot
@camperbot
Apr 20 2017 01:07
dubsteppa4life sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: dubsteppa4life already gave forwebtech points
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:08
@Dubsteppa4Life You're Welcome !
Louis Gagliano
@lgagliano41
Apr 20 2017 01:08
im asking about the previous challanges
can anyone say will reset affect the previous challanges?
omarraza
@omarraza
Apr 20 2017 01:09

From the openweather API I'm trying to access some data and most of it is working except on piece. This is the sample JSON
http://samples.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=b1b15e88fa797225412429c1c50c122a1

function(data) {
      $("#city").html(data.name + ", " + data.sys.country);
      $("#temp").html(Math.floor(data.main.temp - 273.15) + " C");
      $("#sky").html(data.weather[2]);
    });
  }

the jQuery line with #sky isn't working. I've tried data.weather.description and data.weather[2] (since weather looks to be an array in the JSON) but neither is working

Aizaz Shahid
@aizazshahid
Apr 20 2017 01:09
no its just for that page only
Moisés Man
@moigithub
Apr 20 2017 01:13
@omarraza if weather is an array.. how many elements it have ??
if u not sure HOW that data is structured.. u should use console.log to inspect it
OR install json viewer addon in ur browser and open that api url there
omarraza
@omarraza
Apr 20 2017 01:14
I do use a json viewer
oh are you saying that weather is an array with 1 object inside of it
so the call should be data.weather[0].description ?
Moisés Man
@moigithub
Apr 20 2017 01:15
  "weather": [
    {
      "id": 800,
      "main": "Clear",
      "description": "clear sky",
      "icon": "01n"
    }
  ],
if weather have only 1 element
$("#sky").html(data.weather[2]); <---will fail (u accessing the 3rd element )
omarraza
@omarraza
Apr 20 2017 01:16
@moigithub got it, thank you!
CamperBot
@camperbot
Apr 20 2017 01:16
:star2: 3133 | @moigithub |http://www.freecodecamp.com/moigithub
omarraza sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Cynthia
@cyanste
Apr 20 2017 01:21
@revisualize again... TY, I couldn't figure out the "No such contact" until I scrolled up and read your prev response. Finally got this Profile Lookup complete. :+1: :fire:
CamperBot
@camperbot
Apr 20 2017 01:21
cyanste sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: cyanste already gave revisualize points
sagarnayak
@sagarnayak
Apr 20 2017 01:22
any one have done the Counting Cards challenge !!!
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:22
@sagarnayak yes ?
sagarnayak
@sagarnayak
Apr 20 2017 01:23
so what its saying to do ??? what does the card variable contain ..?? @forwebtech
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:23

well, read this

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

Vikrant Singh
@VikrantSingh13
Apr 20 2017 01:24
anyone who did the react projects, what resources did you use to learn the library?
sagarnayak
@sagarnayak
Apr 20 2017 01:24
yes . thats what written . but i am unable to get it . let the card is 2 . then what ??? what will happen ?? @forwebtech
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:25
ok first make a switch statement that will accept the value of card
and make it by looking through the given table in that task !
sagarnayak
@sagarnayak
Apr 20 2017 01:26
so if card is 2 then the result is bet .??
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:27
and at the top there is a global variable named count, when user calls the function so it will increment / decrement it as per the value of card
sagarnayak
@sagarnayak
Apr 20 2017 01:27
so if its 2 and 3 . the count is +2 . and the result is 2 Bet ??
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:28
no , the bet and hold decision is take through the count variable
sagarnayak
@sagarnayak
Apr 20 2017 01:28
ohhk . got it . thanks @forwebtech
CamperBot
@camperbot
Apr 20 2017 01:28
sagarnayak sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @forwebtech |http://www.freecodecamp.com/forwebtech
Steven
@Ironwrangler
Apr 20 2017 01:29
is there a way to start the course over from scratch .i had some issues and would like to go back to the beginning
Luke LaValva
@LuLaValva
Apr 20 2017 01:29
var Person = function(firstAndLast) {
  getNames(firstAndLast);

  var firstName,lastName,fullName;
  function getNames(firstAndLast){
    fullName=firstAndLast;
    firstName=firstAndLast.substring(0,firstAndLast.indexOf(" "));
    lastName=firstAndLast.substring(firstAndLast.indexOf(" ")+1);
  }

  function fullNameCheck(){
    fullName=firstName+" "+lastName;
  }

  return {
    getFirstName: function(){
      return firstName;
    },
    getLastName: function(){
      return lastName;
    },
    getFullName: function(){
      return fullName;
    },

    setFirstName: function(name){
      firstName=name;
      fullNameCheck();
    },
    setLastName: function(name){
      lastName=name;
      fullNameCheck();
    },
    setFullName: function(name){
      getNames(name);
    }
  };
};

var bob = new Person('Bob Ross');
bob instanceof Person;
I don't understand why bob instanceof Person returns false
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:29
@Ironwrangler sure! freecodecamp.com/map
visit that !
Steven
@Ironwrangler
Apr 20 2017 01:30
@forwebtech ty
CamperBot
@camperbot
Apr 20 2017 01:30
ironwrangler sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @forwebtech |http://www.freecodecamp.com/forwebtech
shiva prasad reddy
@WaysToGo
Apr 20 2017 01:30
@Ironwrangler else u can delete and start over again
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:30
@Ironwrangler You're welcome!
don't need to delete if we select from map its always starts new !
Christoffer Back
@backchristoffer
Apr 20 2017 01:34
Having trouble with solution:
Generate Random Whole Numbers with JavaScript . I can't figure out what to do or in what order really.
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:34
@backchristoffer yes !
@backchristoffer as you know Math.random() always create decimal values
@backchristoffer so you have to use the function named Math.floor( code )
it will round off your random number !
stevemax22
@stevemax22
Apr 20 2017 01:36
Need help with Test Objects for Properties challenge. Can anyone assist?
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:36
@stevemax22 sure !
can you please show the code !
stevemax22
@stevemax22
Apr 20 2017 01:36

@forwebtech
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
myObj.checkProp("gift");
myObj.checkProp("kitten");
return "Not found";
}

// Test your code by modifying these values
checkObj("gift");

Aizaz Shahid
@aizazshahid
Apr 20 2017 01:36
cbot code format guide please
CamperBot
@camperbot
Apr 20 2017 01:36
you called?
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:37
code format find
find code format
CamperBot
@camperbot
Apr 20 2017 01:37
find code format
nothing found
Christoffer Back
@backchristoffer
Apr 20 2017 01:37
@forwebtech yes and I can't figure out how to write that code.
Manish Giri
@Manish-Giri
Apr 20 2017 01:37
'''
CamperBot
@camperbot
Apr 20 2017 01:37
:bulb: to format code use backticks! ``` more info
Manish Giri
@Manish-Giri
Apr 20 2017 01:37
read the link
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:37
@Manish-Giri thanks !
CamperBot
@camperbot
Apr 20 2017 01:37
forwebtech sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5223 | @manish-giri |http://www.freecodecamp.com/manish-giri
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:37
@stevemax22 what is the instruction ?
stevemax22
@stevemax22
Apr 20 2017 01:38
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:39
@stevemax22 well steve to check the property we have arr.hasOwnProperty()
syntax
Manish Giri
@Manish-Giri
Apr 20 2017 01:39
@stevemax22 do you know what you're doing?
myObj.checkProp("gift");
myObj.checkProp("kitten");
what is .checkProp?
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:39
yes combine it into if else statement
stevemax22
@stevemax22
Apr 20 2017 01:40
@Manish-Giri .checkProp was in the instructions. I had just assumed it was to be used? No I don't quite know what I'm doing
Manish Giri
@Manish-Giri
Apr 20 2017 01:40
@stevemax22 no
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:40
@stevemax22 that func. isn't available
Manish Giri
@Manish-Giri
Apr 20 2017 01:40
@stevemax22 function checkObj(checkProp) {
checkProp is just the value passed in when the function is called, like gift or kitten
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:40
as far as i know !
Manish Giri
@Manish-Giri
Apr 20 2017 01:41
you need .hasOwnProperty() to check if a property exists
anderson
@anderson2825
Apr 20 2017 01:41
How to calculate the product of i ???
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:42
@anderson2825 didn't get you ?
anderson
@anderson2825
Apr 20 2017 01:42

function factorialize(num) {
var numa=num;
for(var i=1;i<numa; i++){
console.log(i);
}
return num;
}

factorialize(5);

stevemax22
@stevemax22
Apr 20 2017 01:42
@Manish-Giri @forwebtech So I get it now. .hasOwnProperty is a function within Java. But now, when I put that in, it still doesn't do me good. I'm doing something wrong here.
anderson
@anderson2825
Apr 20 2017 01:43
@forwebtech please help me check it?? thanks!
CamperBot
@camperbot
Apr 20 2017 01:43
:cookie: 264 | @forwebtech |http://www.freecodecamp.com/forwebtech
anderson2825 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Apr 20 2017 01:43
@stevemax22 did you add the if/else too
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:43
@anderson2825 so you need to make a factorial !
multiply and add your variable num with i iterator
syntax num = num * i;
anderson
@anderson2825
Apr 20 2017 01:44
ok ,thanks! @forwebtech
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:45
@anderson2825 You're welcome !
stevemax22
@stevemax22
Apr 20 2017 01:45

@Manish-Giri function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty("gift");
myObj.hasOwnProperty("pet");

if (checkObj = "house");
return "Not found";
}

Christoffer Back
@backchristoffer
Apr 20 2017 01:46
@forwebtech how do I use random and floor?
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:46
Math.floor(Math.random());
Luke LaValva
@LuLaValva
Apr 20 2017 01:48
Can anybody help me with instanceof?
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:48
@stevemax22 steve you did it wrong, because function name shouldn't came there
Manish Giri
@Manish-Giri
Apr 20 2017 01:49

@stevemax22 so here

myObj.hasOwnProperty("gift");
myObj.hasOwnProperty("pet");

if your function is called 100 times with values like box or tray, you'll have 100 more of these statements?

Christoffer Back
@backchristoffer
Apr 20 2017 01:49
@forwebtech but it's already used in a variable, so I should create one again and? I don't know..
stevemax22
@stevemax22
Apr 20 2017 01:49
@forwebtech I don't even have an if/return for those objects. Is this what you're getting at?
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:51
yes you can use it !
or if it is already initialized in variable then just you have to call it at the return statement. @backchristoffer
@stevemax22 you have to use if else to check for that conditions because if that true then you have to print that property also !
Christoffer Back
@backchristoffer
Apr 20 2017 01:52
@forwebtech that's what I did at first but it still says that I have to use Math.random and *.floor
Caleb
@calebxblackwell
Apr 20 2017 01:52
I need help with Global Scope and Functions. :)
Joseph
@revisualize
Apr 20 2017 01:52
la la la la la la
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:52
@backchristoffer paste your code !
Christoffer Back
@backchristoffer
Apr 20 2017 01:53

""var randomNumberBetween0and19 = Math.floor(Math.random() * 10);

function randomWholeNum() {

// Only change code below this line.

return randomNumberBetween0and19;
}
""

Aizaz Shahid
@aizazshahid
Apr 20 2017 01:53
```
Manish Giri
@Manish-Giri
Apr 20 2017 01:53
@stevemax22 first thing, you need to use checkProp, forget individual properties like gift or pet
Joseph
@revisualize
Apr 20 2017 01:54
Using variables for storing values ... THAT"S CRAZY!
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:54
function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random());
}
@backchristoffer
thats it !
Christoffer Back
@backchristoffer
Apr 20 2017 01:57
@forwebtech but I did just that
Aizaz Shahid
@aizazshahid
Apr 20 2017 01:58
what is the error ??
@backchristoffer my bad !
because Math.random() creates number between 0 to 1 (but less than 1)
so the round off makes it always zero, now just multipl that random number by 10, and then round off it !
David Miller
@DavidMillerFL
Apr 20 2017 02:00
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (1) {
case 1:
  answer="alpha";
      break;
case 2:
   answer="beta";
   break;
  }

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

// Change this value to test
caseInSwitch(1);
Any hints guys? I can’t get answer to = “beta” using switches.
Christoffer Back
@backchristoffer
Apr 20 2017 02:00
@forwebtech using the existing value stored in the variable should've done that already
Karan Nandha
@karann7
Apr 20 2017 02:01
who wants to code along and build a weather app in node, express.
gonna start in 5 mins on hangouts
Joseph
@revisualize
Apr 20 2017 02:01
@DavidMillerFL You should use the parameter.
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:01
@backchristoffer but that is * by 20
return Math.floor(Math.random()*10);
use that
Joseph
@revisualize
Apr 20 2017 02:01
@DavidMillerFL switch (1) is always passing 1 through the switch.
Christoffer Back
@backchristoffer
Apr 20 2017 02:01
@forwebtech I did use that in the beginning, I just changed it from 20 to 10
David Miller
@DavidMillerFL
Apr 20 2017 02:01
@revisualize Hmm.. I’ll try making the switch… empty. I get what you’re saying lol.
Thank you @revisualize
CamperBot
@camperbot
Apr 20 2017 02:02
davidmillerfl sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3792 | @revisualize |http://www.freecodecamp.com/revisualize
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:02
@backchristoffer the above one is just for example !
Christoffer Back
@backchristoffer
Apr 20 2017 02:02
@forwebtech huge thank you for helping me.
CamperBot
@camperbot
Apr 20 2017 02:02
backchristoffer sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:02
:sparkles:
Welcome !
David Miller
@DavidMillerFL
Apr 20 2017 02:02
Yeah!!!!!
Joseph
@revisualize
Apr 20 2017 02:02
@DavidMillerFL making the switch empty ... well then your switch will never run.
David Miller
@DavidMillerFL
Apr 20 2017 02:02
I set it to val
Christoffer Back
@backchristoffer
Apr 20 2017 02:03
@forwebtech ye so you see my problem when I don't understand what's wrong at first. My head wants to change that code and be done with it.
Joseph
@revisualize
Apr 20 2017 02:03
@DavidMillerFL Do you know why you're setting it to val?
Caleb
@calebxblackwell
Apr 20 2017 02:03
Can anyone help me with "Global scope and functions" challenge?
David Miller
@DavidMillerFL
Apr 20 2017 02:03
@revisualize Let me read the code and try to make some kind of sense about it. Sec.
Stephen James
@sjames1958gm
Apr 20 2017 02:04
@calebxblackwell What do you have?
David Miller
@DavidMillerFL
Apr 20 2017 02:05

It’s a bit difficult for me to articulate it but here goes.

function caseInSwitch(val)

has a parameter (I think that’s what it’s called) of

val
Joseph
@revisualize
Apr 20 2017 02:05
@DavidMillerFL yup
@DavidMillerFL That's correct.
Caleb
@calebxblackwell
Apr 20 2017 02:06
@sjames1958gm I'm supposed to use var to declare a global variable myGlobal outside of a function, initializing it with a value of 10. Also supposed to assign 5 to oopsglobal inside fun1 (code to follow)
Stephen James
@sjames1958gm
Apr 20 2017 02:06
@calebxblackwell k
David Miller
@DavidMillerFL
Apr 20 2017 02:06

So, the

switch

is set to (val) to control that parameter. Right? If I set it to 1, it’ll set it to 1 every time.

Caleb
@calebxblackwell
Apr 20 2017 02:06

// Declare your variable here
var myGlobal = ["myGlobal", 10];

function fun1() {
// Assign 5 to oopsGlobal Here
var output = "";
if (typeof oopsGlobal != "undefined"){
output += "oopsGlobal: " +oopsGlobal;
}
console.log(output);
}

Aizaz Shahid
@aizazshahid
Apr 20 2017 02:06
@DavidMillerFL yes thats why you have to put an variable as argument there !
Caleb
@calebxblackwell
Apr 20 2017 02:07
@sjames1958gm I really have no clue about how to assign 5 to oopsglobal.
Stephen James
@sjames1958gm
Apr 20 2017 02:07
@calebxblackwell You way overdid this - you need to assign myGlobal to 10
and assign 5 oopsGlobal
All that extra code is not needed
Joseph
@revisualize
Apr 20 2017 02:07
@DavidMillerFL That's all correct.
Stephen James
@sjames1958gm
Apr 20 2017 02:07
@calebxblackwell How do you assign 7 to a?
Caleb
@calebxblackwell
Apr 20 2017 02:07
@sjames1958gm just overthinking I guess.
@sjames1958gm var myGlobal = ["a", 7]
Stephen James
@sjames1958gm
Apr 20 2017 02:08
@calebxblackwell a = 7
David Miller
@DavidMillerFL
Apr 20 2017 02:08
@revisualize I didn’t originally think to change switch to val, because in the example it said “num”. In my mind that meant create a switch for each number.
Stephen James
@sjames1958gm
Apr 20 2017 02:08
@calebxblackwell So how do you assign 5 to oopsGlobal?
Caleb
@calebxblackwell
Apr 20 2017 02:08
oopsGlobal = 5?
Stephen James
@sjames1958gm
Apr 20 2017 02:09
@calebxblackwell Simple as that - and for myGlobal to 10?
David Miller
@DavidMillerFL
Apr 20 2017 02:09
@revisualize
Here’s the example. Bit of a curveball. I guess I think too literal sometimes.
switch (num) {
  case value1:
    statement1;
    break;
Caleb
@calebxblackwell
Apr 20 2017 02:09
myGlobal = 10. Let me try really quick ok? @sjames1958gm
Stephen James
@sjames1958gm
Apr 20 2017 02:09
@DavidMillerFL MDN page on switch has some good examples -
@calebxblackwell Don't forget the var for myGlobal
Caleb
@calebxblackwell
Apr 20 2017 02:10
@sjames1958gm nailed it. overthinking it as usual. Thank you.
CamperBot
@camperbot
Apr 20 2017 02:10
calebxblackwell sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6829 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 20 2017 02:11
@calebxblackwell :+1:
Joseph
@revisualize
Apr 20 2017 02:11
@DavidMillerFL but, is num a variable in your function?
cbot
CamperBot
@camperbot
Apr 20 2017 02:14
you called?
Joseph
@revisualize
Apr 20 2017 02:15
@camperbot You smell of rusted bolts and your mother was a toaster!
Laura Veee
@Cyclokitty
Apr 20 2017 02:17
lol
Joseph
@revisualize
Apr 20 2017 02:21
I should make a script that randomly insults @camperbot
Laura Veee
@Cyclokitty
Apr 20 2017 02:22
That would be fun. I made a rude cat bot for Slack.
@revisualize Which one? I'm a sap for udemy coupons.
宓树权
@stephen-mi
Apr 20 2017 02:27
How to do "Escape Sequences in Strings"
Joseph
@revisualize
Apr 20 2017 02:27
@Cyclokitty I just realized I was thinking of someone else.
@stephen-mi What code do you have?
Laura Veee
@Cyclokitty
Apr 20 2017 02:27
@revisualize No worries. I took his first course and it was good.
Joseph
@revisualize
Apr 20 2017 02:28
Ahh. I paid for the first one. I haven't completed it.
宓树权
@stephen-mi
Apr 20 2017 02:28
My English is bad
Jose Diaz
@jsd540
Apr 20 2017 02:28
He, everyone, how do I paste a clip of my code? I have been trying to figure this out and can only get the first 3 tests to pass.
Joseph
@revisualize
Apr 20 2017 02:28
@stephen-mi Show .. me ... code
Laura Veee
@Cyclokitty
Apr 20 2017 02:28
@revisualize Colt Steeles Web Dev Bootcamp is even more complete.
宓树权
@stephen-mi
Apr 20 2017 02:28
var myStr; // Change this line
myStr = "\t "+"\b "+"\r "+"\n";
Joseph
@revisualize
Apr 20 2017 02:28
@jsd540 Copy and Paste?
@stephen-mi That isn't the correct string.
You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
宓树权
@stephen-mi
Apr 20 2017 02:29
I don't know to do
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:29
@jsd540 copy and paste as per normal text
Joseph
@revisualize
Apr 20 2017 02:30
@stephen-mi You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n \\ SecondLine backslash carriage-return ThirdLine
George Yammine
@Yammine94
Apr 20 2017 02:30
hey would anyone be willing to tell me whats wrong with my function real quick?

var count = 0;
function cc(card) {
for( var i = 0; i < card.length; i++){
if( 2<= card[i] <=6 ){
count += 1;
} else
if( 7<= card [i]<=9 ){
count += 0;
} else
if( card[i] === 10 || card[i]==="K" ||card[i]==="A" || card[i]==="Q" ||card[i]=== "J"){
count = count - 1;
}
}

     if(count > 0){
       return count.toString() + " Bet";
     }


    if(count <= 0){
       return count.toString() + " Hold";
     }

}

宓树权
@stephen-mi
Apr 20 2017 02:32
@revisualize thank you
CamperBot
@camperbot
Apr 20 2017 02:32
stephen-mi sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3793 | @revisualize |http://www.freecodecamp.com/revisualize
George Yammine
@Yammine94
Apr 20 2017 02:32
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Joseph
@revisualize
Apr 20 2017 02:32
@Yammine94 card.length is always 1
@Yammine94 card isn't an array.
@Yammine94 Are you turning card into an array?
George Yammine
@Yammine94
Apr 20 2017 02:33
so the sequence tests means that it is just running the function over again for each card input?
I did this assuming it was not an array and it did not work
Joseph
@revisualize
Apr 20 2017 02:33
@Yammine94 ; is a statement terminator in JS
@Yammine94 So, it is 5 different function calls.
Jose Diaz
@jsd540
Apr 20 2017 02:34
@Yammine94 no need to convert the count to string
George Yammine
@Yammine94
Apr 20 2017 02:34
alright I will make the quick fixes and paste it back right away.
Jose Diaz
@jsd540
Apr 20 2017 02:34
@revisualize Thanks...
CamperBot
@camperbot
Apr 20 2017 02:34
jsd540 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3794 | @revisualize |http://www.freecodecamp.com/revisualize
George Yammine
@Yammine94
Apr 20 2017 02:35
these are changes I made after what I assumed would work didnt
@revisualize Thanks...
CamperBot
@camperbot
Apr 20 2017 02:35
yammine94 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3795 | @revisualize |http://www.freecodecamp.com/revisualize
Edward GG
@obamaanakbsi
Apr 20 2017 02:35
hey.. anyone can teach me how to use math.random??
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:35
Math.random generates a number between 0 and 1
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:36
Who's done the random quote project? Where did you store your quotes? Did you just make objects?
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:36
@obamaanakbsi what about it that you don't understand
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:36
massive switch? array of strings?
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:36
@sevensixtwo762 you get it from API
ROBUSTO8
@ROBUSTO8
Apr 20 2017 02:36

quick question why does this return "6" instead of [10, 20, 30, 30, 40, 50]? :

function getIndexToIns(arr, num) {
arr = arr.sort(function(a, b) {
return a-b;
});

return arr.push(num);
}

getIndexToIns([40, 60], 50);
getIndexToIns([10, 20, 30, 40, 50], 30);

Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:36
@sevensixtwo762 you will get an array of JS objects
Edward GG
@obamaanakbsi
Apr 20 2017 02:37
if there is to generate romdom between 1 and 0... so why must use it??
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:37
what api? I don't see anything about a quote api on the project description.
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:37
i guess you could also make your own
one data structure you can use is an array of JS objects
Joseph
@revisualize
Apr 20 2017 02:38
@obamaanakbsi Is it in the video?
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:38
Did you do this one already?
Joseph
@revisualize
Apr 20 2017 02:38
I haven't.
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:38
@obamaanakbsi you use it when u need a random number
@sevensixtwo762 me? i think so
Edward GG
@obamaanakbsi
Apr 20 2017 02:39
duno...
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:39
I'd better have. I have my frontend certification hahaha
Edward GG
@obamaanakbsi
Apr 20 2017 02:39
@revisualize duno...
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:39
thanks @kuriakinzeng
CamperBot
@camperbot
Apr 20 2017 02:39
sevensixtwo762 sends brownie points to @kuriakinzeng :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @kuriakinzeng |http://www.freecodecamp.com/kuriakinzeng
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:40
@obamaanakbsi i don't understand your question
Joseph
@revisualize
Apr 20 2017 02:44
@sevensixtwo762 Is the info in the Video?
@obamaanakbsi That was a miss send. It was supposed to go to @sevensixtwo762
Jose Diaz
@jsd540
Apr 20 2017 02:44
@ROBUSTO8 it looks like you are returning the push, I think you should push and then return the array
ROBUSTO8
@ROBUSTO8
Apr 20 2017 02:45
yeah i just realized thanks @jsd540
CamperBot
@camperbot
Apr 20 2017 02:45
robusto8 sends brownie points to @jsd540 :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @jsd540 |http://www.freecodecamp.com/jsd540
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:45
I'm wondering how people got their quotes. I saw @kuriakinzeng 's, but I'm going to try for something a bit more.
@revisualize I don't think so. I didn't see anything about using an api, and @kuriakinzeng used a few js objects, so I guess whatever I need to do is the way to go.
I was looking in to using the fortune database earlier.
apparently there's fortune.js which made searching for a fortune database's json api harder
Kuriakin Zeng
@kuriakinzeng
Apr 20 2017 02:48
I would get it from API, but codepen is a pain to work with for ajax requests sometimes
George Yammine
@Yammine94
Apr 20 2017 02:48
Can someone please tell me why my code is not working?

var count = 0;

function cc(card) {
if( 2<= card <=6 ){
count += 1;
}
if( 7<= card <=9 ){
count += 0;
}
if( 10<= card || "K" ||"A" || "Q" || "J"){
count -= 1;
}

return count <= 0 ? count + " Hold": count + " Bet";

// Only change code above this line
}

Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:49
by "fortune" I mean the unix utility that returns a fortune.https://en.wikipedia.org/wiki/Fortune_(Unix)
@Yammine94 it would be helpful if you'd quote code posts with ``` before and after
Jose Diaz
@jsd540
Apr 20 2017 02:50
@Yammine94 s/b || card === "K" || card === "Q" || etc... also if card < var then &, ||, etc then card again;
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:52
meaning there has to be some boolean to evaluate in between || and && operators
George Yammine
@Yammine94
Apr 20 2017 02:52
@sevensixtwo762 Will do sorry first time I use this chat
Jose Diaz
@jsd540
Apr 20 2017 02:52
no worries
George Yammine
@Yammine94
Apr 20 2017 02:52
but I use my test case of "cc(2)"
and it still does not register a + 1 count
and gives me 0
var count = 0;

function cc(card) {
  if( 2<= card <=6 ){
    count += 1;
  } 
  if( 7<= card <=9 ){
    count += 0;   
  }  
  if( 10<= card || card ==="K" || card ==="A" || card ==="Q" || card ==="J"){
    count -= 1;
  }

  return count <= 0 ? count + " Hold": count + " Bet";

  // Only change code above this line
}
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:56
george is it the card game challenge ???
Jose Diaz
@jsd540
Apr 20 2017 02:56
if( 2<= card <=6 ) should also be written the same if (2 <= card && 6 >= card), its a syntax thing
George Yammine
@Yammine94
Apr 20 2017 02:56
yes it is
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:57
well you have to do nothing when card = 0
George Yammine
@Yammine94
Apr 20 2017 02:57
oh my .. I am not allowed to make 2 comparisons without an "&&"?
Joseph
@revisualize
Apr 20 2017 02:57
@Yammine94 This ... if( 7<= card <=9 ){ .. is that correct?
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:57
@Yammine94 it is better to use switch statement here !
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:57
@Yammine94 Try using switch/case for this one
Jose Diaz
@jsd540
Apr 20 2017 02:58
@Yammine94 each comparison needs an entire statement but you can have as many as beeded
Joseph
@revisualize
Apr 20 2017 02:58
But, you don't have to.
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:58
@Yammine94
switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;

    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;    

  }
David Midlo
@querentCode
Apr 20 2017 02:58
right you have to specify each unique comparison
if( 2<= card && card <=6 ){
    count += 1;
  } 
  if( 7<= card && card <=9 ){
    count += 0;   
  }
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 02:59
well giving the answer isn't really helpful...
David Midlo
@querentCode
Apr 20 2017 02:59
sure it is
Joseph
@revisualize
Apr 20 2017 02:59
@sevensixtwo762 I AGREE!
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:59
@sevensixtwo762 right !
Joseph
@revisualize
Apr 20 2017 02:59
@querentCode No it isn't.
George Yammine
@Yammine94
Apr 20 2017 02:59
thank you all
Jose Diaz
@jsd540
Apr 20 2017 02:59
how are you guys getting the code to look like the editor?
David Midlo
@querentCode
Apr 20 2017 02:59
if you say so
Aaron Bell
@awb715
Apr 20 2017 02:59
anyone familiar with copying arrays
ive learned a valuable lesson
Aizaz Shahid
@aizazshahid
Apr 20 2017 02:59
@awb715 you can share with us
Joseph
@revisualize
Apr 20 2017 02:59
Studies have shown that giving people answers to problems instills an illusionary sense of learning. Because, it only puts information into short-term memory. Of which people think they are learning. Only through a little struggle and repetition that the human brain puts things into long-term memory. I don't know what your end goal. I don't know if you want to do this as a personal project, hobby, or if you want to move into industry. Because of this, I strongly feel that working with people to allow them to solve problems on their own is a far better outcome than giving away answers. But, others clearly don't agree with my methods for helping people learn.
George Yammine
@Yammine94
Apr 20 2017 02:59
but @jsd540 You called out the missing && statements
I cnt believe that was it..
Aaron Bell
@awb715
Apr 20 2017 03:00
@forwebtech well im trying to reset an array to its original value when the tic tac toe board gets reset
George Yammine
@Yammine94
Apr 20 2017 03:00
such simplicity took 30 minutes of my life lol
David Midlo
@querentCode
Apr 20 2017 03:00
yes, but the flow of the conversation does matter. Modeling does as well.
George Yammine
@Yammine94
Apr 20 2017 03:00
thanks for the feedback everyone
David Midlo
@querentCode
Apr 20 2017 03:00
it’s a game of connect the dots
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:00
@awb715 what do you mean by reset ??
David Midlo
@querentCode
Apr 20 2017 03:00
after enought has been spoken, it’s okay to show what you’re talking about
*enough
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:01
do you have its previous value ??
Joseph
@revisualize
Apr 20 2017 03:01
@awb715 :wave:
Aaron Bell
@awb715
Apr 20 2017 03:01
@forwebtech but ive learned then when you reference to another array IN A OBJECT, it just a pointer reference to the other array, not a real copy
var openBox = {
  open:['0', '1', '2', '3', '4', '5', '6', '7', '8'],
  live:new Array (this.open)

};
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:01
@awb715 indeed its just a referrence into that arayy !
Aaron Bell
@awb715
Apr 20 2017 03:01
heres my example, on the board at the beginning of a game, the open boxes are in the open property, as you play your first round, they get removed
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:02
you can slice that duplicate into existence.
Aaron Bell
@awb715
Apr 20 2017 03:02
so when I click reset on the board, at the beginning of the next round the live property isnt reset to the 0-8, its just reset to what its pointing to
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:02
arrDup=arr.slice(0);
Aaron Bell
@awb715
Apr 20 2017 03:02
slice does not alter. It returns a shallow copy of elements from the original array. Elements of the original array are copied into the returned array as follows:
For object references (and not the actual object), slice copies object references into the new array. Both the original and new array refer to the same object. If a referenced object changes, the changes are visible to both the new and original arrays.
thats from mdn
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:02

function convertToRoman(num) {
  var roNum = ["I", "II", "III", "IV", "V"];
  var array = [num];
  if (array[0]===num) {
    return roNum[num-1];
  }
}

convertToRoman(3);
I managed to get II to V
I just need to add more to array
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:03
@awb715 yeah, you can say that, like:
var  a = 5;

var b = a;

a= 10;
we just pass the reference or memory location to that b !
Aaron Bell
@awb715
Apr 20 2017 03:03
yea so b becomes 10
manjotkaurghuman
@manjotkaurghuman
Apr 20 2017 03:03
hi
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:03
@MathematicsCoding if you're hardcoding the answers, you're doing it wrong.
manjotkaurghuman
@manjotkaurghuman
Apr 20 2017 03:04
can anyone plaese help me in solving the chunky monkey problm
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:04
@awb715 Its great that you are focusing also on concepts !
Joseph
@revisualize
Apr 20 2017 03:04
@awb715 Array.from(...originArr);
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:04
they are really necessary to build your knowledge, not information :)
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:05
@revisualize you said which book
I ordered up and going
Joseph
@revisualize
Apr 20 2017 03:05
@MathematicsCoding I don't know how to read.
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:05
reading is for fools
Kirk
@PingDesign
Apr 20 2017 03:05

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.lenght;

Aizaz Shahid
@aizazshahid
Apr 20 2017 03:06
@sevensixtwo762 too much reading, and don't think is wrong, but stills reading is important !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:06
@sevensixtwo762 ok...
Kirk
@PingDesign
Apr 20 2017 03:06
Can anyone tell me what I'm doing wrong here?
Jose Diaz
@jsd540
Apr 20 2017 03:06
I have been working on the Profile Look Up challenge and so far can only get the first 3 tests to pass:

function lookUpProfile(firstName, prop){
// Only change code below this lin

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

   if (contacts[i].firstName === firstName && contacts[i][prop]){

  return  contacts[i][prop];  

}

}

Aizaz Shahid
@aizazshahid
Apr 20 2017 03:06
@sevensixtwo762 didn't you read any course books or in your school ??
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:06
@PingDesign spelling the word "length"
Jose Diaz
@jsd540
Apr 20 2017 03:07
If I add any statements after I destroy the other tests...
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:07
@forwebtech sorry, sarcasm doesn't translate over the internet..]
Joseph
@revisualize
Apr 20 2017 03:07
@jsd540 You need to keep coding.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:07
@sevensixtwo762 what is sarcasm ??
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:07
@forwebtech see? You just did it.
and I didn't see.
Kirk
@PingDesign
Apr 20 2017 03:07
@sevensixtwo762 thankyou! that was a little dislexic of me
CamperBot
@camperbot
Apr 20 2017 03:07
pingdesign sends brownie points to @sevensixtwo762 :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @sevensixtwo762 |http://www.freecodecamp.com/sevensixtwo762
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:08
@sevensixtwo762 what ??
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:09
I don't know. What's going on?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:09
that means we are fools !
sorry for that !
Jose Diaz
@jsd540
Apr 20 2017 03:09
@revisualize So every time I add an additional statement, if, else if, else the previous statements don't work
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:09
Trading cookies for llamas. Anyone?
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:09
..
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:09
@jsd540 no, they check out in order.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:10
@jsd540 syntax for conditional statements:
if () {

} else if {

}
Joseph
@revisualize
Apr 20 2017 03:10
@jsd540 Did you read the document that I linked?
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:10
if "if" is true, "if else" doesn't evaluate. neither does "else"
Jose Diaz
@jsd540
Apr 20 2017 03:10
@revisualize reading it now, thanks btw
CamperBot
@camperbot
Apr 20 2017 03:10
jsd540 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: jsd540 already gave revisualize points
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:12
well, i have a problem in reading, when i read some book it takes me lots of time to read even a single paragraph, because i try to read with understanding, is it wrong habbit ?
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:12
no. if you keep reading without understanding, you are wasting time.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:13
@sevensixtwo762 indeed !
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:13
what is your mother tongue
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:13
urdu !
its a major language in Asia !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:14
Yes
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:14
i am from Pakistan !
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:14
I can't imagine how hard English would be.I know urdu. I've never tried to learn a language with a different script.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:14
@sevensixtwo762 Urdu is a beautiful language, for me english is easy than Urdu!
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:15
Yes, I know a man named Kishin from Pakistan
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:15
Only if you learn urdu first before english...
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:15
@sevensixtwo762 i think kishin knows Hindi language
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:15
oh I don't mean that I know how to speak Urdu. only that I know of it.
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:16
Oh I misunderstood
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:16
I guess it's possible. His last name is Bhagchandani
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:16
@sevensixtwo762 Urdu is similar to Hindi, because it came from its ancestor language !
@sevensixtwo762 yes he is Hindu by name !
similar only in orally not script wise !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:17
@sevensixtwo762 what did you do for this challenge?
Did you use some if statements a kind of loop or something?
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:17
@MathematicsCoding which challenge?
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:18
Roman Numeral converter
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:18
I'm not there yet.
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:18
Oh
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:18
but there's a simple algorithm
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:18
@MathematicsCoding can you give me the instructions !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:18
Convert the given number into a roman numeral.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:18
@sevensixtwo762 you can tell him if you know !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:19
@forwebtech I dont want the solution :p
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:19
just search for "decimal to roman numeral conversion algorithm"
that will show you how it's done. you just have to code it.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:19
@MathematicsCoding i am just talking about concept !
@MathematicsCoding make your dictionary array like thing and try to compare with it every single digit you will give !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:21
@sevensixtwo762 I see
So C is hundred right?
I just create a variable for hundred if I wanted 110 I just add X to it
CX
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:21
as far as i know !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:22
Hm
I think C is 80
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:22
@MathematicsCoding Well sorry i am wrong, have checked, c == 100
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:22
Yea
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:23
This message was deleted
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:23
XCVII
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:23
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:23
I dont understand how is that 97?
Yea
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:24
3 steps
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:24
XCVII
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:24
Oh
C = hundred X = 10
So 100-10 = 90
CX = 90
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:25
i think so!
@MathematicsCoding saboor visit the given site, :point_up: April 20, 2017 8:23 AM
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:25
So if one letter is smaller than after them then substract it whatever it is before them
X = 10 I = 1
IX = 9
cause 10 - 1 = 9
Is that how its work?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:26
first you have to figure it the place values of the number
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:26
From the following table, find the highest decimal value v that is less than or equal to the decimal number x

and its corresponding roman numeral n:


Decimal value (v)     Roman numeral (n)
1     I
4     IV
5     V
9     IX
10     X
40     XL
50     L
90     XC
100     C
400     CD
500     D
900     CM
1000     M


Write the roman numeral n that you found and subtract its value v from x:

x = x - v
Repeat stages 1 and 2 until you get zero result of x.
Jarod Guthrie
@jarodguthrie
Apr 20 2017 03:27

hi guys!
I'm having trouble with this from 'makeobject properties private':
var Bike = function() {

// Only change code below this line.
var gear = 0;

this.setGear = function(newGear){
gear += newGear;
};
this.getGear = function(){
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);

myBike.getGear() should return 4 after calling myBike.setGear(4). But is showing as wrong
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:28
function convertToRoman(num) {
 var hun = ["C", "CC", "CCC", "CCCC", "D"]; //100,200,300,400,500
}

convertToRoman(36);
So I could create var like that?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:29

@jarodguthrie

Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
Further explanation on this keyword

Saboor Malik
@MathematicsCoding
Apr 20 2017 03:29

function convertToRoman(num) {
 var tho = ["M"]; 
 var hun = ["C", "CC", "CCC", "CCCC", "D"]; //100,200,300,400,500
}

convertToRoman(36);
If I wanted 900 then I would return tho[0]+hun[0]
MC
Oh CM then hun[0]+tho[0]
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:31
@jarodguthrie if you declare a variable within your function, then it should be called private variable !
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:31
@jarodguthrie gear variable isn't a running total
@jarodguthrie gear can only be one thing at a time. when newGear is 3, the gear should be set to 3, not increased by three.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:32
@MathematicsCoding at first try to split your digit into several place values !
sorry, split the num
like if you have to number 240, so it should be like,
var  hundred = 200;

var tens = 40
@MathematicsCoding After that its easy to change it !
leetboy
@leetboy
Apr 20 2017 03:34
'''
dd
'''
CamperBot
@camperbot
Apr 20 2017 03:34
:bulb: to format code use backticks! ``` more info
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:34
for that you can use the % operator, with the values of roman numerals from chart that I posted
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:34

function convertToRoman(num) {
 var tho = ["M", "MM", "MMM", "MMMM"]; //1,000
 var hun = ["C", "CC", "CCC", "CCCC", "D"]; //100,200,300,400,500
  if (num===900) {
    return hun[0]+tho[0];
  }
}

convertToRoman(900);
leetboy
@leetboy
Apr 20 2017 03:35
dasd
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:35
no, you can't use any character more than 3 times. seriously, just use the algorithm that I posted.
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:35
Which one?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:35
@leetboy thanks for learning that :)
CamperBot
@camperbot
Apr 20 2017 03:35
:cookie: 241 | @leetboy |http://www.freecodecamp.com/leetboy
forwebtech sends brownie points to @leetboy :sparkles: :thumbsup: :sparkles:
Jarod Guthrie
@jarodguthrie
Apr 20 2017 03:35
thanks @sevensixtwo762
CamperBot
@camperbot
Apr 20 2017 03:35
jarodguthrie sends brownie points to @sevensixtwo762 :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @sevensixtwo762 |http://www.freecodecamp.com/sevensixtwo762
leetboy
@leetboy
Apr 20 2017 03:35
lol
np
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:36
From the following table, find the highest decimal value v that is less than or equal to the decimal number x

and its corresponding roman numeral n:


Decimal value (v)     Roman numeral (n)
1     I
4     IV
5     V
9     IX
10     X
40     XL
50     L
90     XC
100     C
400     CD
500     D
900     CM
1000     M


Write the roman numeral n that you found and subtract its value v from x:

x = x - v
Repeat stages 1 and 2 until you get zero result of x.
leetboy
@leetboy
Apr 20 2017 03:36

function palindrome(str) {

  var rev = str.split("").reverse().join("");

  if ( rev.replace(/([^\W*])/gi,"").toLowerCase() === str.replace(/([^\W*])/gi,"").toLowerCase()){
    return true;
  }
  else{
    return false;
  }






}



palindrome("eye");
im struggling with this
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:36
@sevensixtwo762 just like that? shouldnt I add variable?
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:37
@MathematicsCoding that's not code. it's just the steps to repeat for converting decimal to roman
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:37
I understand..
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:37
it's the algorithm that you have to try and describe with code.
but at least you don't have to try and solve conversion and programming at once. you should try converting a number manually to make sure you understand
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:39

function convertToRoman(num) {
 var roNum = ["I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"];
}

convertToRoman(900);
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:39
if you can't do it on paper, you surely won't be able to in code.
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:39
I understand how roman numerals works now
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:40
@MathematicsCoding logic building is just like how our brain solves the problem !
Sam Houlahan
@Sam-Houlahan
Apr 20 2017 03:40
Hi team is anyone available to assist me? It is to do with twitch api project https://github.com/Sam-Houlahan/Twitch-TV-Api basically it is unreliable when showing whos online and offline i cant figure out if is to do with my calls to the api or the code.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:40
as @sevensixtwo762 told that do it on paper first and then transfer it to your code, in a way that JS can understand.
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:41
Sigh hard to remember what these roman numerals represenets
I will comment it
Whats DC?
CD*
Oh its 400..
c = 100 d =500

function convertToRoman(num) {
 var roNum = ["I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"];
              //1,4,5,9,10,40,50,90,100,90,400,500,900,1000
}

convertToRoman(900);
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:45
yes
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:49

function convertToRoman(num) {
 var roNum = ["I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"];
              //1,4,5,9,10,40,50,90,100,400,500,900,1000
              //num = 0,1,2,3,4,5,6,7, 8 ,9  ,10,11 ,12, 13, 14 - arr[num]
}

convertToRoman(900);
Now next step
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:50
now try to split up your num
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:50
I dont understand
More than one parameter?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:50
ok if the number is 945
@MathematicsCoding no argument is should to one, but you have to separate it with some methods, look at the instructions some methods are mentioned there !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:51
Then that would be CMXLV
Yeah...
CMXLV is 945?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:52
i think it should be CMXL
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:52
Well thats 940
CM = 900 and XL = 40
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:53
@MathematicsCoding you can use this Calculator
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:53
L = 50 X = 10
XL = 40
Galib Hossain
@formulajp60
Apr 20 2017 03:53
Hi guys, can you help me with the "Profile Lookup" section?
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:53
@formulajp60 sure !
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:54
From the table, find the highest roman numeral that is smaller than or == the decimal value. If you're going to convert 2222, that's 1000, or M. So put an M. and subtract 1000 from 2222. you've now got M and 1222. What's the next highest roman number, less than or == the remainder? M again, so put another M. That's MM, with remainder 222. What's the next highest roman numeral, smaller than or == 222? It's C, for 100, so put C. That's MMC, and remainder 122. Put C again, for MMCC and 22
and on and on.
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:54
@formulajp60 whatis your code !
Galib Hossain
@formulajp60
Apr 20 2017 03:55
I am trying to solve it by loop. But every time the loop exits if it doesn't find the name. So, no opportunity to check the next one;
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:55
did you try something ?
'''
CamperBot
@camperbot
Apr 20 2017 03:55
:bulb: to format code use backticks! ``` more info
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:55
@formulajp60 try to format your code as @camperbot told
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:56
@sevensixtwo762 I see
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 03:56
@formulajp60 return no such contact outside the loop
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:56
Sorry i'm having headache right now... I gotta go to sleep..
I will remember that
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:57
@HeebieGeeBee tell the reason also !
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:57
If 1222 then M if 222 then C if 122 then C if 22 then X if 12 then X so on...
Right?
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 03:58
@forwebtech he knows the reason
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:58
You just have to find less than the number or equal to
Aizaz Shahid
@aizazshahid
Apr 20 2017 03:58
@MathematicsCoding if i gave you the number 2456 how will you guess its place values, in general ?
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 03:58
@MathematicsCoding yes. and add the letter to the roman numeral, and subtract the value from the decimal. until you hit 0
Saboor Malik
@MathematicsCoding
Apr 20 2017 03:59
@sevensixtwo762 I understand so that how I would do it
If i had 3999 that would be M
?
I continue until it hit 0
ooo... I could just create if statements for that..
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 04:00
MMMCMXCIX
or nested while's
Saboor Malik
@MathematicsCoding
Apr 20 2017 04:01
If I wanted to use while loop I would have to learn how to do that again..
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:01
@MathematicsCoding if you want to rest try to take power nap.
Saboor Malik
@MathematicsCoding
Apr 20 2017 04:01
Yea
Akosua
@akosasante
Apr 20 2017 04:01
I'm curious, from what I understand the JS array.sort() function looks for -1, 0, or +1 returned by the callback
So how come this still works?
Saboor Malik
@MathematicsCoding
Apr 20 2017 04:01
Alright thanks @sevensixtwo762 @forwebtech for getting me this far
CamperBot
@camperbot
Apr 20 2017 04:01
mathematicscoding sends brownie points to @sevensixtwo762 and @forwebtech :sparkles: :thumbsup: :sparkles:
Akosua
@akosasante
Apr 20 2017 04:01
array.sort(function(a, b) {
return b > a;
});
CamperBot
@camperbot
Apr 20 2017 04:01
:cookie: 271 | @forwebtech |http://www.freecodecamp.com/forwebtech
:cookie: 285 | @sevensixtwo762 |http://www.freecodecamp.com/sevensixtwo762
Saboor Malik
@MathematicsCoding
Apr 20 2017 04:01
Good night
Jean-Paul Sauve
@jp-sauve
Apr 20 2017 04:02
@MathematicsCoding it's good to know. while is easy. it does what's in the {} only while what's in the () is true
while (isTrue) {do this;}
Akosua
@akosasante
Apr 20 2017 04:02
return a > b also works to sort it in ascending order. Can sort always be used with a comparer function that just returns true or false? Or does it only work with numeric arguments
Galib Hossain
@formulajp60
Apr 20 2017 04:02
@HeebieGeeBee If I return "No such contact" outside loop, it exits the function before running the loop
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:03
@formulajp60 no it doesnt
not if its after the loop
Julian Mansueto
@julianmnst
Apr 20 2017 04:03

hi folks i need some help again. with this:


function getClima(lat, lon) {
var apiURI = "api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon;
$.ajax({
    url: apiURI,
    dataType: "json",
    type: "GET",
    async: "false",
    success: function(resp) {
        var temp = resp.main.temp;
        console.log(temp);
    }
});
}

 navigator.geolocation.getCurrentPosition(function(position) {
      getClima(position.coords.latitude, position.coords.longitude);
    });

nothing happens.
what am I doing wrong?

HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:04
@julianmnst probably mixed origin issues
look in your console
Aaron Bell
@awb715
Apr 20 2017 04:05
@revisualize that doesnt work
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:05
what errors are you getting
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:05
@akosasante first where did you read that, array.sort() returns +1, 0, -1 ?
Galib Hossain
@formulajp60
Apr 20 2017 04:05
@HeebieGeeBee HELL YEAH! Thanks! It worked!
CamperBot
@camperbot
Apr 20 2017 04:05
formulajp60 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1392 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Joseph
@revisualize
Apr 20 2017 04:06
@awb715 welp. I tried.
Akosua
@akosasante
Apr 20 2017 04:06

@forwebtech : I guess I worded that wrong. https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

The "compareFunction" or the "callback" that you pass to sort() is supposed to return -1, 0, +1 to my understanding

Galib Hossain
@formulajp60
Apr 20 2017 04:06
Very simple yet useful thing that I learned!
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:06
@akosasante sort uses a-b or b-a for the callback
Julian Mansueto
@julianmnst
Apr 20 2017 04:07
@HeebieGeeBee jquery.min.js:4 GET https://s.codepen.io/boomerang/iFrameKey-1fb32418-9907-acbc-a5b7-d3d0d1e1300f/api.openweathermap.org/data/2.5/weather?lat=-31.4360555&lon=-64.2023677 404 ()
send @ jquery.min.js:4
ajax @ jquery.min.js:4
getClima @ VM776 pen.js:3
(anonymous) @ VM776 pen.js:16
exactly that
Akosua
@akosasante
Apr 20 2017 04:07
@HeebieGeeBee : Right I understand, I was just surprised that 'a > b' and 'a < b' worked. Was wondering if that is supposed to e the case or just happens to work for numeric arrays?
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:08
@akosasante so youre just trying to sort strings?
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:08
If compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
If compareFunction(a, b) is greater than 0, sort b to a lower index than a.
compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.
@awb715 read that
Aaron Bell
@awb715
Apr 20 2017 04:08
Formy next project I wanna make a site that takes data from a form and then adds it to a SQL databose with node
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:10
@julianmnst i dont see an api key in your url
Akosua
@akosasante
Apr 20 2017 04:10
@HeebieGeeBee : In this particualr example I was sorting the array [1, 12, 21, 2]
@forwebtech : I used compareFunction(a,b) { return a > b } and it still worked. Was just surprised as that's not the documented way it works
Aaron Bell
@awb715
Apr 20 2017 04:10
why @forwebtech
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:10
for openweather map
LeSean Johnson
@leseanbiz
Apr 20 2017 04:10
is there a reason why using the wunderground api for the local weather app will be a problem?
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:10
@akosasante well don't. But it has the information about the sort( comparefuncc )
Julian Mansueto
@julianmnst
Apr 20 2017 04:11
I'm sorry but what do you mean api key?
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:12
@julianmnst you need to sign up to open weather maps api and they'll give you a key to access their api
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:12
function compare(a, b) {
  if (a is less than b by some ordering criterion) {
    return -1;
  }
  if (a is greater than b by the ordering criterion) {
    return 1;
  }
  // a must be equal to b
  return 0;
}
Julian Mansueto
@julianmnst
Apr 20 2017 04:13
@HeebieGeeBee THANK YOU again
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:14
@akosasante when you say it worked did it sort it in the proper way or just did sometype of sort?
Akosua
@akosasante
Apr 20 2017 04:16

@forwebtech @HeebieGeeBee : eh, okay. I understand how the compare function is supposed to work. I am just curious if this was just one of those tricky/hidden ways that javascript values sometimes work.

var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a, b) {
  return b > a;
});

The above returns
[21, 12, 2, 1]
(You can try it in the chrome dev console)

And same with the oppoiste

var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a, b) {
  return a > b;
});

returns [1, 2, 12, 21]

HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:17
@akosasante guess it works just did some tests, didnt know you could do that way for numbers but guess you can
[1,2,4,12,34,25,64,21].sort((a, b)=> a<b)
[64, 34, 25, 21, 12, 4, 2, 1]
[1,2,4,12,34,25,64,21].sort((a, b)=> a>b)
[1, 2, 4, 12, 21, 25, 34, 64]
Akosua
@akosasante
Apr 20 2017 04:18
huh, interesting. Probably best to stick to the documented way. Just thought it was surprising/interesting. Is it because of the how those data types work in javascript or something?
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:21
im sure there must be a reason b why its not the best way to do it
but who knows what that is
David Miller
@DavidMillerFL
Apr 20 2017 04:26
function isLess(a,b) {

    return a === b;
}


// Change these values to test
isLess(10, 15);
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:27
@DavidMillerFL why ===?
David Miller
@DavidMillerFL
Apr 20 2017 04:27
I dunno, it’s in the instructions? @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:27
theres a clue in the name of the function
David Miller
@DavidMillerFL
Apr 20 2017 04:27
Hmm
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:27
@DavidMillerFL indeed !
David Miller
@DavidMillerFL
Apr 20 2017 04:27
Ok I’ll re-examine
Thanks @HeebieGeeBee @forwebtech
CamperBot
@camperbot
Apr 20 2017 04:27
davidmillerfl sends brownie points to @heebiegeebee and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 1393 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:28
great :+1:
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:28
@DavidMillerFL think about using > or <
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:28
@Lumexralph mornin
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:28
@HeebieGeeBee Morning Bro
David Miller
@DavidMillerFL
Apr 20 2017 04:28
@Lumexralph Well that done it. Thanks!
CamperBot
@camperbot
Apr 20 2017 04:28
davidmillerfl sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1531 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:28
howdy?
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:28
fine
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:28
@DavidMillerFL :+1:
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:28
hows you?
David Miller
@DavidMillerFL
Apr 20 2017 04:28
I swear if it wasn’t for the hints you guys give me I would have been stuck so many times today.
Darth Skywalker
@adityaparab
Apr 20 2017 04:29
Hints!
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:30
just gentle, struggled to stand up, JS calculator hoping i finish and sort the bugs today.... and having some fun times with Python
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:30
nice
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:30
Rogue Nation
David Miller
@DavidMillerFL
Apr 20 2017 04:30
function isLess(a,b) {

    return a <= b;
}


// Change these values to test
isLess(10, 15);
So, anyone care to discuss this with me? I’d like to know why it works.
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:30
Getter and Setter are the examples of Encapsulation ??
Darth Skywalker
@adityaparab
Apr 20 2017 04:31
@forwebtech False
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:31
The Last Jedi
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:31
This message was deleted
Darth Skywalker
@adityaparab
Apr 20 2017 04:31
Jedi + Sith, both at the same time
David Miller
@DavidMillerFL
Apr 20 2017 04:31
hey man I didn’t see any trailers and I’m like actively avoiding any plot details :(
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:31
@adityaparab then what ?
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:31
luke is a grey
David Miller
@DavidMillerFL
Apr 20 2017 04:32
ooook closing Gitter
Darth Skywalker
@adityaparab
Apr 20 2017 04:32
@forwebtech Class is an example of encapsulation (that's theory, practically, every function is an example of encapsulation)
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 04:32
force fluid
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:32
@adityaparab ok accessing private methods of a class, what is that ??
What is the name of that concept !
Darth Skywalker
@adityaparab
Apr 20 2017 04:33
@forwebtech private methods can only be accessed from the instance of the same class
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:33
@adityaparab but we can make methods to access them, like Getter / Setter.
Darth Skywalker
@adityaparab
Apr 20 2017 04:34

@forwebtech

What is the name of that concept !

Visibility control, I think..

Aizaz Shahid
@aizazshahid
Apr 20 2017 04:34
@adityaparab Did you ever learn OOP ? through any language !
Darth Skywalker
@adityaparab
Apr 20 2017 04:34
C++ and Java
And JS too, but syntax is a bit different in JS
concepts are all the same
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:35
Then what is Encapsulation ?
Darth Skywalker
@adityaparab
Apr 20 2017 04:35
@forwebtech : Encapsulation means combining data and the methods that manipulate that data together.
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:36
Encapsulation of behavior associated with getting or setting the property - this allows additional functionality (like validation) to be added more easily later.
ref: link
Darth Skywalker
@adityaparab
Apr 20 2017 04:37
@forwebtech That's too much theory without any practical example mate... :)
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:37
setter and getter are the examples of Encapsulation !
ok i will give you !
var Bike = function() {

  // Only change code below this line.
  var gear;

  this.getGear = function() {
     return gear;   
  };

  this.setGear = function(val) {
    gear = val;
  };


};
Ref: Make Object Properties Private
Actually, it refreshed my JAVA :) looking through that :sparkles:
anyone know that?
Luke
@luke818h
Apr 20 2017 04:51
I need some help with javascript Profile Lookup.
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:52
@luke818h Where you got stuck ?
Luke
@luke818h
Apr 20 2017 04:54
at the beginning. Should i copy/paste the instructions?
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:54
@luke818h asking your question can make it direct
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:55
no i will look it !
Luke
@luke818h
Apr 20 2017 04:55
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

      // Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Naidu
@jayanaidu
Apr 20 2017 04:55
I need to some help in java script
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:56
did you get this
If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"
Luke
@luke818h
Apr 20 2017 04:56
"The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact."
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:56
@luke818h what's the question?
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:56
@luke818h
Naidu
@jayanaidu
Apr 20 2017 04:56
titleCaseOver is defined and has a value of 9000
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:57
@luke818h you should to check the firstname into the given array !
Ogundele Olumide
@Lumexralph
Apr 20 2017 04:57
@luke818h
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the array contacts
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Luke
@luke818h
Apr 20 2017 04:57
should i be testing a boolean value of the firstname
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:57
no just use conditional statement
Naidu
@jayanaidu
Apr 20 2017 04:57

2
// Declarations
3
var studlyCapVar;
4
var properCamelCase;
5
var titleCaseOver;
6

7
// Assignments
8
studlyCapVar = 10;
9
properCamelCase = "A String";
10
titleCaseOverr = 9000;
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:57
with firstName to contacts[i].firstName
Naidu
@jayanaidu
Apr 20 2017 04:58
i defined all variables in the above manner
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:58
read his guideline: :point_up: April 20, 2017 9:57 AM
@luke818h
Luke
@luke818h
Apr 20 2017 04:59
ok. thanks. I just needed a bump in the right direction
thanks you
Lin Grayson
@awakenedlin
Apr 20 2017 04:59
Would anyone be able to help me with JavaScript exercise number 31 (FrontLine SecondLine ThirdLine)?
Aizaz Shahid
@aizazshahid
Apr 20 2017 04:59
@jayanaidu what are you doing !
Naidu
@jayanaidu
Apr 20 2017 04:59
everything is right but the titlecaseover is definedand has a value of 9000 is showing wrong
Lin Grayson
@awakenedlin
Apr 20 2017 04:59
I dont think I understand the instructions correctly.
Aizaz Shahid
@aizazshahid
Apr 20 2017 05:00
@jayanaidu paste your code !
@awakenedlin what is the name of that challenge!
ahmad
@woat
Apr 20 2017 05:00
@awakenedlin shoot it
Naidu
@jayanaidu
Apr 20 2017 05:00
i am doing Understanding case sensitivity invariables@aizaz
Lin Grayson
@awakenedlin
Apr 20 2017 05:00
var myStr = "FirstLine \n \SecondLine\ \r ThirdLine"; // Change this line
ahmad
@woat
Apr 20 2017 05:01
@awakenedlin whats the description of the code challenge?
Lin Grayson
@awakenedlin
Apr 20 2017 05:01
That's what I have so far, here's the default code: var myStr; // Change this line
ahmad
@woat
Apr 20 2017 05:01
the descripton
of
the
Lin Grayson
@awakenedlin
Apr 20 2017 05:01
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:01
@awakenedlin in JS you'll need to use some special characters within your string to give a kind of representation you want and to make the JS interpreter decipher and not confuse stuffs that's why you use them..........eliminate any space between your string
Aizaz Shahid
@aizazshahid
Apr 20 2017 05:02
@jayanaidu
Lin Grayson
@awakenedlin
Apr 20 2017 05:02
I eliminated the spaces and it still isn't working. :\
Aizaz Shahid
@aizazshahid
Apr 20 2017 05:02
@jayanaidu did you know what is camelCase
Naidu
@jayanaidu
Apr 20 2017 05:02
ya
Aizaz Shahid
@aizazshahid
Apr 20 2017 05:02
just change your all variables to camelCase
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:02
@awakenedlin did you escape backslash ?
Naidu
@jayanaidu
Apr 20 2017 05:03
tell me @forwebtech
Lin Grayson
@awakenedlin
Apr 20 2017 05:03
@Lumexralph I didn't, I'll try that.
Naidu
@jayanaidu
Apr 20 2017 05:03
ichanged all variables into camel case
Aizaz Shahid
@aizazshahid
Apr 20 2017 05:03
@jayanaidu
paste the code then please !
ahmad
@woat
Apr 20 2017 05:04
@awakenedlin sorry brah can you link me the challenge
Aizaz Shahid
@aizazshahid
Apr 20 2017 05:04
'''
CamperBot
@camperbot
Apr 20 2017 05:04
:bulb: to format code use backticks! ``` more info
Naidu
@jayanaidu
Apr 20 2017 05:05

// Declarations
var studlyCapVar;
var properCamelCase;
var titleCaseOver;

// Assignments
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOverr= 9000;

Aizaz Shahid
@aizazshahid
Apr 20 2017 05:06
@jayanaidu in the last you have typo check it !
titleCaseOverr => titleCaseOver
Markus Kiili
@Masd925
Apr 20 2017 05:09
@Lumexralph Morning.
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:09
@Masd925 Morning Markus
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 05:12
@Masd925 mornin
Julian Mansueto
@julianmnst
Apr 20 2017 05:13
Hi there people. I'm at the Weather App challenge. I get Mixed Content error. Any ideas of how to make it work?
Markus Kiili
@Masd925
Apr 20 2017 05:13
@HeebieGeeBee Morning.
devpaaji
@devpaaji
Apr 20 2017 05:16
@Lumexralph gm
@Masd925 Hello how ae you
@HeebieGeeBee gm
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 05:17
@devpaaji mornin
Markus Kiili
@Masd925
Apr 20 2017 05:17
@devpaaji Fine.
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 05:19
@julianmnst try not to use geolocation with an api that doesnt serve api data over https
or us an ip lookup for location data that iuses http
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:19
@devpaaji Hey Bro! morning
Naidu
@jayanaidu
Apr 20 2017 05:21

var myVar = 87;

// Only change code below this line
myVar = ++myVar;
myVar=myVar;

what is the error in this code
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:21
@jayanaidu myVar++;
Naidu
@jayanaidu
Apr 20 2017 05:22
they asked to me to make mt var should equal 88
myVar should eual 88
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:23
@jayanaidu do you know our pre and post increment operator works ?
Naidu
@jayanaidu
Apr 20 2017 05:23
one more question is myVar = myVar should be changed
ya
bilaal-s
@bilaal-s
Apr 20 2017 05:23
Good morning guys. CSS question sorry :) whats up with my weather-icon div? why cant I get it to display as a square next to my weather-info div? I suspect it has something to do with the before/after of the sun animation. https://codepen.io/bilaal-s/pen/dWyrgM
Julian Mansueto
@julianmnst
Apr 20 2017 05:23
@HeebieGeeBee not sure I'm following. intead "navigator.geolocation" should I use IP?
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:24
@jayanaidu yes, remove that and replace it myVar++;
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 05:24
@julianmnst yeah, or use a weather api that allows access with https
Julian Mansueto
@julianmnst
Apr 20 2017 05:24
@HeebieGeeBee Ok got it now, thanks!
CamperBot
@camperbot
Apr 20 2017 05:24
julianmnst sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1394 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 05:24
maybe someone knows how to use one of those gatway things like crossorigin.me
but i havent used those, or know how they work
Naidu
@jayanaidu
Apr 20 2017 05:25
after doing according to u myVar=87
@Lumexralph
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:25
@jayanaidu can you show your updated code?
Naidu
@jayanaidu
Apr 20 2017 05:26

var myVar = 87;

// Only change code below this line
myVar = myVar++;

Julian Mansueto
@julianmnst
Apr 20 2017 05:26
@HeebieGeeBee Will read about crossorigin as well! :D
Ogundele Olumide
@Lumexralph
Apr 20 2017 05:27
@jayanaidu that's why I asked if you know how pre and post increment operator works, just do myVar++; don't assign it to myVar, there's already a side-effect that increments myVar with 1
Jake
@JakeDVirus
Apr 20 2017 05:34

Given below are two code. the diference is just in the extra parenthesis.
1-This fist code executes as expected-- the event is fired only once

var pBlock = document.getElementById("pBlock");
function onceClick() {
    alert("Clicked");
    event.currentTarget.removeEventListener("click", onceClick)
}
pBlock.addEventListener("click", onceClick);

2- but in this code, when the click event occurs then the event is fired infinte times, i.e, the alert pops up and when i click "ok" in the alert box then again the alert pops up and it goes on.. ultimately i had to run task manages to close the browser

var pBlock = document.getElementById("pBlock");
function onceClick() {
    alert("Clicked");
    event.currentTarget.removeEventListener("click", onceClick())  //the extra parenthesis in this line
}
pBlock.addEventListener("click", onceClick);

what happened under the hood in the secound code that made this happen (repeated continous event firing)??

devpaaji
@devpaaji
Apr 20 2017 05:36
@NeelDVirus note the fundamental concept of using () and not using ()
when you use () the function is executed and the return value is assigned to the event handler
when you use without it
only reference of it is passed
Markus Kiili
@Masd925
Apr 20 2017 05:38
@NeelDVirus onceClick is a function and onceClick() is a call to the function and evaluates to the return value. Looks like every call to that function calls itself again, on the second case.
devpaaji
@devpaaji
Apr 20 2017 05:38
that means actual function is assigned
Important to mention here is that functions are first class objects in JavaScript.
that simply means Fn can be assigned to other variables or passed around as arguments.
Jake
@JakeDVirus
Apr 20 2017 05:40
@devpaaji @devpaaji oh do you mean passing just onClickpassed the function as argument, and passing onClick() makes it recursive?
Markus Kiili
@Masd925
Apr 20 2017 05:40
@NeelDVirus Passing onClick() means that the function is called and the return value passed as argument.
Each call calls the same function again and it never stops.
So more and more execution contexts are formed until the browser runs out of memory, or something like that.
Pieter Stokkink
@forkerino
Apr 20 2017 05:44
Morning!
@Masd925 @Lumexralph @HeebieGeeBee :wave:
Markus Kiili
@Masd925
Apr 20 2017 05:44
@forkerino Morning.
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 05:44
@forkerino mornin
Jake
@JakeDVirus
Apr 20 2017 05:44
@Masd925 Oops i think i am getting you. i have to use just onClickto pass the reference of the function as the argument
Markus Kiili
@Masd925
Apr 20 2017 05:44
@NeelDVirus Yes.
Jake
@JakeDVirus
Apr 20 2017 05:46
@Masd925 @devpaaji thanks guys
CamperBot
@camperbot
Apr 20 2017 05:46
neeldvirus sends brownie points to @masd925 and @devpaaji :sparkles: :thumbsup: :sparkles:
:star2: 3888 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 233 | @devpaaji |http://www.freecodecamp.com/devpaaji
Markus Kiili
@Masd925
Apr 20 2017 05:47
@NeelDVirus The idea is to give the event handler function to the browser to be executed later when the event fires. Not to execute it yourself.
Jake
@JakeDVirus
Apr 20 2017 05:49
@Masd925 can you please elaborate it little bit
i mean "not to execute yourself" and "later when the event fires".. i am not getting you :/
devpaaji
@devpaaji
Apr 20 2017 05:50
pBlock.addEventListener("click", onceClick);
@NeelDVirus
only when a click event is fired
you call that function
otherwise let it sleep
easily and not work at all
like a lazy ass
Markus Kiili
@Masd925
Apr 20 2017 05:51
@NeelDVirus That is the idea of callback functions and used with event handlers. You make a function (object) and give it to someone to be executed later. For example with map method, the map method executes the callback function once for each array element under the hood and makes and returns a new array made from the return values. With event handlers, that addEventListener call tells the browser to run the given function when the specified event fires at some point later.
Daksh Shah
@dakshshah96
Apr 20 2017 05:52
Hey everyone, for ‘Show the Local Weather’ project, how do I get the coordinates of the users location? The HTML5 geolocation in Chrome no longer allows requests from non-HTTPS sources. :/
Markus Kiili
@Masd925
Apr 20 2017 05:53
@NeelDVirus If there are no function currently being executed, the engine looks periodically if any events have fired and runs the corresponding callback function. That is how events work.
Jake
@JakeDVirus
Apr 20 2017 05:54
@Masd925 oh i got it now.. thanks for explaining it in details, really appreciated man
CamperBot
@camperbot
Apr 20 2017 05:54
neeldvirus sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: neeldvirus already gave masd925 points
Markus Kiili
@Masd925
Apr 20 2017 05:55
@NeelDVirus You're welcome.
Jake
@JakeDVirus
Apr 20 2017 05:55
@devpaaji yeah i knew that.. may be i could not extract out the meaning from the sentence hehe
devpaaji
@devpaaji
Apr 20 2017 05:55
I make simple stories
to explain complex topics
once you start drawing analogy
programming becomes easier
Pieter Stokkink
@forkerino
Apr 20 2017 05:56
@dakshshah96 I think codepen will go full HTTPS in a month or so. But what is the problem with using HTTPS? An alternative to geolocation is to do an ip based search for location.
Jake
@JakeDVirus
Apr 20 2017 05:56
@devpaaji yeah that really helped me in this point
devpaaji
@devpaaji
Apr 20 2017 05:56
simple, untill the button is clicked, the function is sleeping
once clicked, mom asks the son to wake up and go to school
Jake
@JakeDVirus
Apr 20 2017 05:57
@devpaaji yeah i knew that as the logically concept
devpaaji
@devpaaji
Apr 20 2017 05:57
son gets up, baths, cleans eat breakfast and go to school
Jake
@JakeDVirus
Apr 20 2017 05:57
hahaha :D
devpaaji
@devpaaji
Apr 20 2017 05:57
so here son is the function which holds the logic when the button is clicked
so one click, he will do the tasks and again go to sleep... again another click, he will repeat the above tasks and go to sleep
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:00
am i understanding that with node i can create the http server to listen
but do i set it with my internet ip
if i want ppl to access it from outside
bilaal-s
@bilaal-s
Apr 20 2017 06:00
Morning guys ^_^ my understanding of absolute positioning doesn't seem to be helping me here xD the animated sun is "outside" the gray oval div i want it to be in when it is resized, any ideas? https://codepen.io/bilaal-s/pen/dWyrgM
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:01
or do i still just give it the ip of my router
and then set the router up
Henry
@GitHub-Henry
Apr 20 2017 06:02
@HeebieGeeBee do you have a static or dynamic ip
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:02
dynamic
Henry
@GitHub-Henry
Apr 20 2017 06:02
@HeebieGeeBee Here's the gist. you need a dynamic ip so folks can get to it
you can use something like dynu.com to provide you one for free
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:03
yeah i know all that
Henry
@GitHub-Henry
Apr 20 2017 06:03
they provide an app that you can use to point to your server
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:03
im just talking about when i set the server up in node
Henry
@GitHub-Henry
Apr 20 2017 06:03
this is any web server
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:04
cus like right now i just use like 127.0.0.1 for the ip listening on port 3000
Pieter Stokkink
@forkerino
Apr 20 2017 06:04
@bilaal-s ugh. CSS positioning. Good luck! You might want to ask in the HelpFrontEnd room, too...
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:04
but this is just for local stuff
Henry
@GitHub-Henry
Apr 20 2017 06:04
so folks go to dynu, then dynu routes to your ip address
your dynamic ip address via the dynu.com app
do you have a dynu.com account?
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:05
no not yet
Henry
@GitHub-Henry
Apr 20 2017 06:05
you need it
and you need their app that will route traffic to your web server
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:05
yeah i know, im just trying to figure out if i just continue to run node in the same 127.0.0.1 ip
Henry
@GitHub-Henry
Apr 20 2017 06:05
those two parts are key to you serving up web pages to the public
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:05
as i do with local stuff
and then the router handles serving it from my pc out to the public
Henry
@GitHub-Henry
Apr 20 2017 06:07
When dynu.com routes to your dynamic ip address via their application, then your router will send the traffic to your web server, you need to do port forwarding to accomplish this
that's how you server to the world
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:07
right so aslong as the port is forwarded to my pc where im hosting the node server
i still just use the ip to my router in the node server
Henry
@GitHub-Henry
Apr 20 2017 06:08
public => dynu => isp => router => server
that's the path for your to serve up web pages
bilaal-s
@bilaal-s
Apr 20 2017 06:08
@forkerino Thanks for the tip! will ask there ^_^
CamperBot
@camperbot
Apr 20 2017 06:08
bilaal-s sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1814 | @forkerino |http://www.freecodecamp.com/forkerino
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:08
ok thanks
@GitHub-Henry thanks
CamperBot
@camperbot
Apr 20 2017 06:09
heebiegeebee sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @github-henry |http://www.freecodecamp.com/github-henry
Henry
@GitHub-Henry
Apr 20 2017 06:09
hope that helped
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:09
it did
Markus Kiili
@Masd925
Apr 20 2017 06:10
@bilaal-s You might use relative units for the top and left positions of the sun. Using absolute px amounts might be messing the layout up.
HeebieGeeBee
@HeebieGeeBee
Apr 20 2017 06:10
and do all browsers make a request for favicon?
automatically
Markus Kiili
@Masd925
Apr 20 2017 06:10
@bilaal-s Try percentages for example.
Henry
@GitHub-Henry
Apr 20 2017 06:10
i think most do, so I include them in my pages
Pieter Stokkink
@forkerino
Apr 20 2017 06:10
@HeebieGeeBee not sure about that, but there's a simple npm package for it.
Henry
@GitHub-Henry
Apr 20 2017 06:10
besides that it personalizes my pages
HeebieGeeBee