These are chat archives for FreeCodeCamp/HelpJavaScript

13th
May 2017
Jason Luboff
@JLuboff
May 13 2017 00:00
@blackcytographer My github profile? I wouldn't worry too much about my repos, most of them are for Backend stuff and/or I've forked/starred other peoples stuff
Aizaz Shahid
@aizazshahid
May 13 2017 00:01
@t0cc the problem is that empty string is still string, so that's the point.
Jason Luboff
@JLuboff
May 13 2017 00:01
Alright...see ya guys around
t0cc
@t0cc
May 13 2017 00:01
forwebtech: isn't it strange that var myVar; myVar += "something"; results in a string "undefinedsomething" ?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 00:02
later
Aizaz Shahid
@aizazshahid
May 13 2017 00:02
@t0cc because you are concatenating. and you already know that when we declare the myVar without assigning something, it will automatically gets the value undefined
so it is equal to myVar = (undefined) + "something"; just showing the concept !
t0cc
@t0cc
May 13 2017 00:03
forwebtech: I would expect that myVar will initialized 'empty' if I assign a string ... Mmm
Aizaz Shahid
@aizazshahid
May 13 2017 00:04
@t0cc JS is not strictly typed but it has types, but if you make var myStr, who knows what will store in it ? so how can we say that it is a string ?

@t0cc so by default variables stored with it.

The global undefined property represents the primitive value undefined. It is one of JavaScript's primitive types.

t0cc
@t0cc
May 13 2017 00:05
forwebtech: I thought if I "var myVar;" it is the same as "var myVar = undefined;"
Aizaz Shahid
@aizazshahid
May 13 2017 00:06
A variable that has not been assigned a value is of type undefined.
@t0cc indeed !
Caleb Brenner
@cwborion
May 13 2017 00:08
I feel like I’m close on this challenge, but unsure what I’m missing. Any hints?
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookUp = {
    "alpha": Adams,
    "bravo": Boston,
    "charlie": Chicago,
    "delta": Denver,
    "echo": Easy,
    "foxtrot": Frank,
  };
    var phoneticLookUp = result;
  }

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

// Change this value to test
phoneticLookup("charlie");
Aizaz Shahid
@aizazshahid
May 13 2017 00:08
@cwborion yes, but you have already a declared variable result, is there, to get the value from lookup
t0cc
@t0cc
May 13 2017 00:09
forwebtech: so its type is 'undefined' not its value. To me 'undefined' is a type showing, no variable type was set for now. Then the next operation (eg string operation) sets the type to string and the value should be the string value added with the operation.
Aizaz Shahid
@aizazshahid
May 13 2017 00:09
@t0cc yes !
so when we initialized with some value, it gets its type according to the value.
t0cc
@t0cc
May 13 2017 00:10
forwebtech: ok so far, but why is JS then converting the type 'undefined' into a string "undefined" += "something" to "undefinedsomthing" ... that's what I don't get
Aizaz Shahid
@aizazshahid
May 13 2017 00:11
@t0cc actually you are concatenating it
Caleb Brenner
@cwborion
May 13 2017 00:11
@forwebtech hmm the only thing I’d think to switch it with is “return” but that didn’t work either
Aizaz Shahid
@aizazshahid
May 13 2017 00:11
not assigning actually .
Francis Ngo
@francisngo
May 13 2017 00:11
can someone help me with this?
var coffee = [
  {title: 'Peets'},
  {title: 'Starbucks'},
  {title: 'Philz Coffee'}
];

function searchCoffee(title){
  //input: title
  //output: return coffee object 
  //if not found, return false; 
  return coffees.find(function(coffee){
    return coffee.title === title;
  });
  //how to return false if not found?
}
searchCoffee('Peets'); //{title: 'Peets'}
searchCoffee('Sightglass'); //false
Rodrigo
@conderodrigo98
May 13 2017 00:12
hi! I'm trying to make a json call to the wikipedia api but I get this error in the console: XMLHttpRequest cannot load https://en.wikipedia.org/wiki/api.php?action=opensearch&format=json&search=holis. Redirect from 'https://en.wikipedia.org/wiki/api.php?action=opensearch&format=json&search=holis' to 'https://en.m.wikipedia.org/wiki/api.php?action=opensearch&format=json&search=holis' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access. Anybody knows how to solve this problem??
Aizaz Shahid
@aizazshahid
May 13 2017 00:12
@t0cc for more clearance:
var a = 2;
var str = "";
str = a + " two"
console.log(str);    // 2 two
@cwborion all things are predefined for you, so you just need to assign the value from lookup into result variable, using the parameter, because lookup is an object, as well.
Gulsvi
@gulsvi
May 13 2017 00:13
@conderodrigo98 Add origin=* to your URL: http://stackoverflow.com/a/38921370
Keon Samuel
@keonsam
May 13 2017 00:14
man dataViz is dead.
Ashref
@Asher2016
May 13 2017 00:14
@francisngo use for loop with index
Rodrigo
@conderodrigo98
May 13 2017 00:16
@SkyCoder01 I get the same error : XMLHttpRequest cannot load https://en.wikipedia.org/wiki/api.php?action=opensearch&format=json&search=holis&origin=*. Redirect from 'https://en.wikipedia.org/wiki/api.php?action=opensearch&format=json&search=holis&origin=*' to 'https://en.m.wikipedia.org/wiki/api.php?action=opensearch&format=json&search=holis&origin=*' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
Gulsvi
@gulsvi
May 13 2017 00:17
@conderodrigo98 Can you share your codepen link?
Caleb Brenner
@cwborion
May 13 2017 00:17
@forwebtech so I have this now, but it isn’t working. I think I have only one line incorrect, the one with [lookUp].
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookUp = {
    "alpha": Adams,
    "bravo": Boston,
    "charlie": Chicago,
    "delta": Denver,
    "echo": Easy,
    "foxtrot": Frank,
  };
    val return = [lookUp];
  }

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

// Change this value to test
phoneticLookup("charlie");
Rodrigo
@conderodrigo98
May 13 2017 00:18
@SkyCoder01 here you have. Thanks in advance
CamperBot
@camperbot
May 13 2017 00:18
conderodrigo98 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1381 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Aizaz Shahid
@aizazshahid
May 13 2017 00:20
@cwborion yes, to access the object properties you have two options, one, with . dot operator obj.propName and [] bracket notation, obj[prop]. But here we can access that object only with bracket notation because we are using a parameter to access that object.
Gulsvi
@gulsvi
May 13 2017 00:21
@conderodrigo98 The URL needs to start with: https://en.wikipedia.org/w/api.php not https://en.wikipedia.org/wiki/api.php
https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=holis&origin=*
/w/ not /wiki/
FlashHero
@FlashHero
May 13 2017 00:21
@cwborion [lookUp] doesn't do anything, you need object name which is lookUp and then you put brackets and put the parameter val inside
Rodrigo
@conderodrigo98
May 13 2017 00:22
@SkyCoder01 Oh what a silly mistake!! Thanks for the help :smile:
CamperBot
@camperbot
May 13 2017 00:22
conderodrigo98 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: conderodrigo98 already gave skycoder01 points
FlashHero
@FlashHero
May 13 2017 00:23
can anyone help me with Missing letters algorithms
t0cc
@t0cc
May 13 2017 00:24
@forwebtech: can you try this with chrome debugger:
```
var myVar;
var res = "something";
myVar += res;
console.log(myVar);
```
not sure if I can paste that way with IRC cleint
Caleb Brenner
@cwborion
May 13 2017 00:25
@FlashHero this is what I got out of what you explained, isn’t working. I’m clueless haha.
lookUp[val];
Stephen James
@sjames1958gm
May 13 2017 00:30
@cwborion The function has a return result; so you need to assign that value to result to get it returned from the function
FlashHero
@FlashHero
May 13 2017 00:30
@cwborion that's basically it lookUp is the object and val is the parameter that you are passing into the function so it would look like this lookUp[this is the parameter passed into function which is treated as a property] and now you just need to return what you have wrote it already
Aizaz Shahid
@aizazshahid
May 13 2017 00:31
@t0cc don't have chrome.
t0cc
@t0cc
May 13 2017 00:32
@forwebtech It might be a debugger issue. If I don't "var myVar = undefined;" the debugger keeps the old myVar value.
Aizaz Shahid
@aizazshahid
May 13 2017 00:33
@t0cc ok check the typeof myVar without assigning ?
t0cc
@t0cc
May 13 2017 00:35
@forwebtech ha, there is a side effect
@forwebtech as the debugger keeps the type and value of myVar up until I exclusively assign "var myVar = undefined;" it sticks to typeof string
Caleb Brenner
@cwborion
May 13 2017 00:39
@FlashHero okay, still not working.
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookUp = {
    "alpha": Adams,
    "bravo": Boston,
    "charlie": Chicago,
    "delta": Denver,
    "echo": Easy,
    "foxtrot": Frank,
  };
  phoneticLookup[val];  
  lookUp[val];
  }

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

// Change this value to test
phoneticLookup("charlie");
I tried making the result =lookUp[val] but it didn’t work either
and with return
t0cc
@t0cc
May 13 2017 00:40
@forwebtech but, this still doesn't explain, why the type 'undefined' ever gets converted into the string "undefined". But maybe that's another side effect I can't verify
FlashHero
@FlashHero
May 13 2017 00:40
@cwborion you don't do phoneticLookup[val]; lookUp[val] is fine just return that
Caleb Brenner
@cwborion
May 13 2017 00:41
return lookUp[val];
FlashHero
@FlashHero
May 13 2017 00:41
yes
did it work ?
Caleb Brenner
@cwborion
May 13 2017 00:42
hmm it still isn’t working though
FlashHero
@FlashHero
May 13 2017 00:42
delete return result
Caleb Brenner
@cwborion
May 13 2017 00:43
still not working, and that part is under the note to “not change code below this line"
Cindy Chew
@cindychewy
May 13 2017 00:43
Hi guys
im stuck in the part to convert celsius to fahrenheit
how to do this part huh
FlashHero
@FlashHero
May 13 2017 00:44
@cwborion let me see the code
Benjamin Hike
@BenJess
May 13 2017 00:45
@cindychewy i can help out!
Caleb Brenner
@cwborion
May 13 2017 00:45
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookUp = {
    "alpha": Adams,
    "bravo": Boston,
    "charlie": Chicago,
    "delta": Denver,
    "echo": Easy,
    "foxtrot": Frank,
  };  
  return lookUp[val];
}

  // Only change code above this line

  return result;
}

// Change this value to test
phoneticLookup("charlie");
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:45
@cindychewy how much you have so far?
@cwborion check that you have 2 returns and a key in the air
FlashHero
@FlashHero
May 13 2017 00:46
@cwborion delete return result it should work
Kevin Fontela
@Kevin0828
May 13 2017 00:46
hello javascript friends
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:46
hello Kevin
Caleb Brenner
@cwborion
May 13 2017 00:47
@FlashHero still not working, show me the code you used.
deaninous
@deaninous
May 13 2017 00:47
Hi, js room, I will just be chilling and enjoying the teachable moments
FlashHero
@FlashHero
May 13 2017 00:47
@cwborion you have an extra curly braces
Benjamin Hike
@BenJess
May 13 2017 00:47
@deaninous welcome :)
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:48
delte the return result part @cwborion
  return lookUp[val];
}
return result;
Cindy Chew
@cindychewy
May 13 2017 00:48
@NahuelOvejero @BenJess im totally clueless now.
deaninous
@deaninous
May 13 2017 00:48
thank you @BenJess
CamperBot
@camperbot
May 13 2017 00:48
deaninous sends brownie points to @benjess :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @benjess |http://www.freecodecamp.com/benjess
Cindy Chew
@cindychewy
May 13 2017 00:48
actually i stopped the syllabus for a month. now im completely lost oh no.
xNamek
@xNamek
May 13 2017 00:48
also delete the curly brace under the result
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:48
@cindychewy you need to use the formula given in the left
Caleb Brenner
@cwborion
May 13 2017 00:48
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookUp = {
    "alpha": Adams,
    "bravo": Boston,
    "charlie": Chicago,
    "delta": Denver,
    "echo": Easy,
    "foxtrot": Frank,
  };  
  return lookUp[val];
}

  // Only change code above this line




// Change this value to test
phoneticLookup("charlie");
Cindy Chew
@cindychewy
May 13 2017 00:48
how do u do math w a variable
Caleb Brenner
@cwborion
May 13 2017 00:48
the brace after return?
Damien
@DubbDevs
May 13 2017 00:48
hi Can I have some assistance with my code..working on the algorithm challenge
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:49
@cindychewy
This will given a parammter the double
var result = param *2
Cindy Chew
@cindychewy
May 13 2017 00:49
function convertToF(celsius) {
var fahrenheit;
var celsius*9/5 + 32;
Damien
@DubbDevs
May 13 2017 00:50
function findLongestWord(str) {
 var wordArray;
 var wordCounts;
 var sortedArray; 

    wordArray = str.split(" ");

      for (var i=0; i < wordArray.length; i++){
         wordCounts = wordArray[i].length;                         //I want wordCounts to be an array with the # of each word length, it only returns the length of last word
      }



  return wordCounts; /*str.length*/
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Cindy Chew
@cindychewy
May 13 2017 00:50
i want to convert celsius to fahrenheit
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:50
@cindychewy so fahrenheit is C * 9/5 + 32 ... how you will transalte that to code?
FlashHero
@FlashHero
May 13 2017 00:51

@cwborion you forgot your quotes in the values

"alpha": "Adams",

put quotes to all the values

Cindy Chew
@cindychewy
May 13 2017 00:51
@NahuelOvejero is it
var result=""
Benjamin Hike
@BenJess
May 13 2017 00:52
@cindychewy you’re on the right track, you just need to set one var. The project gives you a starting C val of 30 ‘convertToF(30). They give you the variable fahrenheit. So naturally fahrenheit will = the formula to change C to F. then "return fahrenheit”. will return the answer
Cindy Chew
@cindychewy
May 13 2017 00:52
result= C*9/5 + 32;
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:52
@cindychewy yeah.. exactly, you don't need to use var celcious, because is already given to you by parammeters
@cindychewy so result = celcius * 9/5 + 32 ... and result is farehenit ! :D
Caleb Brenner
@cwborion
May 13 2017 00:53
@FlashHero ah yeah, that’s what it was, often something small like that. I wasn’t sure if they belonged on the values, or the to the left of the ‘ : ‘ or on both haha. Thank you and the other folks for helping.
CamperBot
@camperbot
May 13 2017 00:53
cwborion sends brownie points to @flashhero :sparkles: :thumbsup: :sparkles:
:cookie: 179 | @flashhero |http://www.freecodecamp.com/flashhero
deaninous
@deaninous
May 13 2017 00:53
@DubbDevs you are on the right tack. you should have the counts in wordCount. So you want the maximum of that.
t0cc
@t0cc
May 13 2017 00:54
@forwebtech Or it is simply a debugger bug. Anyways, it's already to late. Thanks.
CamperBot
@camperbot
May 13 2017 00:54
t0cc sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 501 | @forwebtech |http://www.freecodecamp.com/forwebtech
Cindy Chew
@cindychewy
May 13 2017 00:54
omgg i got it thank you so much @NahuelOvejero and @BenJess !!!!!=)
CamperBot
@camperbot
May 13 2017 00:54
cindychewy sends brownie points to @nahuelovejero and @benjess :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @benjess |http://www.freecodecamp.com/benjess
:cookie: 375 | @nahuelovejero |http://www.freecodecamp.com/nahuelovejero
deaninous
@deaninous
May 13 2017 00:54
@DubbDevs and you have a bug when adding to wordCount
BarrienteM
@BarrienteM
May 13 2017 00:55
Hi I'm working on this challenge called Understanding Case Sensitivity in Variables and I'm having a tough time understanding it
Damien
@DubbDevs
May 13 2017 00:55
@deaninous yeah wordCounts is only giving me the count of the last word in the array, i thought it'd give me a count of each, since I've already split each word
deaninous
@deaninous
May 13 2017 00:55
use += instead of + @DubbDevs
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:56
@cindychewy no problem ! happy coding! :D
deaninous
@deaninous
May 13 2017 00:56
that way it would accumulate. Also I would have it as an array instead
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:56
@BarrienteM how much you have done?
Gavo Bon
@GavoGavo
May 13 2017 00:57
hey all. sometimes I think the ordering in FreeCodeCamp is confusing... it's probably me but... is if (num > 10) { return "Bigger than 10"; } else { return "10 or Less"; } the same as
BarrienteM
@BarrienteM
May 13 2017 00:57
@NahuelOvejero I've gotten to the last part of it but I reset without thinking so I'm back at the start
Gavo Bon
@GavoGavo
May 13 2017 00:58
if (num > 10) { return "Bigger than 10"; } { return "10 or Less"; }
Nahuel Ovejero
@NahuelOvejero
May 13 2017 00:58
@BarrienteM x) Its ok , what are the instructions?
deaninous
@deaninous
May 13 2017 00:59
@GavoGavo I am not sure about the braces surrounding your last return
Dylan Demnard
@kulpio
May 13 2017 00:59

Hi guys!
I am trying to get through the lesson "Return Early Pattern for Function". The thing I don't get is that I need to get an "undefined value if the a or b are smaller than 0. How do I get this "undefined value? I tried by injection an "undefined" value for a hypothetical c....did not work lol.
here is the code:

// Setup
function abTest(a, b) {
// Only change code below this line
abTest(a, b, c);

if(a<0 || b<0);

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);

Damien
@DubbDevs
May 13 2017 00:59
@deaninous shouldn't I have .push somewhere, I want wordCounts to be an array with each wordcount the example should return [3,5,5,3,6...] ....my logic is that thenI can sort by # and pop off the hightest...the current loop only returns 1 digit that's the lettercount of the last word
BarrienteM
@BarrienteM
May 13 2017 01:00
@NahuelOvejero it's saying all my assignments need to use the camelCase in both declaration and assignment sections
Gavo Bon
@GavoGavo
May 13 2017 01:00
sorry @deaninous ... I was attempting to alter the existing example but another similar example for the second one would be:
function ourTrueOrFalse(isItTrue) { if (isItTrue) { return "Yes, it's true"; } return "No, it's false"; }
Brittany Rutherford
@brittanyrutherford
May 13 2017 01:00
is there an easy way to write a blog post on wordpress without the hassle of uploading images first?
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:00
@BarrienteM well, camelCaseIsWritingLikeThis
Gavo Bon
@GavoGavo
May 13 2017 01:00
What I'm asking is: Isn't the "No" return supposed to be preceeded with an else
BarrienteM
@BarrienteM
May 13 2017 01:02
@NahuelOvejero I know it's case sensitive but it won't let me pass so really I'm not understanding why
deaninous
@deaninous
May 13 2017 01:02
You can initialize the wordCount var first // wordCount = [ ] // then in your for loop push or say // wordCount[i] = the value you want @DubbDevs
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:02
@BarrienteM what the test says?
Benjamin Hike
@BenJess
May 13 2017 01:02
@cindychewy no problem! :)
BarrienteM
@BarrienteM
May 13 2017 01:03
@NahuelOvejero Modify the existing declarations and assignments so their names use camelCase.
Do not create any new variables.
deaninous
@deaninous
May 13 2017 01:03
@GavoGavo Yupp, that should be good.
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:03
@BarrienteM can you show me the code?
BarrienteM
@BarrienteM
May 13 2017 01:04

@NahuelOvejero
// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

Gavo Bon
@GavoGavo
May 13 2017 01:04
@deaninous so: an else statement was implied in the structure of the second example... JS knew it was an else, because of the way it was laid out?
deaninous
@deaninous
May 13 2017 01:04
@kulpio undefined is a keyword. You should have it without the parens
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:05
@BarrienteM you need to change all of them to camelCase
Gavo Bon
@GavoGavo
May 13 2017 01:05
What's confusing me is that the second example comes from earlier in the course... but then they have Introducing Else Statements and say "what if an if statement is not true? The code would fail to run".. but there were examples given earlier which already showed this wasn't true. I find that really confusing and not so logical.
BarrienteM
@BarrienteM
May 13 2017 01:06
@NahuelOvejero if it's that simple i'm going to be kinda upset lol because i've been trying to figure it out for a while maybe I should take a break lol working to much today
deaninous
@deaninous
May 13 2017 01:06
yupp. @GavoGavo The return tells it that if the condition is true, return at this point. Forget everything after this point. So in the case it did not return, it keeps going till it was flaged to return
Dylan Demnard
@kulpio
May 13 2017 01:06

@deaninous sorry I don't get it. I tried that... doesn't work either:

// Setup
function abTest(a, b) {
// Only change code below this line

if(a<0 || b<0 === undefined);

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);

Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:06
@BarrienteM that is what I was trying to exaplin :P
BarrienteM
@BarrienteM
May 13 2017 01:07
it still won't let me pass
Franklin Sami
@cre8tivefranklin
May 13 2017 01:07
Hi everyone, I'm trying to return value.. but i cant seem to pull this off because ive already returned a number.. is it possible to return more than once within the same function?
BarrienteM
@BarrienteM
May 13 2017 01:08
@NahuelOvejero I changed them and it won't give me any checkmarks or anything
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:08
@cre8tivefranklin nope, it is not
deaninous
@deaninous
May 13 2017 01:08
@GavoGavo The presence of the return statement is key. if it were just a console.log function then the code will not return but keep going. return exits
Gavo Bon
@GavoGavo
May 13 2017 01:08
@deaninous Thanks! That's made it a little clearer. Cheers
CamperBot
@camperbot
May 13 2017 01:08
gavogavo sends brownie points to @deaninous :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @deaninous |http://www.freecodecamp.com/deaninous
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:09
@BarrienteM there are some wrong , reset the code and follow the instructions, read them carefully
deaninous
@deaninous
May 13 2017 01:09
if(a<0 || b<0 === undefined); @kulpio look at this part
no problem @GavoGavo
Dylan Demnard
@kulpio
May 13 2017 01:11
@deaninous well, I am looking at it, it is the only part I wrote LOL
should I make and if and else condition, one for a and one for b?
SpeedyPlays200
@SpeedyPlays200
May 13 2017 01:11
I'm stuck. What does it mean to define something??
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:12
@SpeedyPlays200 define, says what mean something. Create, mostly a function (at least in this course)
SpeedyPlays200
@SpeedyPlays200
May 13 2017 01:13
OK, Thanks!
deaninous
@deaninous
May 13 2017 01:13
if(a<0 || b<0){return undefined;}
@kulpio that is what you wanted ^^
Dylan Demnard
@kulpio
May 13 2017 01:14
@deaninous aaaaah! I thought I could not add a return since there was already a return statement at the end.... my bad. Thank you and sorry I had to pull the answer out of you.
CamperBot
@camperbot
May 13 2017 01:14
kulpio sends brownie points to @deaninous :sparkles: :thumbsup: :sparkles:
:cookie: 347 | @deaninous |http://www.freecodecamp.com/deaninous
Dylan Demnard
@kulpio
May 13 2017 01:14
Thank you
deaninous
@deaninous
May 13 2017 01:15
@kulpio this return is for the case a or b is undefined. Otherwise, it keeps runing till it hits a return statement that s valid
@DubbDevs how did it go?
Joseph
@revisualize
May 13 2017 01:23
@kulpio You need to learn how to write if conditions.
@kulpio If you don't learn how to write them properly you're going to have a lot of issues.
Damien
@DubbDevs
May 13 2017 01:28
so I'm a little closer...
for (var i=0; i < wordArray.length; i++)
        wordCounts += wordArray[i].length;
my wordCounts now returns a count of each word in the string but...it's not an Array?
deaninous
@deaninous
May 13 2017 01:30
+= works if wordcount is of type string. And the strings with be smooshed like "testing123isthiswork"
Damien
@DubbDevs
May 13 2017 01:30
so it'll show something like 35536433 when I was expecting [3,5,5,3,6,4,3]
yup!
can I sort that an have the highest number at the end and pop it off like an array?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:31
is wordCounts an empty array when you declare it?
@DubbDevs
Damien
@DubbDevs
May 13 2017 01:31
yes
deaninous
@deaninous
May 13 2017 01:31
easier if you had wordCount as an array instead
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:32
push the values into it
Damien
@DubbDevs
May 13 2017 01:32
yeah that was my original thinking @HeebieGeeBee but now I'm a bit turned around to be honest
deaninous
@deaninous
May 13 2017 01:32
declare your array as var wordCount = [ ] then the push op will work
Damien
@DubbDevs
May 13 2017 01:32

function findLongestWord(str) {
 var wordArray;
 var wordCounts = [];
 var sortedArray; 

    wordArray = str.split(" ");

      for (var i=0; i < wordArray.length; i++)
        wordCounts += wordArray[i].length;




  return wordCounts; /*str.length*/
}

findLongestWord("The quick brown fox jumped over the lazy dog");
deaninous
@deaninous
May 13 2017 01:32
@DubbDevs
 wordCounts += wordArray[i].length;
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:34
@DubbDevs well, if your going to be using sort there is no need for that loop
but if youre going to use a loop theres no need for a sort method, or to generate an array
Eduar Tua
@eduartua
May 13 2017 01:38

Guys in this code:

$(document).ready(function(){
  $("btn-f").on("click", function() {
    $(".temperature").html("Test");
  });
  getWeather();  
});

Why the html method does not modify the div with temperature class?

The btn-f is the class of a button
Damien
@DubbDevs
May 13 2017 01:39
i thought the loop was needed to "loop" thru entire string and get each wordcount?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:39
yes you can do it that way, but if youre doing it that way you only need to find the greatest length with the loop, and then return that value
@DubbDevs
@eduartua is the button you click on the text of the html you want to change?
Eduar Tua
@eduartua
May 13 2017 01:41
@HeebieGeeBee No, I want to change the text of a div in the same container
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:42
@eduartua do lots of things have that class?
Eduar Tua
@eduartua
May 13 2017 01:43
Just one div have the .temperature class
Kelechi Chinaka
@ke1echi
May 13 2017 01:43

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

function checkObj(checkProp) {
  // Your Code Here
  if (checkObj.hasOwnProperty()) {
    return checkProp;
  }else {
    return "Not Found";
  }

}

// Test your code by modifying these values
checkObj("gift");
what am i doing wrong @HeebieGeeBee
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:43
@kelechichinaka what property you are checking? :P
Gabe Rotberg
@grotberg
May 13 2017 01:43
@eduartua you need to do .btn-f for the click statement
@eduartua with the period. without it, it isn't catching the event because it can't find that element
Kelechi Chinaka
@ke1echi
May 13 2017 01:44
myObj @NahuelOvejero
Nahuel Ovejero
@NahuelOvejero
May 13 2017 01:45
@kelechichinaka .hasOwnPropert(PROPERTYTOTEST)
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:45
@kelechichinaka youre not checking for the property checkProp
and then youre not returning that properties value if it is found
Eduar Tua
@eduartua
May 13 2017 01:46
I miss that period. thank you @HeebieGeeBee But it still does not change the text on the div
CamperBot
@camperbot
May 13 2017 01:46
eduartua sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1632 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Gabe Rotberg
@grotberg
May 13 2017 01:47
@eduartua can you link your codepen?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 01:47
@eduartua you have this in a codepen?
Gabe Rotberg
@grotberg
May 13 2017 01:49
@eduartua Ah, I see. You need to call that jquery statment on btn-f AFTER you create the button using javascript.
@eduartua Right now, you're trying to assign the function to that button, but the button doesn't exist yet. Then you create the button programmatically, but there's no click event assigned to it.
Eduar Tua
@eduartua
May 13 2017 01:50
So, should I switch the function calls right? first the that create the button and the waiting for click
??
Gabe Rotberg
@grotberg
May 13 2017 01:50
@eduartua So I'd either make the button part of the static HTML, or make sure to call $("btn-f").on("click", function() {...}); after you create it
@eduartua exactly
Eduar Tua
@eduartua
May 13 2017 01:52
Well I switched them but still does not work
Kelechi Chinaka
@ke1echi
May 13 2017 01:52

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

function checkObj(checkProp) {
  // Your Code Here
  if (checkObj.hasOwnProperty(myObj)) {
    return myObj;
  }else {
    return "Not Found";
  }

}

// Test your code by modifying these values
checkObj("gift");
still dont understand
Eduar Tua
@eduartua
May 13 2017 01:52
getWeather();
  $(".btn-f").on("click", function() {
    $(".temperature").html("Test");
  });
@kelechichinaka Loot at the argument of hasOwnProperty, there you should use the property
Inside the if condition
kreuel
@kreuel
May 13 2017 01:55
Hi Guys, got stuck in Mutation, i've managed to loop the letter of the second value to the first value.
Not sure why the first task(mutation(["hello", "hey"])) return 'true' instead of 'false'. here is my code below.
blob
Gabe Rotberg
@grotberg
May 13 2017 01:56
@eduartua it works for me if I put the $(".btn-f").on("click", function() { $(".temperature").html("Test"); }); right after the $(".info").html(html); line
Eduar Tua
@eduartua
May 13 2017 01:58
I thought i could work putting it after the call of getWeather function in the document.ready function
That is a little confusing
Gabe Rotberg
@grotberg
May 13 2017 01:59
@eduartua Remember, the ajax call is asynchronous. So you can't count on it finishing before the code continues.
@eduartua getJSON rather, in this case. Anything that depends on that completing should be called within its callback function.
deaninous
@deaninous
May 13 2017 02:01

```

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array…

``` @kreuel

Eduar Tua
@eduartua
May 13 2017 02:01
I think I have to read about it. Any recommendation?
Joseph
@revisualize
May 13 2017 02:01
@kelechichinaka Hey. You have a few issues.
Eduar Tua
@eduartua
May 13 2017 02:01
Thank you @grotberg
CamperBot
@camperbot
May 13 2017 02:01
eduartua sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @grotberg |http://www.freecodecamp.com/grotberg
deaninous
@deaninous
May 13 2017 02:02
@kreuel check the conditions you are testing for in your if statement befor returning
Eduar Tua
@eduartua
May 13 2017 02:03
Let me tell you if i got if. With the asynchronous thing what you mean is that the json call hasn't finished when the other jquery method is executed right?
@grotberg
kreuel
@kreuel
May 13 2017 02:03
@deaninous hi let me check it
Gabe Rotberg
@grotberg
May 13 2017 02:04
@eduartua Exactly. So, you call getWeather, and then it sends off the call to the API... but before the API comes back with a response (that takes a while, because the internet), the rest of the code continues on.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:04
what's the opposite of bash? what do we call the CLI on windows?
Joseph
@revisualize
May 13 2017 02:05
@kelechichinaka So you have a function declaration of function checkObj(checkProp) { } .. With that function declaration you have a function name of checkObj and you have a parameter of checkProp.
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
So, when you make a function call:
checkObj("pet") the parameter checkProp gets the value "pet".
checkObj("horse") the parameter checkProp gets the value "horse".
As mentioned above, you can then use the parameter inside of the function just like you'd use any other variable that holds a value.
..
I see that you're trying to use .hasOwnProperty() on a function. Which isn't a function method.
Eduar Tua
@eduartua
May 13 2017 02:05
I understand now, Thank you @grotberg
CamperBot
@camperbot
May 13 2017 02:05
eduartua sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:warning: eduartua already gave grotberg points
Gabe Rotberg
@grotberg
May 13 2017 02:05
@eduartua then, the API comes back, and fires off your callback function (the function within the getJSON statement). Which sort of continues on its own timeline, unrelated to the rest of the code that is running (and has in all likelyhood, already finished)
conlong
@conlong
May 13 2017 02:05
i can't figure out the regex used for the palindrome challenge?
deaninous
@deaninous
May 13 2017 02:05
@conlong what do you have so far?
Joseph
@revisualize
May 13 2017 02:07
@conlong What regex do you have?
@conlong What are you trying to remove?
And the reverse of that...
What are you trying to keep?
deaninous
@deaninous
May 13 2017 02:08
@brittanyrutherford Not sure if that is an opposite but they have DOS
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:10
@deaninous so do we say: command line commands, or cli commands, or command prompt, or DOS? :S
Joseph
@revisualize
May 13 2017 02:10
@brittanyrutherford There are two CLI's on Windows.
@brittanyrutherford cmd ... Command Prompt && Powershell
@brittanyrutherford We call them cmd (sea em dee) commands.
Eduar Tua
@eduartua
May 13 2017 02:11
Another question @grotberg , If I call another function inside that inner jquery method, Can I define that function wherever I want?
deaninous
@deaninous
May 13 2017 02:12
i would say DOS command. dont qoute me @brittanyrutherford
Gabe Rotberg
@grotberg
May 13 2017 02:13
@eduartua Yep. You can have the callback call a function defined outside of the callback itself. It will execute when the callback does.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:13
@revisualize but isn't bash a command prompt as well?
Joseph
@revisualize
May 13 2017 02:13
@brittanyrutherford Bash is a shell
Eduar Tua
@eduartua
May 13 2017 02:13
@grotberg even if I define at the top level of the file?
Kelechi Chinaka
@ke1echi
May 13 2017 02:13
so where am i suppose to use the .hasOwnProperty am kinda confused @revisualize
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:13
what's the difference between a shell and a command prompt? :(
don't they both accept commands?
Gabe Rotberg
@grotberg
May 13 2017 02:14
@eduartua Yup
Joseph
@revisualize
May 13 2017 02:14
@brittanyrutherford The both accept commands.
deaninous
@deaninous
May 13 2017 02:14
I stand corrected
Joseph
@revisualize
May 13 2017 02:14
@brittanyrutherford Basically they do the same thing.
Eduar Tua
@eduartua
May 13 2017 02:14
@grotberg that freedom does not lead to bad practices?
Just asking
deaninous
@deaninous
May 13 2017 02:14
 The commands in Windows are available from the Command Prompt and are called Command Prompt commands or CMD commands, but they are not DOS commands.
Joseph
@revisualize
May 13 2017 02:14
@brittanyrutherford Except at the core they do a LOT different things.
Joseph
@revisualize
May 13 2017 02:15
@kelechichinaka You're supposed to use the .hasOwnProperty() method inside of the if condition like you are.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:15
@revisualize so why can't I consider the command prompt as a shell? for me anything with black screen is a shell :S
for me shell is = command prompt
Gabe Rotberg
@grotberg
May 13 2017 02:15
@eduartua On the contrary, it allows you to build modular code. For example, you might have a function that formats and displays your temperature data. You can call that inside the API callback and then whenever the temperature needs reformatting (like when the unit switches).
Joseph
@revisualize
May 13 2017 02:15
@brittanyrutherford Is every car a Porsche ... Is every Porsche a car?
Eduar Tua
@eduartua
May 13 2017 02:16
@grotberg Cool thank you
CamperBot
@camperbot
May 13 2017 02:16
eduartua sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:16
yes every Porsche is a car
CamperBot
@camperbot
May 13 2017 02:16
:warning: eduartua already gave grotberg points
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:16
but the opposite is wrong
@deaninous thank you :)
CamperBot
@camperbot
May 13 2017 02:16
brittanyrutherford sends brownie points to @deaninous :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @deaninous |http://www.freecodecamp.com/deaninous
Joseph
@revisualize
May 13 2017 02:16
@brittanyrutherford So, calling the command prompt a shell isn't correct.
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:17
i drive every car like its porsche
Joseph
@revisualize
May 13 2017 02:17
@HeebieGeeBee Me too. Me ... too.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:17
@revisualize so a shell is > command prompt?
Joseph
@revisualize
May 13 2017 02:17
VRRRRRRROOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMMMMMMMMMMMMMMM
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:17
lol
Joseph
@revisualize
May 13 2017 02:17
@brittanyrutherford No.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:17
car is > Porsche :(
Joseph
@revisualize
May 13 2017 02:17
@brittanyrutherford Look. We could sit down and do a deep dive .. a deep deep dive.
@brittanyrutherford You can enter commands into a shell.
@brittanyrutherford You can enter commands into a command prompt
@brittanyrutherford But, they do different functions at their core.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:18
ok ..
Joseph
@revisualize
May 13 2017 02:18
@brittanyrutherford One is an emulator of shell like tasks.
The other is a shell
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:19
ok. thank you @revisualize
CamperBot
@camperbot
May 13 2017 02:19
brittanyrutherford sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3951 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 13 2017 02:19
@brittanyrutherford It can get really confusing.
@brittanyrutherford But, if you want to just talk about it on the surface level.
@brittanyrutherford They basically achieve the same task. Differently.
@brittanyrutherford Why are you asking?
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:21
is bash something that I can install on windows?
Joseph
@revisualize
May 13 2017 02:21
@brittanyrutherford Yes.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:21
I want to write an email to my manager, so I don't know the exact terms to use
Joseph
@revisualize
May 13 2017 02:21
@brittanyrutherford Which version of Windows?
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:22
I am not sure what they use
but I just wanted to know the name of bash on windows
if I can call it bash too
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:23
doesnt your windows come with powershell?
Joseph
@revisualize
May 13 2017 02:23
Windows 7, Windows 10 all have PowerShell
I run PowerShell all day long
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:25
does everything bash can do cant it?
deaninous
@deaninous
May 13 2017 02:26
there is gitbash
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:26
the .exe on windows, is called executable file?
deaninous
@deaninous
May 13 2017 02:26
for windows
Joseph
@revisualize
May 13 2017 02:26
@brittanyrutherford Yes.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:27
@deaninous yes I saw it, but is gitbash a bash executable, or git + bash together?
do I need to install git separately, or can I just install gitbash
Joseph
@revisualize
May 13 2017 02:28
This message was deleted
deaninous
@deaninous
May 13 2017 02:30
When I installedit, it came together and I think you had the option to install both or to drop one. @brittanyrutherford
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:31
ah ok
one last question, do I call PowerShell commands as commands or cmdlets?
Joseph
@revisualize
May 13 2017 02:33
@brittanyrutherford cmdlets
commandlets
deaninous
@deaninous
May 13 2017 02:34
I think there are commands and cmkltets and there is a difference. Not a powershell guy
Joseph
@revisualize
May 13 2017 02:34
@brittanyrutherford Per Jeffrey Snover they are cmdlets
I sit in Powershell all day.
I also watched the MS training video that Jeffrey Snover hosted about PowerShell.
They are cmdlets
I shook his hand once too.
Not that that really means anything.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:37
hehe
thank you @revisualize
CamperBot
@camperbot
May 13 2017 02:37
brittanyrutherford sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: brittanyrutherford already gave revisualize points
deaninous
@deaninous
May 13 2017 02:37
alright @revisualize as I said, I am not a powershell guy
Joseph
@revisualize
May 13 2017 02:38
I'm a Senior Network Systems Administrator in a Windows environment.
Eduar Tua
@eduartua
May 13 2017 02:39
guys, can I add two classes to a jquery method or Should I write two diff methods?
deaninous
@deaninous
May 13 2017 02:39
How Cmdlets Differ from Commands

Cmdlets differ from commands in other command-shell environments in the following ways:

    Cmdlets are instances of .NET Framework classes; they are not stand-alone executables.

    Cmdlets can be created from as few as a dozen lines of code.

    Cmdlets do not generally do their own parsing, error presentation, or output formatting. Parsing, error presentation, and output formatting are handled by the Windows PowerShell runtime.

    Cmdlets process input objects from the pipeline rather than from streams of text, and cmdlets typically deliver objects as output to the pipeline.

    Cmdlets are record-oriented because they process a single object at a time.
dinosaurjude
@dinosaurjude
May 13 2017 02:39
so i got really frustrated and ended up looking up how to do the profile lookup. should i redo all the lessons where i started struggling or should i continue on?
@revisualize I forgot to mention that I know google foo. Didnt I?
Joseph
@revisualize
May 13 2017 02:41
Google-fu is a good fu to know.
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:41
what do we call PowerShell/command prompt/bash .. tools? If I want to talk about them in a specific sentence?
Joseph
@revisualize
May 13 2017 02:42
@brittanyrutherford ummm... Don't know.
Command Line Interfaces
Brittany Rutherford
@brittanyrutherford
May 13 2017 02:44
alright :) I am done with this
Joseph
@revisualize
May 13 2017 02:45
@brittanyrutherford What the hell were you writing?
@brittanyrutherford What do you do?
Damien
@DubbDevs
May 13 2017 02:46
@deaninous @HeebieGeeBee i finally got it! find the longest word in a string...warning my code/logic is UGLY but it worked..can you help me with ideas to improve
function findLongestWord(str) {
 var wordArray;
 var wordCounts = [];
 var sortedArray = []; 
 var answer; 

    wordArray = str.split(" ");


     for (var i=0; i < wordArray.length; i++) 
        wordCounts.push(wordArray[i].length);  

  wordCounts.sort(function(a,b){
    return a - b;
  });

      answer  = wordCounts.pop();





  return answer; /*str.length*/
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Anthony
@anthonyblackmandvc
May 13 2017 02:47
grats
Joseph
@revisualize
May 13 2017 02:47
@DubbDevs That's a lot of code.
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:47
@DubbDevs just use the sort function
sort the split string array by their lengths
Anthony
@anthonyblackmandvc
May 13 2017 02:48
you can split the string just by starting with str.split(" ");
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:48
and then return either the first element or last elements length depending on how you sort it
Damien
@DubbDevs
May 13 2017 02:49
I thought I tried that before and the sort wasn't working for me thought I needed to get word counts then sort those
Joseph
@revisualize
May 13 2017 02:49
@brittanyrutherford You know on Linux BASH is usually accessed via the Terminal.
deaninous
@deaninous
May 13 2017 02:49
@DubbDevs It is pretty impressive.
Anthony
@anthonyblackmandvc
May 13 2017 02:49
you can sort the elements, but they dont teach you how in the earlier challenges
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:49
ust use .length on a and b in teh sort callback
Anthony
@anthonyblackmandvc
May 13 2017 02:49
i had to learn in the hard way. and by hard i mean, i had to ask around =)
Caleb Brenner
@cwborion
May 13 2017 02:49
Not sure what I’m doing wrong here, the first one comes out right, but everything following it doesn’t.

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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.gift) {
    return "pony";
  } else if (myObj.pet) {
    return "kitten";
  } else if (myObj.bed) {
    return "sleigh";
  } else if (myObj.house) {
    return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");
Joseph
@revisualize
May 13 2017 02:50
@cwborion So you have a function declaration of function checkObj(checkProp) { } .. With that function declaration you have a function name of checkObj and you have a parameter of checkProp.
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
So, when you make a function call:
checkObj("pet") ... the parameter checkProp gets the value of the arguement "pet".
checkObj("horse") ... the parameter checkProp gets the value of the arguement "horse".
As mentioned above, you can then use the parameter inside of the function just like you'd use any other variable that holds a value.
Now, the lesson is trying to teach you about the object method .hasOwnProperty()
deaninous
@deaninous
May 13 2017 02:50
flows nicely and self explained !! @DubbDevs
Anthony
@anthonyblackmandvc
May 13 2017 02:50
sort *by element
Manny
@Alloffices
May 13 2017 02:50
All are passing except return false Mutations:Challenge
function mutation(arr) {
  do {
    return true;
  } 
  while (arr.indexOf(arr) >= -1);
}
mutation(["hello", "hey"]);
Joseph
@revisualize
May 13 2017 02:51
@Alloffices Because all your function is doing is returning true
Eduar Tua
@eduartua
May 13 2017 02:51
Guys I just finished the Weather App challenge
Could you give me some feedback?
Joseph
@revisualize
May 13 2017 02:51
You might as well just write:
function mutation(arr) {
    return true;
}
Eduar Tua
@eduartua
May 13 2017 02:51
Damien
@DubbDevs
May 13 2017 02:52
so the sort can sort by lengths....gotta look into that
Eduar Tua
@eduartua
May 13 2017 02:52
Let me know if works fine
Damien
@DubbDevs
May 13 2017 02:52
I know my code and thinking was verbose to say the least
Caleb Brenner
@cwborion
May 13 2017 02:52
@revisualize so I shouldn’t even be usin IfElse statments?
Anthony
@anthonyblackmandvc
May 13 2017 02:52
@eduartua its too cold!
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:52
@DubbDevs arr.sort((a,b) => a.length - b.length)
Joseph
@revisualize
May 13 2017 02:53
@cwborion No you should. But, you only need 1.
Caleb Brenner
@cwborion
May 13 2017 02:53
@revisualize okay, still pretty lost haha, but I’ll mess with it
Jake
@NeelDVirus
May 13 2017 02:54
what will be the instance when event.buttons = null for mousemove event?
Anthony
@anthonyblackmandvc
May 13 2017 02:54
@eduartua degree's out two decimal places. is that a requirement for the app?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:54
@eduartua looks nice works well
Jason Luboff
@JLuboff
May 13 2017 02:55
That's some fancy syntax
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:56
@JLuboff wb
Damien
@DubbDevs
May 13 2017 02:56
@HeebieGeeBee Thanks definitely going to try that. Thanks ! @deaninous @anthonyblackmandvc @revisualize
CamperBot
@camperbot
May 13 2017 02:56
dubbdevs sends brownie points to @heebiegeebee and @deaninous and @anthonyblackmandvc and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 248 | @anthonyblackmandvc |http://www.freecodecamp.com/anthonyblackmandvc
:star2: 1633 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 350 | @deaninous |http://www.freecodecamp.com/deaninous
:star2: 3952 | @revisualize |http://www.freecodecamp.com/revisualize
Eduar Tua
@eduartua
May 13 2017 02:58
@anthonyblackmandvc It doesn't but when I was changing the temperature's scale I was getting like ten decimals, so I rounded it to two decimals
Jason Luboff
@JLuboff
May 13 2017 02:58
@HeebieGeeBee I'm back momentarily...getting a short workout in...then have some stuff to do
HeebieGeeBee
@HeebieGeeBee
May 13 2017 02:59
cool
Jason Luboff
@JLuboff
May 13 2017 03:00
What is it...4 am over there?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:01
5
Jason Luboff
@JLuboff
May 13 2017 03:03
Dang.
Pearl
@Jiaaa1014
May 13 2017 03:03
var Bike = function() {

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

  this.setGear = function(change) {
    gear += change;

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

};
var Bike = function() {

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

  this.setGear = function(change) {
    gear = change;

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

};
why the second is true?
Jason Luboff
@JLuboff
May 13 2017 03:03
Does your family/friends ever call you at like 5 in the afternoon and you blow them off since you're sleeping?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:04
you assume that i get phonecalls
...funny
@Jiaaa1014 because youre just re assigning the variable in the second, not adding to it
Joseph
@revisualize
May 13 2017 03:06
la la la la
Anthony
@anthonyblackmandvc
May 13 2017 03:06
and your gear isn't set to a 0 in the second example. not sure if that really matters or not tho
Caleb Brenner
@cwborion
May 13 2017 03:06
@revisualize am I any closer? This is as close to the example code as I could possibly make it.
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  checkObj.hasOwnProperty("gift");
  checkObj.hasOwnProperty("pet");
  checkObj.hasOwnProperty("bed");
  if (myObj.house) {
  return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:06
and btw im rarely sleeping at 5pm
@JLuboff
Joseph
@revisualize
May 13 2017 03:07
@cwborion No.
@cwborion What is checkObj?
Caleb Brenner
@cwborion
May 13 2017 03:07
the function
Joseph
@revisualize
May 13 2017 03:07
@cwborion Okay. Can you use the .hasOwnProperty() method on a function?
@cwborion The Object method.hasOwnProperty() returns a boolean (true/false) indicating whether the object has the specified property as own (not inherited) property.
Caleb Brenner
@cwborion
May 13 2017 03:08
@revisualize I’m assuming not, but FCC hasn’t really said much about that other than this first exercise so I don’t know.
Anthony
@anthonyblackmandvc
May 13 2017 03:08
would it be better to use checkProp?
Joseph
@revisualize
May 13 2017 03:09
@cwborion You use the .hasOwnProperty() Object method to see if an Object has a property.
@cwborion Next question: what is checkProp?
Caleb Brenner
@cwborion
May 13 2017 03:10
@revisualize the variable?
Joseph
@revisualize
May 13 2017 03:10
@cwborion Parameter. But, you use it like a variable.
@cwborion What type of value does the .hasOwnProperty() method return?
Caleb Brenner
@cwborion
May 13 2017 03:10
@revisualize I switched checkObj with checkProp
Joseph
@revisualize
May 13 2017 03:10
@cwborion Well, that's wrong.
Jason Luboff
@JLuboff
May 13 2017 03:11
@HeebieGeeBee I mean...you gotta get calls sometimes...
Joseph
@revisualize
May 13 2017 03:11
@cwborion Is checkProp an Object?
Caleb Brenner
@cwborion
May 13 2017 03:11
@revisualize no the parameter that should get the information from myObj
Joseph
@revisualize
May 13 2017 03:11
@cwborion What did you do to your code?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:11
@JLuboff during the day just ppl trying to sell stuff
Joseph
@revisualize
May 13 2017 03:11
@cwborion Do you realize that the object is myObj?
He11aWor1d
@He11aWor1d
May 13 2017 03:12
help, in the course "Profile Lookup",I meet some unknown trouble
Joseph
@revisualize
May 13 2017 03:12
@He11aWor1d What is your function?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:12
but i would say phonecalls dont happen that much with friends actually
Caleb Brenner
@cwborion
May 13 2017 03:12
@revisualize yes I realize that
He11aWor1d
@He11aWor1d
May 13 2017 03:12

`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 lookUp(firstName, prop){
// Only change code below this line
var i=0;
var temp="";
while(i<contacts.length){
if(contacts[i][firstName]==firstName && contacts[i][prop]){
temp = contacts[i][prop];
}
if(contacts[i][firstName]!=firstName){
temp = "No such contact";
}
if(!contacts[i][prop]){
temp = "No such property";
}
i++;
}
return temp;
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");`

Joseph
@revisualize
May 13 2017 03:12
@cwborion So you use .hasOwnProperty() on an object.
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:12
mostly just text messages or messengers @JLuboff
Joseph
@revisualize
May 13 2017 03:13
@cwborion What's the current state of your function?
Caleb Brenner
@cwborion
May 13 2017 03:14
@revisualize this is what I have now.

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

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("gift");
  myObj.hasOwnProperty("pet");
  myObj.hasOwnProperty("bed");

  return "Not Found";
}

// Test your code by modifying these values
checkObj("gift”);
Joseph
@revisualize
May 13 2017 03:14
@cwborion Okay what type of a value does .hasOwnProperty() return to the caller?
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:15
holy crap 70 percent of all agriculture crops in america are used to feed cows
Anthony
@anthonyblackmandvc
May 13 2017 03:15
sounds about right
He11aWor1d
@He11aWor1d
May 13 2017 03:15
@revisualize could you see something wrong with my code?
Caleb Brenner
@cwborion
May 13 2017 03:15
@revisualize the corresponding value from myObj
Joseph
@revisualize
May 13 2017 03:15
@cwborion No.
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:15
thats a lot of beef
Joseph
@revisualize
May 13 2017 03:16
@He11aWor1d I see lots of things wrong with your code.
He11aWor1d
@He11aWor1d
May 13 2017 03:16
....
Caleb Brenner
@cwborion
May 13 2017 03:16
@revisualize I have no idea then..
Joseph
@revisualize
May 13 2017 03:16
@cwborion The Object method.hasOwnProperty() returns a boolean (true/false) indicating whether the object has the specified property as own (not inherited) property.
deaninous
@deaninous
May 13 2017 03:16
@HeebieGeeBee that gives me the heegeebeegees
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:16
lol
He11aWor1d
@He11aWor1d
May 13 2017 03:17
@revisualize I have no idea about it
Jason Luboff
@JLuboff
May 13 2017 03:17
@HeebieGeeBee Americans love their steak and dairy
Joseph
@revisualize
May 13 2017 03:17
:cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone: :cow2: :hamburger: :meat_on_bone:
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:17
they do make tasty burgers
Anthony
@anthonyblackmandvc
May 13 2017 03:17
oh this whole time i was reading herbiebeegee. i was like this dude loves 70s music
HeebieGeeBee
@HeebieGeeBee
May 13 2017 03:18
lol
Joseph
@revisualize
May 13 2017 03:18
@cwborion Okay what type of a value does .hasOwnProperty() return to the caller?
Caleb Brenner
@cwborion
May 13 2017 03:19
@revisualize true or false
a boolean
Joseph
@revisualize
May 13 2017 03:19
@cwborion Correct.
@cwborion What do if conditional statement trigger from?
Caleb Brenner
@cwborion
May 13 2017 03:19
@revisualize functions?
Joseph
@revisualize
May 13 2017 03:19
@cwborion No.
A boolean
@cwborion Do you not see that I'm leading you down a path?
Brittany Rutherford
@brittanyrutherford
May 13 2017 03:21
@revisualize sorry I didn't see your message hehe
Manny
@Alloffices
May 13 2017 03:21
@revisualize No sure why it's passing for some and not others _ Mutations
function mutation(arr) {
  var arrOne = arr[0];
  var arrTwo = arr[1];
  var arraY = [];
  var i;
  for (i=0;i<arrTwo.length;i++) {
    return arrOne.indexOf(arrTwo[i]) !== -1;
  }
}
mutation(["hello", "w"]);
Brittany Rutherford
@brittanyrutherford
May 13 2017 03:21
I was writing an email to my manager
deaninous
@deaninous
May 13 2017 03:23
The moment your code hits return. It wont wait to check to other elements. It will return @Alloffices
Caleb Brenner
@cwborion
May 13 2017 03:23
@revisualize it’s hard to say. I only get to work on this like two days a week and FCC doesn’t have any form of helpful review other than the large map that is tedious to go back through for particular lessons, so my vocabulary doesn’t stick well, so a lot of what you’re saying I can remember from other lessons but have trouble implenting when I’ve got it in front of me.
Joseph
@revisualize
May 13 2017 03:23
@cwborion So, .hasOwnProperty() returns a boolean value to the caller and if conditional statements are triggered via a boolean value via the if condition ... Maybe you should put a call via .hasOwnProperty() inside of an if condition.
if (condition) {
     statement
}
Caleb Brenner
@cwborion
May 13 2017 03:24
@revisualize okay I will mess with that. I never would have thought in the slightest to do that
Joseph
@revisualize
May 13 2017 03:25
@cwborion Then remember that we discussed how checkProp was a parameter that holds a value and is used inside of your function just like a variable?
@cwborion Remember this shit too:
So you have a function declaration of function checkObj(checkProp) { } .. With that function declaration you have a function name of checkObj and you have a parameter of checkProp.
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
So, when you make a function call:
checkObj("pet") ... the parameter checkProp gets the value of the arguement "pet".
checkObj("horse") ... the parameter checkProp gets the value of the arguement "horse".
As mentioned above, you can then use the parameter inside of the function just like you'd use any other variable that holds a value.
Now, the lesson is trying to teach you about the object method .hasOwnProperty()
Caleb Brenner
@cwborion
May 13 2017 03:26
@revisualize okay cool, thank you. I will start it with
if (checkProp) {
CamperBot
@camperbot
May 13 2017 03:26
cwborion sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3953 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 13 2017 03:26
@cwborion Well, you want a LOT more in that condition.
Anthony
@anthonyblackmandvc
May 13 2017 03:27
@cwborion i have that same issue. im thinking about going back over the initial lessons while taking notes.
Joseph
@revisualize
May 13 2017 03:28
@anthonyblackmandvc What's the state of your function?
Caleb Brenner
@cwborion
May 13 2017 03:28
@revisualize damnit lol.
@anthonyblackmandvc yeah, it’s frustrating, you’d think they would make some sort of review per section or emphasize particular things.
Anthony
@anthonyblackmandvc
May 13 2017 03:28
oh, im not stuck on anything at the moment. I was just giving some encouragement to @cwborion
i just finished "truncate a string". probably a bit sloppy on the code, but it works. I'm taking a little break and watching other people hand out advice.
Joseph
@revisualize
May 13 2017 03:30
@cwborion Do you really not understand what's going on?
@cwborion Would it be easier if we just got on a live session and hashed it out?
Caleb Brenner
@cwborion
May 13 2017 03:31
@revisualize no man, sorry. I have no idea how to take all this information and apply it.
@revisualize yeah that would probably be more helpful
I’m so lost
Anthony
@anthonyblackmandvc
May 13 2017 03:31
@revisualize i think what happens is, its easy to blow thru the first few hundred challenges. and instead of soaking it in, we keep plowing til we hit a wall
Joseph
@revisualize
May 13 2017 03:31
@cwborion Let me open up a codeshare. One second.
zhaoxiaopeng
@zhaoxiaopeng3
May 13 2017 03:32

hello everyone! Understanding Case Sensitivity in Variables// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

var studlyCapVar=10;
var properCamelCase="A String";
var titleCaseOver=9000;

Anthony
@anthonyblackmandvc
May 13 2017 03:32
@cwborion folks are so damn nice here. super helpful.
Caleb Brenner
@cwborion
May 13 2017 03:33
@anthonyblackmandvc yeah man even many of the other challenges around this one aren’t too difficult, but there are some random ones that leave one feeling stranded. You’re right though, everyone is very helpful and kind, which is humbling when you want to freak out lol
Anthony
@anthonyblackmandvc
May 13 2017 03:35
@zhaoxiaopeng3 i think it also wants you to fix the ones under assignments?
Joseph
@revisualize
May 13 2017 03:35
@cwborion Codeshare isn't working for me. One second.
Damn it.. Nothing is working.
WTF!
Caleb Brenner
@cwborion
May 13 2017 03:39
@revisualize I don’t think I would struggle as much if the example on the same exercise was written out the same, but there isn’t even a function in the example so me, as a novice, am completely thrwon off on how to go about it.
Anthony
@anthonyblackmandvc
May 13 2017 03:42
@cwborion which challenge is that?
Caleb Brenner
@cwborion
May 13 2017 03:43
@anthonyblackmandvc “Testing Objects for Properties"
Joseph
@revisualize
May 13 2017 03:44
@cwborion Hey.
Anthony
@anthonyblackmandvc
May 13 2017 03:45
so the example has a big clue in it
Anthony
@anthonyblackmandvc
May 13 2017 03:46
and its kinda nice that the example doesn't have a function. it helped me wrap my head around what a function is a little better after tinkering with it for a while. I remember that particular one pretty clearly.
smacked my head against it for atleast an hour
Caleb Brenner
@cwborion
May 13 2017 03:46
@revisualize brought me to a page
zhaoxiaopeng
@zhaoxiaopeng3
May 13 2017 03:46
@anthonyblackmandvc Thankyou!
CamperBot
@camperbot
May 13 2017 03:46
zhaoxiaopeng3 sends brownie points to @anthonyblackmandvc :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @anthonyblackmandvc |http://www.freecodecamp.com/anthonyblackmandvc
Caleb Brenner
@cwborion
May 13 2017 03:46
@anthonyblackmandvc yeah I tried writing mine as similar as possible to the example but it didn’t do a whole lot for me.
Joseph
@revisualize
May 13 2017 03:46
@cwborion I'm talking can you hear me?
Anthony
@anthonyblackmandvc
May 13 2017 03:47
@zhaoxiaopeng3 no prob, hope that helped.
Caleb Brenner
@cwborion
May 13 2017 03:49
@revisualize i hear you
rivalino
@rivalino
May 13 2017 03:49
hello, how can I show code with colors lol
Caleb Brenner
@cwborion
May 13 2017 03:51
@revisualize yeah man I’ve never been on that page that you gave me a link to
heroiczero
@heroiczero
May 13 2017 03:51
@rivalino if u want to show code here try ''' :point_down:
CamperBot
@camperbot
May 13 2017 03:51
:bulb: to format code use backticks! ``` more info
Caleb Brenner
@cwborion
May 13 2017 03:51
@revisualize I’m typing in the top window and nothing is happening
Joseph
@revisualize
May 13 2017 03:51
@cwborion I just need you to be able to hear me and be able to see the text that I'm typing into the editor. Can you replace the text in the comment like in FreeCodeCamp?
Caleb Brenner
@cwborion
May 13 2017 03:52
@revisualize yeah it isn’t allowing me to type there
Joseph
@revisualize
May 13 2017 03:53
But, you can hear the words from my mouth?
Peter Kay
@deuscode
May 13 2017 03:53
data[1].forEach(function(apiData, i)
Caleb Brenner
@cwborion
May 13 2017 03:53
@revisualize yes I hear all of it. Trains in the backgound all the words
Peter Kay
@deuscode
May 13 2017 03:53
so how can I change this forEach to use a fat arrow?
Coy Sanders
@coymeetsworld
May 13 2017 03:54
(apiData, i) => { }
Anthony
@anthonyblackmandvc
May 13 2017 03:54
function truncateString(str, num) {
  //create an empty array
 var arr = [];
  //if statement for numbers 3 or less
  if (num < 4 ){
  //slice starting at 0 and using num as the number to slice off
   return str.slice(str, num) + "..."; 
  //else if the string length is greater than the number
 } else if (str.length > num) {
   //slice into a new array using 0 and the number less 3 to include space for the dots.
   arr = str.slice(str , num - 3);
   return arr + "...";
 } else {
   return str;
 }
}
truncateString("A-tisket a-tasket A green and yellow basket", 6);
Peter Kay
@deuscode
May 13 2017 03:55
get rid of the function and beginning parentheses?
@coymeetsworld sweet thanks for the help, I'll test that out
CamperBot
@camperbot
May 13 2017 03:55
deuscode sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2584 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Anthony
@anthonyblackmandvc
May 13 2017 03:55
why does this not work wth negative numbers? oops wait, wrong code
Coy Sanders
@coymeetsworld
May 13 2017 03:55
function(x,y) {
  return x*y;
}
(x,y) => { return x*y; }
rivalino
@rivalino
May 13 2017 03:56
var test = 0;
Peter Kay
@deuscode
May 13 2017 03:56
 data[1].forEach(apiData, i) => {
so would this mean it would look like this ?
Coy Sanders
@coymeetsworld
May 13 2017 03:57
no
rivalino
@rivalino
May 13 2017 03:57
var test = 0;
Peter Kay
@deuscode
May 13 2017 03:58
@coymeetsworld if I wanted to incorporate a forEach loop with the fat arrow, is there a syntax issue with what I'm trying to do?
Coy Sanders
@coymeetsworld
May 13 2017 03:58
yes
try again, you're replacing too much
Caleb Brenner
@cwborion
May 13 2017 03:59
@revisualize following so far
Peter Kay
@deuscode
May 13 2017 03:59
 data[1].forEach((apiData, i) => { //stuff });
@coymeetsworld thanks alot! it clicked!
CamperBot
@camperbot
May 13 2017 03:59
deuscode sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: deuscode already gave coymeetsworld points
Coy Sanders
@coymeetsworld
May 13 2017 04:00
np @deuscode
gj figuring it out
Peter Kay
@deuscode
May 13 2017 04:00
wow a lot easier than I thought
just moving the function over to the right into an arrow
Coy Sanders
@coymeetsworld
May 13 2017 04:00
yeah, if you had a one line like I had above with just a return statement you can use even less code
(x,y) => { return x*y; } could just be (x,y) => x*y
Peter Kay
@deuscode
May 13 2017 04:01
nice, is the return statement the default within that line?
so in an example
```
Anthony
@anthonyblackmandvc
May 13 2017 04:02
i saw a video about => that said it wasn't live yet. i think it was an old video tho, im guessing its live now?
Coy Sanders
@coymeetsworld
May 13 2017 04:02
let a = (x,y) => x*y;
undefined
a(3,5)
15
Peter Kay
@deuscode
May 13 2017 04:02
(x, y) => "hello"
is that valid?
Coy Sanders
@coymeetsworld
May 13 2017 04:02
yep that should work
Peter Kay
@deuscode
May 13 2017 04:03
thanks @coymeetsworld cleared up a lot in a few answers lol
CamperBot
@camperbot
May 13 2017 04:03
deuscode sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: deuscode already gave coymeetsworld points
Coy Sanders
@coymeetsworld
May 13 2017 04:03
yw
Caleb Brenner
@cwborion
May 13 2017 04:05
@revisualize yes, so far. A summary after will help too
so far so god
good
@revisualize yes, let me scan through it with what you said in mind and mention where I’m iffy on understanding
Caleb Brenner
@cwborion
May 13 2017 04:12
so you’re passing the parameter into the variable?
@revisualize
@revisualize could you briefly run through the exercise and re explain how the variable and parameter work together when they’re written together
Caleb Brenner
@cwborion
May 13 2017 04:18
@revisualize I’m confused too haha, sorry this is a lot of stuff swirling around in my head
@revisualize I chatted you privately
kickkick479
@kickkick479
May 13 2017 04:23
@cwborion Can you show your code after amending ?
rivalino
@rivalino
May 13 2017 04:25
Can someone explain why this code works when you enter 0.50 and doesn't work with 0.60?
function counting (number){
  var counter = 0;
  var money = [100.00, 20.00, 10.00, 5.00, 1.00, 0.25, 0.10, 0.05, 0.01];

  while (number > 0) {
    for (var i = 0 ; i < money.length ; i++) {
      if (number < money[i]) {
        continue;
      } else if (number >= money[i]) {
        number = number - money[i];
        counter++;
        break;
      } 
    }
  }
    return counter;
}
document.write(counting(0.50));
Caleb Brenner
@cwborion
May 13 2017 04:26
@revisualize okay, i believe that I understand now how the whole thing works. I was struggling to see how and where the call “gift” got sent into the function.
@revisualize is the only actual place that the call goes in between the brackets?
“gift"
@revisualize does it go into the [] or () or both?
@revisualize by having it written in the call in parentheses, I’m asking where it is sent by default above in the function
basically does it replace every place where “checkProp” is written?
@revisualize okay so it has a particular place where it is sent
@revisualize okay I’m pretty sure I’m grasping it now
YES
that’s what I was asking
Caleb Brenner
@cwborion
May 13 2017 04:31
@revisualize everywhere that it is written?
kickkick479
@kickkick479
May 13 2017 04:32
@rivalino Hi, can you explain the purpose of the counting function ? What count is that expected to return ?
rivalino
@rivalino
May 13 2017 04:32
just the number of times it takes to break the number apart @kickkick479
jaganjaan
@jaganjaan
May 13 2017 04:32
how to implement jquery-comments plugin to my code
rivalino
@rivalino
May 13 2017 04:33
for example 400 should be returning 4 @kickkick479
Caleb Brenner
@cwborion
May 13 2017 04:33
@revisualize awesome, I have a better grasp on how this works than pretty much all of the exercises that have given me trouble so far. Makes a huge difference having someone help out where FCC comes short. Thank you. Although, with the same code you wrote, there is something that is still preventing the test from being completed when I run it.
CamperBot
@camperbot
May 13 2017 04:33
cwborion sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3954 | @revisualize |http://www.freecodecamp.com/revisualize
Caleb Brenner
@cwborion
May 13 2017 04:33
@revisualize this is what I have
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {

    return myObj.[checkProp];

  } else {
  return "Not Found";
}
}


// Test your code by modifying these values
checkObj("gift");
kickkick479
@kickkick479
May 13 2017 04:34
@cwborion return myObj.[checkProp]; => return myObj[checkProp];
rivalino
@rivalino
May 13 2017 04:34
it should break it apart always refering to the (money) array @kickkick479
Caleb Brenner
@cwborion
May 13 2017 04:34
hahaha yes, thank you.
@revisualize yes man, I’m good. You were extermely helpful. I appreciate it.
kickkick479
@kickkick479
May 13 2017 04:35
@rivalino OK. But something is interrupting me. So give me a sec.
rivalino
@rivalino
May 13 2017 04:35
@kickkick479 np
Caleb Brenner
@cwborion
May 13 2017 04:35
@kickkick479 thanks also!
CamperBot
@camperbot
May 13 2017 04:35
cwborion sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 350 | @kickkick479 |http://www.freecodecamp.com/kickkick479
how to implement to my code
Vikram
@vikramnr
May 13 2017 04:37
arr1=arr.slice(size);
arr=arr.push(arr1[0]);
return arr;\this is always returning five any idea?? why so
deaninous
@deaninous
May 13 2017 04:37
@rivalino Your break statement is preventing it from exploring all elements < number but the first one.
Vikram
@vikramnr
May 13 2017 04:38
arr has ["a","b","c","d"]
any help please
Csaba Balogh
@JasonCorp84
May 13 2017 04:40
@vikramnr chunky monkey ?
@vikramnr what is the beginning and the ending index that you need to slice out ?
deaninous
@deaninous
May 13 2017 04:43
what value is seize and what is the initial value of arr? @vikramnr
Anthony
@anthonyblackmandvc
May 13 2017 04:44
im stuck on chunky monkey as well

function chunkArrayInGroups(arr, size) {
  var chunkArr = [];
  for ( var i = 0; i <= arr.length; i + size) {
  var arr1 = arr.slice(i , i + size);
  chunkArr.push(arr1);}
  return chunkArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
stuck in an infinite loop at the moment
Vikram
@vikramnr
May 13 2017 04:45
@deaninous the value is 2 @JasonCorp84 yes
@JasonCorp84 @deaninous first test case
Anthony
@anthonyblackmandvc
May 13 2017 04:46
@vikramnr maybe we can work through it together
would you mind posting your code?
my code would work if i could figure out how to get out of this infinite loop. then again maybe i'm approaching it from the wrong angle
rivalino
@rivalino
May 13 2017 04:47
@deaninous if that is the case why does it work with 101.01. it iterates to 100, then 1, then 0.01, it goes the whole array.
@deaninous it doesn't stop at 100
Vikram
@vikramnr
May 13 2017 04:50
@anthonyblackmandvc yeah but i haven't got this far
Anthony
@anthonyblackmandvc
May 13 2017 04:51
oh, youre not on chunky monkey?
Vikram
@vikramnr
May 13 2017 04:51
@anthonyblackmandvc I'm in the program..but i'm working out on first case only
Anthony
@anthonyblackmandvc
May 13 2017 04:52
ah. looks like you have it. your first slice would be .slice(0,2)
Vikram
@vikramnr
May 13 2017 04:52

function chunkArrayInGroups(arr, size) {
// Break it up
var orginalArr=arr; //[a,b,c,d]
var firstArr=arr.slice(2);//this should return [a,b]
var splitArr=arr.slice(size); //[c,d]
var finalArr=Array.prototype.push.apply(splitArr, firstArr);
return firstArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Anthony
@anthonyblackmandvc
May 13 2017 04:52
and second slice would be .slice(2,4)
does arr.slice(size) really return c,d?
Vikram
@vikramnr
May 13 2017 04:54
@anthonyblackmandvc I 'm still working :worried:
Anthony
@anthonyblackmandvc
May 13 2017 04:54
ok, i'll let you work it out. let me know if you make any progress
Vikram
@vikramnr
May 13 2017 04:54
@anthonyblackmandvc okay sure
Long Nguyen
@longnt80
May 13 2017 04:55

@anthonyblackmandvc

my code would work if i could figure out how to get out of this infinite loop.

you need to change this i + size

Anthony
@anthonyblackmandvc
May 13 2017 04:55
yeah, but im not sure how else to implement the concept
unless i need to rethink my whole code base
since i++ doesn't give the right iterations
deaninous
@deaninous
May 13 2017 04:57
@rivalino you are comparing floats that way. Your program is hanging inside your continue branch. And yes, your break statement woud prevent it from stepping to the next statement if the else block were to run
Anthony
@anthonyblackmandvc
May 13 2017 04:57
i need i to increase per loop at the rate of "size" without creating an infinite loop
is it impossible?
rivalino
@rivalino
May 13 2017 05:00
@deaninous what does it mean 'comparing floats'
Long Nguyen
@longnt80
May 13 2017 05:01
@anthonyblackmandvc what would you do if you want i to increase at the rate of 1?
Mahesh
@mahis929
May 13 2017 05:01
i could not understand the Word Blanks
pls someone help me with a solution
Anthony
@anthonyblackmandvc
May 13 2017 05:02
@longnt80 i'd i++
Long Nguyen
@longnt80
May 13 2017 05:02
@anthonyblackmandvc same thing would go with size
Niranjan Hegde
@niranjanhegde144
May 13 2017 05:02
how can i build a random quote generator
??
Anthony
@anthonyblackmandvc
May 13 2017 05:02
@longnt80 meaning what exactly?
Long Nguyen
@longnt80
May 13 2017 05:02
@anthonyblackmandvc no, sorry what would you do if you want to increase at the rate of 2
Anthony
@anthonyblackmandvc
May 13 2017 05:03
i + 2
Long Nguyen
@longnt80
May 13 2017 05:03
@anthonyblackmandvc no
Anthony
@anthonyblackmandvc
May 13 2017 05:03
ah, is that where im misstepping?
syntax?
Long Nguyen
@longnt80
May 13 2017 05:04
@anthonyblackmandvc remember i = i + 2 is the same as i += 2
Anthony
@anthonyblackmandvc
May 13 2017 05:04
i += 2?
Long Nguyen
@longnt80
May 13 2017 05:04
yes
Anthony
@anthonyblackmandvc
May 13 2017 05:04
ahh, let me try that
bam
Niranjan Hegde
@niranjanhegde144
May 13 2017 05:04
can some help me build a automatic quote generator??
Anthony
@anthonyblackmandvc
May 13 2017 05:04
it worked, thanks @longnt80
CamperBot
@camperbot
May 13 2017 05:04
anthonyblackmandvc sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 240 | @longnt80 |http://www.freecodecamp.com/longnt80
Anthony
@anthonyblackmandvc
May 13 2017 05:04
thats funny. I was banging my head for an hour...all I was missing was a blasted = sign =)
good to know my logic was sound tho
Long Nguyen
@longnt80
May 13 2017 05:06
that's a good solution
rlgerman25
@rlgerman25
May 13 2017 05:06
Hey, guys. I need help with my code. I am stuck in the "Check for Palindromes" challenge.
Heuer-C
@Heuer-C
May 13 2017 05:06
hello
blob
I'm so confused about this question can you help me
Alexandre Conrady
@Aberoom
May 13 2017 05:07
@Heuer-C you probably want a return false; line. Without the whole code it's tough to say whats wrong there.
Heuer-C
@Heuer-C
May 13 2017 05:07
:worried:
this is my code
Quentin Butler
@quentin1431
May 13 2017 05:08
@rlgerman25 Hi, you can share what you are stuck with now :)
Alexandre Conrady
@Aberoom
May 13 2017 05:08
@rlgerman25 post it in between these
```
top and bottom of code.
Heuer-C
@Heuer-C
May 13 2017 05:08
challenge"Falsy Bouncer"

function bouncer(arr) {
// Don't show a false ID to this bouncer.
var word=[false,null,0,"",undefined,NaN];
for(var i=0;i<word.length;i++){
arr=arr.filter(word[i]);
}
return arr;
}

bouncer([7, "ate", "", false, 9]);

Luke Bailey
@baileyl91
May 13 2017 05:08

Hi all, I having a little trouble with Word Blanks. My code is below:

result = ("The " + myNoun + myAdjective +" looked around " + myVerb + "then " + myAdverb + "into the house");

deaninous
@deaninous
May 13 2017 05:08
@rlgerman25
Luke Bailey
@baileyl91
May 13 2017 05:08
Am I missing something obvious?
Anthony
@anthonyblackmandvc
May 13 2017 05:08
@longnt80 i was very close to clearing my code again and starting from scratch too! Glad i asked.
Heuer-C
@Heuer-C
May 13 2017 05:09
filter this function , I am confused.
rlgerman25
@rlgerman25
May 13 2017 05:09

`function palindrome(str) {
var symbols = /\W|_/g;
str = str.replace(symbols, "").toLowerCase;
var reversed = str.replace(symbols, "").toLowerCase.split("").reverse("").join("");
return Boolean(str === reversed);
}

palindrome("eye");`

deaninous
@deaninous
May 13 2017 05:09
while (number > 0) {
    for (var i = 0 ; i < money.length ; i++) {
@rivalino
Alexandre Conrady
@Aberoom
May 13 2017 05:09
@baileyl91 yeah it looks like you could be missing spaces between some of those arguments
Long Nguyen
@longnt80
May 13 2017 05:09
@anthonyblackmandvc
I think fixing the infinite loop is easy, if the problem is the logic then you might need to clear your code
rlgerman25
@rlgerman25
May 13 2017 05:10
My output is: "TypeError: str.replace is not a function"
kickkick479
@kickkick479
May 13 2017 05:10
@rlgerman25 revese() need an argument? Did you read document?
Heuer-C
@Heuer-C
May 13 2017 05:10

function bouncer(arr) {
// Don't show a false ID to this bouncer.
var word=[false,null,0,"",undefined,NaN];
for(var i=0;i<word.length;i++){
arr=arr.filter(word[i]);
}
return arr;
}

bouncer([7, "ate", "", false, 9]);

Alexandre Conrady
@Aberoom
May 13 2017 05:10
@Heuer-C yeah, look up the .filter method on the MDN, you have to put a function into that method that will filter for you. RIght now your filter method isnt doing anything.
Anthony
@anthonyblackmandvc
May 13 2017 05:11
@longnt80 i figured my logic might be flawed if what I wanted to do led to an infinite loop. I was going to try to approach it from a different angle. glad I didn't.
Long Nguyen
@longnt80
May 13 2017 05:11
@anthonyblackmandvc no the infinite loop is caused by the conditions of the loop
Alexandre Conrady
@Aberoom
May 13 2017 05:11
@rlgerman25 look up regular expression on the MDN, you will learn how to write a regex that will find all the symbols and characters, then put that into your replace method at the place where you wrote symbols.
Quentin Butler
@quentin1431
May 13 2017 05:11
@rlgerman25 Use: return str === reversed;
Heuer-C
@Heuer-C
May 13 2017 05:11
oh!each time i want to use "filter" ,i need to write arr=arr.filter(function(){})? @Aberoom
rlgerman25
@rlgerman25
May 13 2017 05:12
@quentin1431 I did that. Same output.
Alexandre Conrady
@Aberoom
May 13 2017 05:12
@Heuer-C yep, unless you've made the function outside the method, then you just have to enter the callback.
Luke Bailey
@baileyl91
May 13 2017 05:12
@Aberoom I looked at spaces in between arguments and reset it to correct space, it won't run. It produce an error test 1 and test 2 not defined?
Anthony
@anthonyblackmandvc
May 13 2017 05:12
@longnt80 true but I'm not experienced enough with for loops to recognize when I have a bad plan or just bad syntax. glad it was the syntax this time.
Heuer-C
@Heuer-C
May 13 2017 05:13
@Aberoom ok!thank u!
Alexandre Conrady
@Aberoom
May 13 2017 05:13
cbot you there?
CamperBot
@camperbot
May 13 2017 05:13
you called?
Anthony
@anthonyblackmandvc
May 13 2017 05:13
lol
Alexandre Conrady
@Aberoom
May 13 2017 05:13
@baileyl91 alright show me your whole code
Anthony
@anthonyblackmandvc
May 13 2017 05:13
@Aberoom thanks!
CamperBot
@camperbot
May 13 2017 05:13
anthonyblackmandvc sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 335 | @aberoom |http://www.freecodecamp.com/aberoom
Anthony
@anthonyblackmandvc
May 13 2017 05:13
there you go
Quentin Butler
@quentin1431
May 13 2017 05:13
@rlgerman25 Also it's .toLowerCase(); With brackets.
Alexandre Conrady
@Aberoom
May 13 2017 05:14
@anthonyblackmandvc thanks buddy :D cbot needs a little help sometimes.
CamperBot
@camperbot
May 13 2017 05:14
aberoom sends brownie points to @anthonyblackmandvc :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @anthonyblackmandvc |http://www.freecodecamp.com/anthonyblackmandvc
aamirfreecode
@aamirfreecode
May 13 2017 05:15
image.png
rlgerman25
@rlgerman25
May 13 2017 05:15
@quentin1431 that was it
aamirfreecode
@aamirfreecode
May 13 2017 05:15
what is wrong
rlgerman25
@rlgerman25
May 13 2017 05:15
Thanks, man.
aamirfreecode
@aamirfreecode
May 13 2017 05:15
?
Luke Bailey
@baileyl91
May 13 2017 05:15

@Aberoom
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = ("The " + myNoun + myAdjective + " looked around " + myVerb + " then " + myAdverb + " into the house");

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

caneno
@caneno
May 13 2017 05:15
hi guy
can you guys help me with this, what am I doing wrong?
function palindrome(str) {
  // Good luck!
  var newStr = str.replace(/\W/g, '');
  var lowerStr = newStr.toLowerCase();
  var splitStr = lowerStr.split("");
  var revStr = splitStr.reverse();
  var joinStr = revStr.join("");
  if(lowerStr === joinStr){
    return true;
  }
  return false;

}



palindrome("_eye");
Quentin Butler
@quentin1431
May 13 2017 05:16
@rlgerman25 Cool, you can also change to these two lines:
str = str.replace(symbols, "").toLowerCase();
var reversed = str.split("").reverse().join("");
Alexandre Conrady
@Aberoom
May 13 2017 05:16
@baileyl91 oh, yeah, remove the parenthesis around your result = () stuff
caneno
@caneno
May 13 2017 05:16
it should return true but its returning false
aamirfreecode
@aamirfreecode
May 13 2017 05:17
image.png
caneno
@caneno
May 13 2017 05:17
and is there a way t simplify it?
Quentin Butler
@quentin1431
May 13 2017 05:18
@caneno Hi, /\W/g does not check for underscores, you will have to add it to your regex.
caneno
@caneno
May 13 2017 05:18
ooo ok
aamirfreecode
@aamirfreecode
May 13 2017 05:18
typeError: can't read property 0 of undefined
why this is happening
Alexandre Conrady
@Aberoom
May 13 2017 05:18
@caneno you can put a bunch of those methods on the same line to simplify. Other than that, a good debugging tip is to return the result you are checking at the end, so check you reverse string and normal string by adding them to an array during the process and then returning the array at the end. That way you can check if the methods are executing correctly, and see what might need to be changed.
Long Nguyen
@longnt80
May 13 2017 05:19
@aamirfreecode
can you copy your code here?
aamirfreecode
@aamirfreecode
May 13 2017 05:19

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];

// Only change code below this line
var sourceProp = Object.keys(source);

for(var i = 0; i<collection.length; i++){
for(var j=0; j<sourceProp.length; j++){
if(collection[i].hasOwnProperty(sourceProp[j]) && collection[i].sourceProp[j]===source.srouceProp[j]){
arr.push(collection[i]);
}
}
}

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Alexandre Conrady
@Aberoom
May 13 2017 05:20
@aamirfreecode in your code you wrote srouce instead of source at line 11 1/2
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];

  // Only change code below this line
  var sourceProp = Object.keys(source);

  for(var i = 0; i<collection.length; i++){
     for(var j=0; j<sourceProp.length; j++){
       if(collection[i].hasOwnProperty(sourceProp[j]) && collection[i].sourceProp[j]===source.srouceProp[j]){
      arr.push(collection[i]);
       }
     }
    }


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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
everyone, you can post your code like this if you add ``` at the top and bottom of your code in new lines.
aamirfreecode
@aamirfreecode
May 13 2017 05:22
@Aberoom Yes, I correct it, but result is same
Long Nguyen
@longnt80
May 13 2017 05:22
@aamirfreecode sourceProp[j] is a variable, you cannot use . to access it
Jor
@joreyesl
May 13 2017 05:22
@aamirfreecode you only want to push if the obj has all the properties in source.
Luke Bailey
@baileyl91
May 13 2017 05:23
@Aberoom Thank you so much
CamperBot
@camperbot
May 13 2017 05:23
baileyl91 sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @aberoom |http://www.freecodecamp.com/aberoom
caneno
@caneno
May 13 2017 05:23
thanks @quentin1431 and @Aberoom
CamperBot
@camperbot
May 13 2017 05:23
caneno sends brownie points to @quentin1431 and @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @aberoom |http://www.freecodecamp.com/aberoom
:cookie: 306 | @quentin1431 |http://www.freecodecamp.com/quentin1431
Long Nguyen
@longnt80
May 13 2017 05:23
@aamirfreecode source.sourceProp[j] this is wrong, you need to use []
not .
remember Access object property using bracket
Nahuel Ovejero
@NahuelOvejero
May 13 2017 05:25
you can access to object property using . if you know the key
Long Nguyen
@longnt80
May 13 2017 05:28
this case it is a variable, so it is wrong
aamirfreecode
@aamirfreecode
May 13 2017 05:35
@longnt80 thanks, it's work now, but another problem is there,
CamperBot
@camperbot
May 13 2017 05:35
aamirfreecode sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @longnt80 |http://www.freecodecamp.com/longnt80
aamirfreecode
@aamirfreecode
May 13 2017 05:37
image.png
there is still two red cross, still not clear this stage
Long Nguyen
@longnt80
May 13 2017 05:38
@aamirfreecode well, there's not error in your code, it's the logic that you need to fix
kickkick479
@kickkick479
May 13 2017 05:38
@aamirfreecode Did you test the case which failed? What result do they return and what difference does exsist between expectation and your result?
Jor
@joreyesl
May 13 2017 05:48
@aamirfreecode :point_up: May 13, 2017 1:22 AM
You need to keep track of how many times the if statement is true. You only want to push if the obj matches all the properties/values in source. Right now you will be pushing as long as 1 of them match.
Abdul Aleem
@OfficialOxide
May 13 2017 05:49
Hey. Could someone tell me what's wrong with my code (can't check against multiple values and return them)

function destroyer(arr) {
  // Remove all the values
  var args = [];
  for (var x = 1; x < arguments.length; x++) {
    args.push(arguments[x]);
  }
  return arr.filter(function (val) {
    for (var z = 0; z < args.length; z++) {
      if (args[z] !== val) {
        return val;
       }
      }
    });

}
destroyer([1, 2, 3, 1, 2, 3], 1, 3);
kickkick479
@kickkick479
May 13 2017 05:52
@OfficialOxide Hi, can you explain how to use filter()?
Abdul Aleem
@OfficialOxide
May 13 2017 05:53
you define a function in it, and in that function, you define the condition against which the values of the array is checked
Amit-Singh58
@Amit-Singh58
May 13 2017 05:53
var myStr = "I am a \"double quoted\" string ";
whats is wrong in this
Abdul Aleem
@OfficialOxide
May 13 2017 05:53
and if that condition is met, the values are returned in a new array (the original doesn't get altered)
Amit-Singh58
@Amit-Singh58
May 13 2017 05:54
have said to use 4 escape literals and two ""
Abdul Aleem
@OfficialOxide
May 13 2017 05:54
which challenge @Amit-Singh58
Amit-Singh58
@Amit-Singh58
May 13 2017 05:55
Escaping Literal Quotes in Strings
kickkick479
@kickkick479
May 13 2017 05:55
@OfficialOxide Yes. if the value in arr matched any values in args, the filter must return false.
Abdul Aleem
@OfficialOxide
May 13 2017 05:57
@Amit-Singh58 you have to do it like this:
"I am a \"double quoted\" string inside \"double quotes\".";
@kickkick479 the problem is, it only checks against the first element of args and not the second one, so it only works with one
Amit-Singh58
@Amit-Singh58
May 13 2017 05:58
@OfficialOxide my bad i missed the remaining string..thanks for help
CamperBot
@camperbot
May 13 2017 05:58
amit-singh58 sends brownie points to @officialoxide :sparkles: :thumbsup: :sparkles:
:warning: @officialoxide's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Abdul Aleem
@OfficialOxide
May 13 2017 05:59
lol
LOL
Mike
@bob-bins
May 13 2017 05:59
for profile lookup, I can't figure out what's wrong with my code
for (var i = 0; i < contacts.length; i++)
  {
    if (contacts[i].firstName == firstName)
    {
      if (contacts[i].hasOwnProperty(prop))
      {
        return contacts[i].prop;
      }
      return "No such property";
    }
    return "No such contact";
  }
Abdul Aleem
@OfficialOxide
May 13 2017 06:00
@bob-bins you cant use a variable (firstName) with dot notation
kickkick479
@kickkick479
May 13 2017 06:00
@OfficialOxide OK. The problem is the position of return.
You should return true, when loop finishes without matching.
If match, return false immediately.
@bob-bins Also, the position of return "No such contact"; is another problem.
Cuz your code finishes when first person does not have the given first name.
return "No such contact"; must be placed afterr the loop finishes.
Jianhao Tan
@jaanhio
May 13 2017 06:03
var pairedArr=[];
  var arr=str.split("");
  for(i=0;i<arr.length;i++){
    if(arr[i]=="A"){
      var innerArrA = arr.shift();
      innerArrA = innerArrA.push("T");
      pairedArr.push(innerArrA);
    }
may i know why does the console say innerArrA.push is not a function?
Abdul Aleem
@OfficialOxide
May 13 2017 06:03
if (contacts[i]['firstName'] == firstName) {
@bob-bins
kickkick479
@kickkick479
May 13 2017 06:04
@bob-bins @OfficialOxide use contacts[i][firstName] . Remove single quotes. Cuz the firstName is a variable.
Abdul Aleem
@OfficialOxide
May 13 2017 06:05
but the single quoted one is a property
we're checking the variable against prop
Mike
@bob-bins
May 13 2017 06:06
i fixed what you guys suggested, but it is still not working. I'm getting the warning "firstName" is better written in dot notation
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;
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
kickkick479
@kickkick479
May 13 2017 06:06
@OfficialOxide @bob-bins Sorry. That was MY mistake. Forget about it.
Alexander Køpke
@alexanderkopke
May 13 2017 06:06
ahm the contact objects have a firstName property so the dot notation is ok here contacts[i].firstName and contacts[i]['firstName'] are the same...
Mike
@bob-bins
May 13 2017 06:06
but it doesn't work in dot notation either
Alexander Køpke
@alexanderkopke
May 13 2017 06:07
@bob-bins contacts[i].prop; prop is a variable though so use contacts[i][prop];
Mike
@bob-bins
May 13 2017 06:08
ohh thanks!
Joseph
@revisualize
May 13 2017 06:09
@bob-bins To add to what @alexanderkopke said:
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];
Abdul Aleem
@OfficialOxide
May 13 2017 06:09
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];
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
that is the correct solution @bob-bins
Joseph
@revisualize
May 13 2017 06:10
That's A correct solution.
There are a few more available.
Mike
@bob-bins
May 13 2017 06:11
thanks all for the help and explanations
Alexander Køpke
@alexanderkopke
May 13 2017 06:12
you got it, sir!
Joseph
@revisualize
May 13 2017 06:13
I like this solution the best:
function lookUpProfile(firstName, prop) {
  var contact = contacts.find(x => x.firstName === firstName);
  return contact ? (contact.hasOwnProperty(prop) ? contact[prop] : 'No such property') : 'No such contact';
}
kickkick479
@kickkick479
May 13 2017 06:14
@revisualize That is amaging. But a bit un-readable :<
Alexander Køpke
@alexanderkopke
May 13 2017 06:14
I love that one can nest ternaries
Joseph
@revisualize
May 13 2017 06:15
Add ()s make it more readable?
kickkick479
@kickkick479
May 13 2017 06:16
@revisualize Yeah, it's getting me familiar with that. TX!
CamperBot
@camperbot
May 13 2017 06:16
kickkick479 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3955 | @revisualize |http://www.freecodecamp.com/revisualize
Peter Nguyen
@iampeternguyen
May 13 2017 06:16
hey i'm workingo n the tic tac toe challenge and im trying to understand why this code puts an x in the box before i click anything..
$(document).ready(function(){
  //get a reference to the element
  var box2 = document.getElementById('box2');

  //add event listener
  box2.addEventListener('click', placeXorO('x', 2));

});
ian
@EIsIncorrect
May 13 2017 06:18
Hi, stuck on the "next in line" javascript challenge. Can't figure out how to get it to return the number that was removed from the array.
function nextInLine(arr, item) {
  // Your code here
  testArr.shift();
  testArr.push(item);
  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Joseph
@revisualize
May 13 2017 06:19

@EIsIncorrect Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

Kavindra Nikhurpa
@kavi-nikhurpa
May 13 2017 06:19
My solution for "Drop it" intermediate algorithm scripting.
function dropElements(arr, func) {
  while(!func(arr[0])) {
    arr.shift();
  }
  return arr;
}
Joseph
@revisualize
May 13 2017 06:20
@EIsIncorrect Note this line:
var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9
@EIsIncorrect testArr is a global variable.
aqleemali
@aqleemali
May 13 2017 06:27

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

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

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

Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:28
@aqleemali Hey!
@aqleemali You need to define fahrenheit according to celsius.
aqleemali
@aqleemali
May 13 2017 06:29
yes
help me
Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:29
@ivancsicsmarkus Fahrenheit equals celsius times 9/5 plus 32.
ian
@EIsIncorrect
May 13 2017 06:29
@revisualize so I've shifted out the 1st element, and pushed item onto the end of the array, but I'm not exactly sure how to get it to return the element that I shifted off
  testArr.shift();
  testArr.push(item);
  return item;  // Change this line
aqleemali
@aqleemali
May 13 2017 06:29
@ivancsicsmarkus
Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:29
@aqleemali ?
aqleemali
@aqleemali
May 13 2017 06:30
ya
Joseph
@revisualize
May 13 2017 06:30
@EIsIncorrect But, you're now doing thins out of order. Additionally you're still using the global variable not the function parameter.
Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:30
@aqleemali
fahrenheit = celsius * 9/5 + 32;
aqleemali
@aqleemali
May 13 2017 06:30
ok thanks
Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:30
@aqleemali ..
aqleemali
@aqleemali
May 13 2017 06:31
ya
ian
@EIsIncorrect
May 13 2017 06:32
@revisualize Oh, I think I get what you mean. Let me give it another go.
@revisualize thanks!
CamperBot
@camperbot
May 13 2017 06:32
eisincorrect sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3956 | @revisualize |http://www.freecodecamp.com/revisualize
Amir Saleem
@amirsaleem96
May 13 2017 06:39
<div class = "parent">
       <div class = "child1">
       </div>
      <div class = "child1">
      </div>
      <div class = "child1">
      </div>

    <div class = "child2">
     </div>
     <div class = "child2">
     </div>
<div class = "child2">
  </div>
</div>
how do I remove every child of parent with class child1.
Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:40
@amirsaleem96 Do you have jquery?
Amir Saleem
@amirsaleem96
May 13 2017 06:40
@ivancsicsmarkus
No, vanilla JS

I generally use this

while(parent.firstChild){
         parent.removeChild(parent.firstChild);
     }

but it removes every child of parent

Abdul Aleem
@OfficialOxide
May 13 2017 06:44
it is shameful that you commit infanticide.

anyway, i'm on the caesars cipher algorithm challenge.


function rot13(str) { // LBH QVQ VG!
  var result = str.split(' ');
  var arr = result.map(function (element) {
    for (var i = 0; i < element.length; i++) {
      element = String.fromCharCode(element.charCodeAt(i) - 13);
      return element;
    }
  });
  return arr.join(' ');
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Gives the output:
F C C
and not FREE CODE CAMP

Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:49
@OfficialOxide try
element[i] = String.fromCharCode(element[i].charCodeAt(i) - 13);
Abdul Aleem
@OfficialOxide
May 13 2017 06:50
thats the problem @ivancsicsmarkus
i already tried that and it says something about read only.
HeebieGeeBee
@HeebieGeeBee
May 13 2017 06:50
@amirsaleem96 have you tried
while(parent.firstChild){
         parent.removeChild(document.getElementsByClassName('child1'));
     }
Markus Ivancsics
@ivancsicsmarkus
May 13 2017 06:51
@OfficialOxide ah, strings are read-only..