These are chat archives for FreeCodeCamp/HelpJavaScript

29th
May 2016
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:00
@nbailey20 I am still not getting quote when I press the Get Quote button
Sudeep Narkar
@sudeepnarkar
May 29 2016 00:01
@sjames1958gm Thanks. I got thorough
CamperBot
@camperbot
May 29 2016 00:01
sudeepnarkar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1333 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sudeep Narkar
@sudeepnarkar
May 29 2016 00:01
*through
Stephen James
@sjames1958gm
May 29 2016 00:01
@sudeepnarkar :+1:
Brendon
@Balvamar
May 29 2016 00:02
I have been stuck on the "quote machine" challenge for a couple of weeks. Api
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:02
@Balvamar Wow I hope that won't happen to me, feel for you man!
Daniel Godigna
@DGAcode
May 29 2016 00:02
hello pals I need a little help with " Record Collection "
Diego Mayer
@Chrono79
May 29 2016 00:03
@33hawk paste your code
Brendon
@Balvamar
May 29 2016 00:03
Just can't get an api to work.
Daniel Godigna
@DGAcode
May 29 2016 00:03
I think this is really bad still I will paste it here
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    prop=3;
  }
  else if (prop === "tracks" && value !== ""){
    value.shift= 3;
  }
  else if(value === ""){
    delete prop;
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:04
@Balvamar yeah me neither.. I feel I didn't learn much from the jquery api challenges that were before
Diego Mayer
@Chrono79
May 29 2016 00:04
@33hawk your ifs are ok, what you do inside them don't
OceanMountains
@OceanMountains
May 29 2016 00:04

@Balvamar try this one:

http://forismatic.com/en/api/

It worked for me. Now if only I could FINISH THIS DAMN TWITTER BUTTON. UGH!!!!

Stephen James
@sjames1958gm
May 29 2016 00:04
Sudeep Narkar
@sudeepnarkar
May 29 2016 00:05
@33hawk Hi . You need to update the collection.
Brendon
@Balvamar
May 29 2016 00:05
The prior challenges did not deal with external api
Daniel Godigna
@DGAcode
May 29 2016 00:05
@Chrono79 Io @sjames1958gm thanks you both I'm a little tired still wan't to do this let me check the previous example
CamperBot
@camperbot
May 29 2016 00:05
33hawk sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 918 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1334 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
May 29 2016 00:05
@33hawk inside all your ifs you have to refer to collection plus something
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:05
@Balvamar And gave little to no information on what you were doing
Norvin Burrus
@ndburrus
May 29 2016 00:06
@33hawk the initial logic looks good, then you get to prop=3; what is this? we need to do this requirement at this point then update or set the value for the prop. agree with the lesson reference (to set, add, and delete values). also, delete prop; note: variables should not be deleted (in this manner). all of the logic looks good - just need the lesson review and you will be fine.. :)
Sudeep Narkar
@sudeepnarkar
May 29 2016 00:06
@33hawk You need to update the value of the property of the collection. Don't you think it should be collections[prop]?
Brendon
@Balvamar
May 29 2016 00:06
Using code pen does not allow you to create your own
Daniel Godigna
@DGAcode
May 29 2016 00:06
@sudeepnarkar you're right I didn't get that
Subh Samal
@subhsamal
May 29 2016 00:07
Hi Guys.. can anyone help me with reversing an array?
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:07
@Balvamar What do you mean?
Diego Mayer
@Chrono79
May 29 2016 00:07
@sudeepnarkar @33hawk it's not btw, look at the object, I think something is missing there
Subh Samal
@subhsamal
May 29 2016 00:07

function reverseString(str) {
 var myArray = [];
 myArray = str.split(" ");
 myArray.reverse();
 myArray.join("");
  retuen myArray;



}

reverseString("hello");
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:08
@subhsamal you wrote retuen not return
Diego Mayer
@Chrono79
May 29 2016 00:08
@subhsamal myArray = str.split(" "); this splits in words, not letters
MBJ
@mbjusa
May 29 2016 00:09

I'd like to talk to someone about how to control the asynch behavior of js

I am working on the twitch tv api project.

Anyone game???

Subh Samal
@subhsamal
May 29 2016 00:09
@Chrono79 how can I split letters?
corrected it. problem with my logic. @kristoferarnthors
Diego Mayer
@Chrono79
May 29 2016 00:09
@subhsamal split("")
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:09
@subhsamal str.split("");
Brendan Kinahan
@BKinahan
May 29 2016 00:10
.splat("''")
Subh Samal
@subhsamal
May 29 2016 00:11
yeah looks like working. @Chrono79 @kristoferarnthors . how to join letter ?
rphares @rphares cleans up the mess @BKinahan made... :blush:
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:11
@subhsamal .join()?
Brendan Kinahan
@BKinahan
May 29 2016 00:12
or .join('') if you don't want commas
Diego Mayer
@Chrono79
May 29 2016 00:12
@subhsamal return myArray.join(""); join doesn't modify the array it's applied
Subh Samal
@subhsamal
May 29 2016 00:13

function reverseString(str) {
 var myArray = [];
 myArray = str.split("");
 myArray.reverse();
 myArray.join('');
  return myArray;



}

reverseString("hello");
I dont want commas. @BKinahan . This one is not working.
Brendan Kinahan
@BKinahan
May 29 2016 00:13
@subhsamal and for extra credit, try chaining the methods together into one line :D
@subhsamal you're not assigning the results of those methods to anything.
Diego Mayer
@Chrono79
May 29 2016 00:14
@subhsamal look above
Brendan Kinahan
@BKinahan
May 29 2016 00:14
@subhsamal NEVER MIND :D
Subh Samal
@subhsamal
May 29 2016 00:14
okay
Diego Mayer
@Chrono79
May 29 2016 00:14
@BKinahan reverse modifies the array
Brendan Kinahan
@BKinahan
May 29 2016 00:14
(does reverse mutate?)
ah
Subh Samal
@subhsamal
May 29 2016 00:15
woaah..
worked
function reverseString(str) {
 var myArray = [];
 myArray = str.split("");
 myArray = myArray.reverse();
 myArray = myArray.join('');
  return myArray;



}

reverseString("hello");
Brendan Kinahan
@BKinahan
May 29 2016 00:16
gave a little too much away there ;)
Diego Mayer
@Chrono79
May 29 2016 00:16
@subhsamal Ok, now, chain the array methods in one line as @BKinahan suggested
@BKinahan spoiler alert! ;)
Subh Samal
@subhsamal
May 29 2016 00:16
so each method looks for a variable to store value? yeah trying it now. @Chrono79 @BKinahan
Diego Mayer
@Chrono79
May 29 2016 00:17
@subhsamal not all, you have to read docs to know which of them mutates the object you applied them and which don't
Brendan Kinahan
@BKinahan
May 29 2016 00:17
@subhsamal no, it doesn't look for a variable really. it'll return its value no matter whether there's something for it to be assigned to, but the value won't be saved anywhere. It's like having a line that just says true; or 2;
That's if you're talking about methods that don't modify what they're operating on, such as join()
Subh Samal
@subhsamal
May 29 2016 00:20
@BKinahan got your point. :)
```js
function reverseString(str) {
 var myArray = [];
 myArray = str.split("");
 myArray = myArray.reverse().join('');
 //myArray = myArray.join('');
  return myArray;



}

reverseString("hello");
is this the one you guys suggested ? @BKinahan @Chrono79
Diego Mayer
@Chrono79
May 29 2016 00:21
@subhsamal there is some more space for improvement there
get rid of the var and return the chaining of the 3 methods
Subh Samal
@subhsamal
May 29 2016 00:22
yessss @Chrono79
function reverseString(str) {
 var myArray = [];
 myArray = str.split("");
 return myArray = myArray.reverse().join('');
 //myArray = myArray.join('');
  //return myArray;  
}

reverseString("hello");
Diego Mayer
@Chrono79
May 29 2016 00:24
@subhsamal try removing myArray completely
Subh Samal
@subhsamal
May 29 2016 00:25
function reverseString(str) {
 //var myArray = [];
  myArray = str.split("");
 return myArray = myArray.reverse().join('');
 //myArray = myArray.join('');
  //return myArray;  
}

reverseString("hello");
So I need to declare myArray as var ? @Chrono79 .. is the above one correct?
Diego Mayer
@Chrono79
May 29 2016 00:26
I give up :confused:
Subh Samal
@subhsamal
May 29 2016 00:26
:(
Diego Mayer
@Chrono79
May 29 2016 00:27

@subhsamal

myArray = str.split("");
 return myArray = myArray.reverse().join('');

Do one line of these 2 removing myArray
after split, chain reverse and join

Subh Samal
@subhsamal
May 29 2016 00:30
tried something as below !!! :worried: I don't want to upset anymore.
return myArray = str.split("").reverse(myArray).join('');
Diego Mayer
@Chrono79
May 29 2016 00:31
@subhsamal almost there, delete myArray =
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:31
@subhsamal you don't need to do .reverse(myArray) just .reverse I think
and yes delete myArray =
Diego Mayer
@Chrono79
May 29 2016 00:31
@kristoferarnthors good point
Subh Samal
@subhsamal
May 29 2016 00:31
function reverseString(str) {
 //var myArray = [];
 // myArray = str.split("");
 return str.split("").reverse(myArray).join('');
 //myArray = myArray.join('');
  //return myArray;  
}

reverseString("hello");
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:31
@subhsamal get rid of the myArray inside of .reverse()
OceanMountains
@OceanMountains
May 29 2016 00:32
I just need to get the Twitter button at the bottom working. No matter what I do, it tells me quoteCode is undefined when I click the twitter button. It works when I click the #randomQuote button, but the Twitter one never works. I swear I am missing something simple and obvious.
$(document).ready(function() {
 $('#randomQuote').click(function() {
  $.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?")
    .done(update)
    .fail(handleErr);
});

  function update(response) {
    var text = response.quoteText;
  var author = response.quoteAuthor;
  if (author === '') {
      author = "Anonymous";
    }
  var quoteCode = "<blockquote>" + text + "<footer> by " + author + "</footer></blockquote>";
 $('#showQuoteHere').html(quoteCode);
  }

window.quoteCode = quoteCode;  

function handleErr(jqxhr, textStatus, err) {
  console.log("Request Failed: " + textStatus + ", " + err);
}

  $('#twitter_btn').click(function() {
  function updateTweet(response) {
         var text = response.quoteText;
  var author = response.quoteAuthor;
  if (author === '') {
      author = "Anonymous";
    }
  var quoteCode = "<blockquote>" + text + "<footer> by " + author + "</footer></blockquote>"; $("twitter_btn").attr("href", "https://twitter.com/intent/tweet?text=" + quoteCode + "%0a--- ");
}
updateTweet(quoteCode);
});
});
Subh Samal
@subhsamal
May 29 2016 00:33
I hope this gonna be the final one. @BKinahan @Chrono79
function reverseString(str) {
 //var myArray = [];
 // myArray = str.split("");
 return  str.split("").reverse().join('');
 //myArray = myArray.join('');
  //return myArray;  
}

reverseString("hello");
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:33
@subhsamal this should work
Subh Samal
@subhsamal
May 29 2016 00:34
working. I mean to ask is this the one you guys suggested ?
Diego Mayer
@Chrono79
May 29 2016 00:34
yes, that'll work, congratulations :+1:
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:34
yes man
congrats
Subh Samal
@subhsamal
May 29 2016 00:34
:blush:
Moisés Man
@moigithub
May 29 2016 00:34
now delete and do a loop version :D
Subh Samal
@subhsamal
May 29 2016 00:35
@Chrono79 Thank you for your patience.
CamperBot
@camperbot
May 29 2016 00:35
subhsamal sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 919 | @chrono79 |http://www.freecodecamp.com/chrono79
Subh Samal
@subhsamal
May 29 2016 00:35
@kristoferarnthors Thanks buddy.
CamperBot
@camperbot
May 29 2016 00:35
subhsamal sends brownie points to @kristoferarnthors :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @kristoferarnthors |http://www.freecodecamp.com/kristoferarnthors
Diego Mayer
@Chrono79
May 29 2016 00:35
no problem, I was just joking before
Kristófer Arnþórsson
@kristoferarnthors
May 29 2016 00:35
@subhsamal no problem man
Diego Mayer
@Chrono79
May 29 2016 00:36
I try to never give up ;)
Subh Samal
@subhsamal
May 29 2016 00:36
hehe.. I believe u really were :smile:
Diego Mayer
@Chrono79
May 29 2016 00:37
@moigithub :D
OceanMountains
@OceanMountains
May 29 2016 00:38
where am I going wrong @moigithub ?
I'm sure you will see this quickly. My eyes have just been going over the code for hours.
Brendan Kinahan
@BKinahan
May 29 2016 00:41
@OceanMountains looks like you might be having some scoping issues
OceanMountains
@OceanMountains
May 29 2016 00:42
I've tried to make quoteCode global with no luck.
Hence why I tried directly copying the code from update function into the twitter button functions. I am out of ideas.
Brendan Kinahan
@BKinahan
May 29 2016 00:44
@OceanMountains you use var to declare it within both of those functions, which makes a new variable each time with its scope limited to within those functions. those values are not accessible outside the functions.
perhaps review the challenges on local and global scope on the FCC map.
OceanMountains
@OceanMountains
May 29 2016 00:45
Correct @BKinahan I understand that 100%. But since I'm using JSON and the API I can't just simply declare a global variable at the top.
MBJ
@mbjusa
May 29 2016 00:46

I'd like to talk to someone about how to control the asynch behavior of js

I am working on the twitch tv api project.

Anyone game???

Brendan Kinahan
@BKinahan
May 29 2016 00:46
@OceanMountains why not?
Daniel Blanco
@Danultimate
May 29 2016 00:46
need some help

function myTest(num) {
// Only change code below this line
if(num < 5){
return 'Tiny';
}
else if(num < 10){
return 'Small';
}
else if(num < 15){
return 'Medium';
}
else if( num < 20){
return 'Large';
}
else if(num >= 20){
return 'Huge';
}

//return "Change Me";
// Only change code above this line
}

// Change this value to test
myTest(7);

OceanMountains
@OceanMountains
May 29 2016 00:47
The problem is that the JSON pull from the API goes straight to my update function to display the quote. Once it's there I don't know how use it outside the scope of that function.
Norvin Burrus
@ndburrus
May 29 2016 00:47
@Danultimate which challenge?
Brendan Kinahan
@BKinahan
May 29 2016 00:47
@OceanMountains quotecode can have an initial (global) value that is updated by your functions without declaring a new variable with function-limited scope.
Daniel Blanco
@Danultimate
May 29 2016 00:48
Chaining If Else Statements
Norvin Burrus
@ndburrus
May 29 2016 00:48
This message was deleted
OceanMountains
@OceanMountains
May 29 2016 00:48
so just put var quoteCode= ''; at the top of my JS?
if it's that simple I am going to kick myself. Wasting hours here.
Brendan Kinahan
@BKinahan
May 29 2016 00:49
@OceanMountains It can be empty, or it can be something that displays before any quote is loaded if you prefer. Then you can just work in something like $('#quote-div').html(quotecode) at the end of your update functions, after quotecode is changed.
@OceanMountains just be sure not to declare quotecode again inside the functions :)
OceanMountains
@OceanMountains
May 29 2016 00:53
All right I will try that @BKinahan .
Norvin Burrus
@ndburrus
May 29 2016 00:53
@Danultimate take a quick look at what return/s is/are needed.... hint: a function name is identified... :) can you identify what the code is missing? also, the final condition can be handled simply with an else statement :)
Francisco Franco
@frenktico
May 29 2016 00:55
/help
CamperBot
@camperbot
May 29 2016 00:55

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

MBJ
@mbjusa
May 29 2016 00:55
@BKinahan I am having trouble controlling the flow of my program using multiple API getjson type calls.
Do you have any words of wisdom regarding this?
Justin Woodward
@jwoo92
May 29 2016 00:58
hey guys i am having a little bit of trouble getting my on click functions to work for my buttons on my twitch.tv app. would anyone be able to look over my code for me please? http://codepen.io/jwoo/pen/bebYLO?editors=0110
Brendan Kinahan
@BKinahan
May 29 2016 00:58
@mbjusa if you have multiple asynchronous functions that have to complete before you can do something with the results, think about how you can check if all the results are ready each time a function finishes. Not sure if that's what you need to do, but it's a good thing to think about anyway :D
buiphuking
@buiphuking
May 29 2016 00:59
help minmax algorithm
CamperBot
@camperbot
May 29 2016 00:59
no wiki entry for: minmax algorithm
OceanMountains
@OceanMountains
May 29 2016 00:59
No dice @BKinahan , still won't work. I am determined to finish this today but I've now spent 5+ hours on something that I'm sure is doable in 5 minutes. I really just want to understand and move on before I throw my computer out the window.
var quoteCode = '';

$(document).ready(function() {
 $('#randomQuote').click(function() {
  $.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?")
    .done(update)
    .fail(handleErr);
});

  function update(response) {
    var text = response.quoteText;
  var author = response.quoteAuthor;
  if (author === '') {
      author = "Anonymous";
    }
  var quoteCode = "<blockquote>" + text + "<footer> by " + author + "</footer></blockquote>";
 $('#showQuoteHere').html(quoteCode);
  } 

function handleErr(jqxhr, textStatus, err) {
  console.log("Request Failed: " + textStatus + ", " + err);
}

  $('#twitter_btn').click(function() {
  function updateTweet() {
  $("twitter_btn").attr("href", "https://twitter.com/intent/tweet?text=" + quoteCode + "%0a--- ");
}
updateTweet(quoteCode);
});
});
vuk81
@vuk81
May 29 2016 01:01

need a help please. What I am doing wrong```
var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear=0;
this.setGear=function(num){
return num;
};
this.getGear=function(num){
return num;
};
};

var myCar = new Car();

var myBike = new Bike();
```

Brendan Kinahan
@BKinahan
May 29 2016 01:01

@OceanMountains hm.. you are still declaring a local variable with

var quoteCode = "<blockquote>" + ...

within update. Is that intended?

Norvin Burrus
@ndburrus
May 29 2016 01:01
@vuk81 which challenge?
vuk81
@vuk81
May 29 2016 01:01
Make object properties private
Brendan Kinahan
@BKinahan
May 29 2016 01:02
@OceanMountains also if quotecode contains html tags etc then adding it to the tweet URL of the button with updateTweet doesn't really make much sense
vuk81
@vuk81
May 29 2016 01:02
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.
var gear=0;
  this.setGear=function(num){
    return num;
  };
  this.getGear=function(num){
    return num;
  };
};

var myCar = new Car();

var myBike = new Bike();
Diego Mayer
@Chrono79
May 29 2016 01:04
@vuk81 getGear doesn't need a param, and review what you return
Daniel Godigna
@DGAcode
May 29 2016 01:04
@Chrono79 still stuck but I think now it's a little better

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    value = collection[prop];
  }
  else if (prop === "tracks" && value !== ""){
    collection = colection[prop].push(value);
  }
  else if(value === ""){
   delete collection[prop];
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Diego Mayer
@Chrono79
May 29 2016 01:05
@33hawk look at collection structure, you need to use id too
Although this isn't right: value = collection[prop];asignation works from right to left
OceanMountains
@OceanMountains
May 29 2016 01:06

@BKinahan I caught that var declaration after I sent it to you. Removed it, still didn't work.

I thought the point of the exercise is to tweet my quote out. That's why I put the contents of quoteCode into updateTweet function.

Daniel Godigna
@DGAcode
May 29 2016 01:06
@Chrono79 there's something I don't really get and it's the relationship of the array with the parameters
Norvin Burrus
@ndburrus
May 29 2016 01:06
@vuk81 setGear needs to connect with the gear var to change it (ie set the gear value). also, getGear needs to return the gear value...
Diego Mayer
@Chrono79
May 29 2016 01:07
@33hawk collection is an object, not an array, with another objects inside
Daniel Godigna
@DGAcode
May 29 2016 01:07
you're right
but still the question is nearly the same
vuk81
@vuk81
May 29 2016 01:08
thanks @ndburrus
CamperBot
@camperbot
May 29 2016 01:08
vuk81 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 451 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 29 2016 01:08
@vuk81 does it make sense? pass? :+1:
yeap
MBJ
@mbjusa
May 29 2016 01:09
@BKinahan Is this what callback functions are for??
How is this done??? Do I check for correct values within a while loop before executing the 2nd API call??
Norvin Burrus
@ndburrus
May 29 2016 01:10
@heebzstreet ok, how can a variable be initialized?
Chris Cullen
@123xylem
May 29 2016 01:10
QuicK Question: What am i missing on my reduce function? Im trying to get the sum of newarr

function sumAll(arr) {
var max =Math.max.apply(Math, arr); // GET largest number
  var min =Math.min.apply(Math, arr); //Smallest
var  subtot=max+min; //Add them
  var newarr=[]; //make newarray
  for(i=min;i<=max;i++){
    newarr.push(i);         //Push middle values of old array into new one
  }
  var result=0;
 [newarr].reduce(function(prev, curr){  prev+=curr; //Reduce newarr to sum of its parts???!
  return result;});
}

sumAll([1, 4]);
Bianca Mihai
@biancamihai
May 29 2016 01:11
@OceanMountains do you get errors in your console log?
@OceanMountains does this make any sense:
function quotes (){
  var quote = null;
  return {
      getQuote : function() {
        // get your quote here and if success replace in html and do:
        quote = 'bla bla';
      },
      tweet : function() {
        console.log('tweet this text: ', quote);
      }
  }
};

var quotes = quotes();
// get new quote
quotes.getQuote();
// on tweet
quotes.tweet();
?
perhaps is more easy to go this way
Norvin Burrus
@ndburrus
May 29 2016 01:12
@vuk81 excellent! nice job.. :sparkles:
MBJ
@mbjusa
May 29 2016 01:13
@heebzstreet I think you have too many "string words"
Diego Mayer
@Chrono79
May 29 2016 01:13
@123xylem
inside your reduce, you have to return prev + current
[newarr] should be newarr and you have to return it or assign that to a var that you return later
OceanMountains
@OceanMountains
May 29 2016 01:14

The error I am getting is VM234 pen.js:27Uncaught ReferenceError: quoteCode is not defined.

@biancamihai , I am just learning to get the API to work and display. Everything I have so far is just trying to get the thing to display anything.

Mateusz Szymański
@matszym
May 29 2016 01:14

@OceanMountains

$("twitter_btn")

I doubt you have twitter_btn element, your selector might be off

OceanMountains
@OceanMountains
May 29 2016 01:16
wow @matszym that was it. I feel so stupid.
Norvin Burrus
@ndburrus
May 29 2016 01:16
@33hawk ok check/review this line: value = collection[prop]; how does the code know where in collection exactly to find the value? the only directions/pointers it has are collection & prop. is there another "pointer" missing?
Daniel Godigna
@DGAcode
May 29 2016 01:16
@Chrono79 I see in that example we go step to step until we reach what we're searching of. But this object in " record collection " we're using id, prop and value. Are those reserved words?
Diego Mayer
@Chrono79
May 29 2016 01:17
@33hawk no, they're your function parameters, and you should treat them as variables, for example, using bracket notation when used to access the object properties/contents
Douglas Hoang
@DouglasHoang
May 29 2016 01:17
Hey guys! I can't figure out how to get JSON data from the recommended api for the challenge. Check out my codepen! Any help is appreciated! https://codepen.io/DouglasHoang/pen/zBYqwm?editors=1111
Norvin Burrus
@ndburrus
May 29 2016 01:17
@33hawk above comment will help with these lines also: collection = colection[prop].push(value); & delete collection[prop];
buiphuking
@buiphuking
May 29 2016 01:18
do we need to use minmax algorithm with tic tac toe game ????????????
Daniel Godigna
@DGAcode
May 29 2016 01:18
@Chrono79 hey Diego thanks again, I will concentrate here for now I will get the good result shortly
CamperBot
@camperbot
May 29 2016 01:18
33hawk sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 920 | @chrono79 |http://www.freecodecamp.com/chrono79
Daniel Godigna
@DGAcode
May 29 2016 01:18

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    value = collection[id][prop];
  }
  else if (prop === "tracks" && value !== ""){
    collection = colection[id][prop].push(value);
  }
  else if(value === ""){
   delete collection[id][prop];
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Mateusz Szymański
@matszym
May 29 2016 01:19
@DouglasHoang your api endpoint doesnt work
Failed to load resource: the server responded with a status of 500 ()
OceanMountains
@OceanMountains
May 29 2016 01:20
@biancamihai yes that makes sense. Thank you for all the help.
CamperBot
@camperbot
May 29 2016 01:20
oceanmountains sends brownie points to @biancamihai :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @biancamihai |http://www.freecodecamp.com/biancamihai
Norvin Burrus
@ndburrus
May 29 2016 01:20
@33hawk colection spelling :sparkles:
Chris Cullen
@123xylem
May 29 2016 01:20
@Chrono79 ok looking into it...
Douglas Hoang
@DouglasHoang
May 29 2016 01:21
@matszym i think it's cause i used the crossorigin.me
@matszym let me try taking it off can you check it again :)
Chris Cullen
@123xylem
May 29 2016 01:22

Once again thanks Diego! ```js
function sumAll(arr) {
var max =Math.max.apply(Math, arr); // GET largest number
var min =Math.min.apply(Math, arr); //Smallest
var subtot=max+min; //Add them
var newarr=[]; //make newarray
for(i=min;i<=max;i++){
newarr.push(i); //Push middle values of old array into new one
}

var result= newarr.reduce(function(prev, curr){ return prev+=curr; //Reduce newarr to sum of its parts???!
}); return result;
}

sumAll([1, 4]);
```

@Chrono79 thanks
CamperBot
@camperbot
May 29 2016 01:22
123xylem sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 921 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen Mansfield
@StephenMansfield
May 29 2016 01:23
alright guys im pretty stuck
would like the qoute to relplace instead of add to the end
I know I need to replace that append with somethign
Mateusz Szymański
@matszym
May 29 2016 01:25

@StephenMansfield

$(".message").append(a[0].content + "<p>— " + a[0].title + "</p>")

change it to:

$(".message").html(a[0].content + "<p>— " + a[0].title + "</p>")
Diego Mayer
@Chrono79
May 29 2016 01:25

@33hawk fix these 2 lines:

value = collection[id][prop];
and 
collection = colection[id][prop].push(value);

the first, I already told you something about
the second, just leave this: collection[id][prop].push(value);

azeem259
@azeem259
May 29 2016 01:25
@azeem259
hey im on the palindrome bonfire and I can't figure out why my code won't work
function palindrome(str) {
var lowercase = str.toLowerCase();
var string = lowercase.replace(/\W|_/g);
var reversestring = string.split("").join("");

if (reversestring === string){
  return true;
} else {
  return false;
}
}

palindrome("nope");
Daniel Godigna
@DGAcode
May 29 2016 01:26
@Chrono79 thanks
CamperBot
@camperbot
May 29 2016 01:26
33hawk sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Stephen Mansfield
@StephenMansfield
May 29 2016 01:26
thanks @matszym
CamperBot
@camperbot
May 29 2016 01:26
stephenmansfield sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:warning: 33hawk already gave chrono79 points
:cookie: 71 | @matszym |http://www.freecodecamp.com/matszym
Mateusz Szymański
@matszym
May 29 2016 01:26
@azeem259 isnt string reserved keyword?
azeem259
@azeem259
May 29 2016 01:26
idk let me google it
Mateusz Szymański
@matszym
May 29 2016 01:27
@azeem259 I did, lower case isnt
Diego Mayer
@Chrono79
May 29 2016 01:27
@matszym no, but String is
Daniel Godigna
@DGAcode
May 29 2016 01:27
@ndburrus thanks
CamperBot
@camperbot
May 29 2016 01:27
33hawk sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 452 | @ndburrus |http://www.freecodecamp.com/ndburrus
Douglas Hoang
@DouglasHoang
May 29 2016 01:28
@matszym How did you check if my linked worked?
Mateusz Szymański
@matszym
May 29 2016 01:28
@azeem259
var reversestring = string.split("").join("");
Diego Mayer
@Chrono79
May 29 2016 01:28
@azeem259 you didn't reversed it, didn't you?
Mateusz Szymański
@matszym
May 29 2016 01:28
@DouglasHoang open real console, not the one codepen provides
azeem259
@azeem259
May 29 2016 01:29
@matszym so I shouldn't use string as a variable?
Mateusz Szymański
@matszym
May 29 2016 01:30
@azeem259 Depends, if you care about code quality, then you shouldnt. Lower case string as variable name will be tolerated by compiler
Douglas Hoang
@DouglasHoang
May 29 2016 01:31
@matszym it says this https://s.codepen.io/boomerang/8ac1c1efc1b703c8bcb401a9fa4f60fe1464485379469/api.openweathermap.org/data/2.5/forecast/weather?lat=21&lon=-87&APPID=b21be656bf39c3aa3e806da3c45d059f. I can't figure out how to make it so it just goes to api.openweathermap.org/data/2.5/forecast/weather?lat=21&lon=-87&APPID=b21be656bf39c3aa3e806da3c45d059f.
Moisés Man
@moigithub
May 29 2016 01:31
@DouglasHoang add http:// to ur api url
Mateusz Szymański
@matszym
May 29 2016 01:32
@DouglasHoang before you put url in code, just open it in browser and check if it loads
Douglas Hoang
@DouglasHoang
May 29 2016 01:32
@matszym it loads
Douglas Hoang
@DouglasHoang
May 29 2016 01:33
@matszym it works without the http://
or i mean
it would work
Daniel Godigna
@DGAcode
May 29 2016 01:35
@ndburrus @Chrono79 thanks
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    collection[id][prop]= value;
  }
  else if (prop === "tracks" && value !== ""){
    collection[id][prop].push(value);
  }
  else if(value === ""){
   delete collection[id][prop];
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
CamperBot
@camperbot
May 29 2016 01:36
33hawk sends brownie points to @ndburrus and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: 33hawk already gave ndburrus points
:warning: 33hawk already gave chrono79 points
Wasiff A
@is0sceles
May 29 2016 01:36
does anyone know how to use Googles Custom Search API ?
Norvin Burrus
@ndburrus
May 29 2016 01:36
@33hawk resolved?
Mateusz Szymański
@matszym
May 29 2016 01:37
@DouglasHoang might be cross origin restriction
Douglas Hoang
@DouglasHoang
May 29 2016 01:39
@matszym is there any substitute to using cross origin?
Mateusz Szymański
@matszym
May 29 2016 01:41
Douglas Hoang
@DouglasHoang
May 29 2016 01:43
@matszym Thanks! I'll look into it
CamperBot
@camperbot
May 29 2016 01:43
douglashoang sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 72 | @matszym |http://www.freecodecamp.com/matszym
Mateusz Szymański
@matszym
May 29 2016 01:45
@DouglasHoang your api is served over http, but codepen over https. Seems liek you are not allowed to make http request from https site
Douglas Hoang
@DouglasHoang
May 29 2016 01:47
@matszym darn so that means i have to find a new api
Chris Cullen
@123xylem
May 29 2016 01:49
function diffArray(arr1, arr2) {

  var first = arr1.push();
  var second = arr2.push();
  var newarr = arr1.concat(arr2);

  for(i=0;i<newarr.length;i++){
    if(newarr[i] == newarr[i]){
      newarr= newarr - newarr[i];
    }

  }
  // Same, same; but different.
  return newarr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Im getting return of null. Why would it convert 4 to null?
Mateusz Szymański
@matszym
May 29 2016 01:51
@123xylem
your bug
newarr= newarr - newarr[i]

@123xylem

newarr[i] == newarr[i]

Always true, unless NaN. You sure this is right condition? I mean, it might be, since you did this:

newarr= newarr - newarr[i];

With is going to replace content of newarr with NaN

Chris Cullen
@123xylem
May 29 2016 01:56
hmm
Well I want to remove duplicates
So if in I's search it finds itself again it removes itself
maybe reduce would be better
if prev == curr remove prev + curr?
Mateusz Szymański
@matszym
May 29 2016 01:58

@123xylem lets assume content of newarr:

[1, 2 , 3, 4]

your if on each iteration is checking if:

1 == 1?
2 == 2?
3 == 3?
4 == 4?
if(newarr[i] == newarr[i])

@123xylem and when you substract number from array, like this:

[1, 2, 3, 4, 5] - 2

What do you think you get?

Jack Anderson
@JackAndersonLee
May 29 2016 01:59
You could try sorting your array
and if the the current index is the same as the next, remove one of it?
Chris Cullen
@123xylem
May 29 2016 02:00
@JackAndersonLee Yes
Jack Anderson
@JackAndersonLee
May 29 2016 02:00
or save one to a variable
Chris Cullen
@123xylem
May 29 2016 02:00
@matszym I see what your saying mat... I made a booboo
@matszym good explanation
var result =newarr.sort(function(a, b) {
 if(a!=b){ return a - b;}
});
THis just gave me the whole array sorted numerically
with duplicates
Mateusz Szymański
@matszym
May 29 2016 02:06
@123xylem drop this idea. Create resultArray, and push numbers that are not found in resultArray, so each number is stored once
Kris Greason
@AureliaWarleader
May 29 2016 02:06
Quick question guys. The factorial problem; should I be able to write a for loop that accounts for 0! = 1? Every for loop I've created works for all cases except 0! and I'm having a hard time figuring out how to deal with that particular case in the loop. I'm wondering if I'm going to have to use a different method for that particular case.
Sorry if it's rude to just post my question, I don't want to interrupt but I don't know the proper way of asking a question amidst another discussion.
Mateusz Szymański
@matszym
May 29 2016 02:07
@AureliaWarleader early return with if(number === 0)
Kris Greason
@AureliaWarleader
May 29 2016 02:08
I thought it might be something like that but I wanted to confirm that a for loop couldn't handle that oddity while still working for all other cases.
Thanks @matszym !
CamperBot
@camperbot
May 29 2016 02:08
aureliawarleader sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 73 | @matszym |http://www.freecodecamp.com/matszym
vuk81
@vuk81
May 29 2016 02:11

can i do something like this. I want to remove all spaces, dots etc and to join all words into single string of letters and to reverse it. Why this wont work ```
function palindrome(str) {
// Good luck!
if(str==str.toLowerCase().replace('.','').join("")){
return true;
} else {return false;}
}

palindrome("eye");
```

function palindrome(str) {
  // Good luck!
  if(str==str.toLowerCase().replace('.','').join("")){
  return true;
} else {return false;}
}


palindrome("eye");
Mateusz Szymański
@matszym
May 29 2016 02:14

@vuk81

join("")

What are you trying to join?

@vuk81 besides join, you are not checking if input is palindrome. you are checking if for example
Vuk81. === vuk81
MrSkyWanker
@MrSkyWanker
May 29 2016 02:18
Greetings. I'm trying to create a boolean object. However, when i follow the provided syntax, the console tells me to not use it as a constructor. How should I proceed to create a boolean object?
Mateusz Szymański
@matszym
May 29 2016 02:19
@MrSkyWanker booleans arent really objects, they are primitives.
var isBooleanAnObject = false;
var isBooleanAPrimitive = true;
MrSkyWanker
@MrSkyWanker
May 29 2016 02:20
@matszym Thanks for you support. Please take a look at here : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
CamperBot
@camperbot
May 29 2016 02:20
mrskywanker sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 74 | @matszym |http://www.freecodecamp.com/matszym
vuk81
@vuk81
May 29 2016 02:21
@matszym I am joing str.join since it will consist of many words, therefore I need to remove space between them. And I know that i am currently comparing vuk81 with vuk81 but that will be solved with replace method.
Mateusz Szymański
@matszym
May 29 2016 02:22

@MrSkyWanker yes, they are wrapped in object
"The Boolean object is an object wrapper for a boolean value"

But they are not objects. The same way numbers and strings arent objects, but are wrapped in objects for your use

MrSkyWanker
@MrSkyWanker
May 29 2016 02:22
I see.
vuk81
@vuk81
May 29 2016 02:23
@vuk81 sorry I ment reverse method
MrSkyWanker
@MrSkyWanker
May 29 2016 02:23
@matszym So do u confirm i should be able to complete the Falsy Bouncer JS Challenge without having to create any true objects?
ThaleSelaht
@ThaleSelaht
May 29 2016 02:24
@MrSkyWanker yes u are
Mateusz Szymański
@matszym
May 29 2016 02:24
@MrSkyWanker Its important, you can extend any object with new property
var myString.someValue = "Hello world!"
return myString.somevalue ;
returns undefined
Joseph
@revisualize
May 29 2016 02:24
@vuk81 You need to remove all non-alphanumeric characters from the string.
Mateusz Szymański
@matszym
May 29 2016 02:24
@MrSkyWanker Another difference between objects and primiteves is, objects are passed by refference, primiteves are passed by value
@MrSkyWanker Those are important distinctions, that will produce nasty bugs, so its important to distinguish between objects and primitives in js
MrSkyWanker
@MrSkyWanker
May 29 2016 02:25
i think i get you
Kris Greason
@AureliaWarleader
May 29 2016 02:25
...is that supposed to be a RegEx thing? Because RegEx is scary... (referring to removing non-alphanumberic characters)
ThaleSelaht
@ThaleSelaht
May 29 2016 02:26
@AureliaWarleader yes, u will find out that knowing regex will be very helpful
Kris Greason
@AureliaWarleader
May 29 2016 02:27
Aww but it's hard! (I kid, of course, I'll have to learn it eventually one way or another)
Thanks @ThaleSelaht
CamperBot
@camperbot
May 29 2016 02:27
aureliawarleader sends brownie points to @thaleselaht :sparkles: :thumbsup: :sparkles:
:cookie: 227 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
Diego Mayer
@Chrono79
May 29 2016 02:28
@AureliaWarleader check hackerrank regex challenges, they're very instructive
Mateusz Szymański
@matszym
May 29 2016 02:28
@vuk81 There is no join method on strings. Its not how you remove spaces from string.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
buiphuking
@buiphuking
May 29 2016 02:28
@Chrono79
can i see your Smallest Common Multiple code ?
vuk81
@vuk81
May 29 2016 02:29
@matszym it works man, i we tried it
@revisualize I dont see the point.
Mateusz Szymański
@matszym
May 29 2016 02:30
@vuk81 If it worked, you didnt call it on string.
Or you extended String.prototype with .join method
buiphuking
@buiphuking
May 29 2016 02:30
@Chrono79
mine

function smallestCommons(arr) {
  var newArr = [];
  arr = arr.sort();
   for ( var i = 0; i < arr[1]; i++){
     newArr[i] = arr[0] + i;
   }
   var x = true;
   var k = 1; 
   while(x){
     k++;
     for( var j = newArr[newArr.length - 2]; j >= newArr[0]; j--){
       if( arr[1] * k % j !==0){
         break;
       }
       if( j === newArr[0]){
         x = false;
       }
     }
   }
    return arr[1] * k;

}


smallestCommons([1,5]);
Diego Mayer
@Chrono79
May 29 2016 02:31
@buiphuking arr.sort() is not the right way to sort an array of numbers
Kris Greason
@AureliaWarleader
May 29 2016 02:32
Thanks @Chrono79 , I'll check it out shortly.
I understand the overall utility of regex but is it supposed to work in the Palindrome problem? I'm trying to use a confirmed regex patter for removing non-alphanumeric characters but it doesn't appear to be working. I don't know if that's because the pattern is off or because regex wouldn't work for some reason in the FCC answer box thingy (I'm not doing well with words, twas a long day at work)
CamperBot
@camperbot
May 29 2016 02:32
aureliawarleader sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 922 | @chrono79 |http://www.freecodecamp.com/chrono79
buiphuking
@buiphuking
May 29 2016 02:32
@Chrono79
i take that, keep reading
vuk81
@vuk81
May 29 2016 02:33
This is my plan. word "The dog" convert to arr("T","h","e", etc.) and than use join to receive "Thedog" then reverse it and compare with original
Justin Woodward
@jwoo92
May 29 2016 02:33
@sjames1958gm final result twitch.tv app.
Mateusz Szymański
@matszym
May 29 2016 02:34

@vuk81
this is what array you will get

["T", "h", "e", " ", "d", "o", "g"]

see the element with space in it? Its not going to be romoved after split

Kris Greason
@AureliaWarleader
May 29 2016 02:35
Nvm, I think I answered my own question
vuk81
@vuk81
May 29 2016 02:36
thats why I will use replace(" ",'')
Diego Mayer
@Chrono79
May 29 2016 02:37
@buiphuking it seems to work, doesn't it?
buiphuking
@buiphuking
May 29 2016 02:39
@Chrono79
my code has 117 step to get result, pythontutor.com
yours 43, i want to ask you something, why you
candidateSCM += arr1*(arr1-1);
are you sure about that ?
Diego Mayer
@Chrono79
May 29 2016 02:39
@buiphuking pretty sure
buiphuking
@buiphuking
May 29 2016 02:41
@Chrono79
now i get this, just your is a bit complicate , is there anyway to clean your code ?
Diego Mayer
@Chrono79
May 29 2016 02:42
@buiphuking you could try ;)
ALMY91
@ALMY91
May 29 2016 02:45
Hi can anyone come up with a simple code illustration to show the difference between a static function and a method invoked on individual objects?
Mateusz Szymański
@matszym
May 29 2016 02:48
@ALMY91
function staticFunction(){

}

var obj = {
  methodOnObject: function(){}
}
@ALMY91 the value of this will be different
ALMY91
@ALMY91
May 29 2016 02:49
@matszym what does methodOnObject do?
@matszym so the first one is a static function and the 2nd is a non static function?
Mateusz Szymański
@matszym
May 29 2016 02:50
@ALMY91 nothing, since its empty function
Honestly, I asume that the first one is static function, but I dont really recall anyone using word static to describe function in js
One more difference, the staticFunction can be called before its defined in code, since it will be hoised anyway, but mothod declaration on object wont
Diego Mayer
@Chrono79
May 29 2016 02:53
@matszym I think he means String.fromCharCode() or some other static method, although he wrote function
Miguel López
@miguelopezv
May 29 2016 02:54
Hi everybody! can someone give me an advice with the Chunky Monkey challenge? I've benn thinking about it for a while but I can't figure out how to begin.
ALMY91
@ALMY91
May 29 2016 02:54
@matszym @Chrono79 still confused hah im a beginner
Mateusz Szymański
@matszym
May 29 2016 02:54
so
staticFunction(); //can be called
function staticFunction() { return this; } //in browser will return window

obj.methodOnObject() //cannot be called before defined
var obj = {
  methodOnObject: function(){ return this} // returns obj
}
@Chrono79 Could be, but thers nothing static on methods defined on String. They can be changed, prototype can be extended etc Thats why you'll more often hear dynamic as describing behavior of js instead of static ;)
Diego Mayer
@Chrono79
May 29 2016 02:57
@miguelopezv you can use a loop and slice or splice (maybe not the same loop for both methods)
@matszym
The static String.fromCharCode() method returns a string created by using the specified sequence of Unicode values
I think sometimes you can use a static method in something that's not really that type, as when you use var args = Array.prototype.slice.call(arguments);
buiphuking
@buiphuking
May 29 2016 02:58
@Chrono79
Plz explain me this line ,
if (count === arr1-arr[0]-1
i am not sure about this?
Miguel López
@miguelopezv
May 29 2016 02:59
@Chrono79 any other advice? I'm feeling really lost with it... don't know how to define with items should go to which nested array
ALMY91
@ALMY91
May 29 2016 03:00
@matszym why isn my browser returning anything tho?
Diego Mayer
@Chrono79
May 29 2016 03:00
@buiphuking that means the scm is divisible for all the numbers in the range
ALMY91
@ALMY91
May 29 2016 03:00
blob
staticFunction(); //can be called
function staticFunction() { return this; } //in browser will return window
@matszym i followed exactly as u mentioned but nth is appearing
Diego Mayer
@Chrono79
May 29 2016 03:01
@miguelopezv using a while loop + splice is the easiest one
Norvin Burrus
@ndburrus
May 29 2016 03:01
@vuk81 which challenge?
buiphuking
@buiphuking
May 29 2016 03:02
@Chrono79
good job!, you really put your energy on js
Mateusz Szymański
@matszym
May 29 2016 03:02
@ALMY91 console contains log of your action, its seems like you didnt paste code in console
Diego Mayer
@Chrono79
May 29 2016 03:02
@buiphuking :+1: I try (sometimes)
ALMY91
@ALMY91
May 29 2016 03:04
@matszym ah i see but why does it return the word window when we return this? its the first time im coming across this..
Mateusz Szymański
@matszym
May 29 2016 03:05
@ALMY91 it returns object window
ALMY91
@ALMY91
May 29 2016 03:05
@matszym is that a default object everytime if we return this?
Mateusz Szymański
@matszym
May 29 2016 03:05
@ALMY91 no, check comment on the method of object

@ALMY91

this will take value of context you are running function/method in

ALMY91
@ALMY91
May 29 2016 03:07
@matszym this is confusing, i'd prolly change the return value to a string first... iv yet to come across this study and its making me even more confused haha
Mateusz Szymański
@matszym
May 29 2016 03:08
proof of concept.png
@ALMY91
ALMY91
@ALMY91
May 29 2016 03:10
@matszym is this the same theory as anoymous function and function declaration?
@matszym declared functions i meant
Mateusz Szymański
@matszym
May 29 2016 03:12
This depends on contex of execution. I can force method on one object to different context, like window, even when the context should be some other object this method was defined on
@ALMY91 and othe way around, function declared with default window context can be changed to some other. There are 3 methods on Object to do that, bind, apply, call
ALMY91
@ALMY91
May 29 2016 03:16
@matszym could we simplify the code , im a beginner here so there are certain things tt u hv mentioned ive yet to come across, say for example if i do this, does it still represent a non-static function?
var obj = {
  function staticFunction(){ return "hello";} // returns "hello"
}
console.log(obj) //cannot be called before defined
Mateusz Szymański
@matszym
May 29 2016 03:17
@ALMY91 I dont think compiler would let you do that
ALMY91
@ALMY91
May 29 2016 03:18
@matszym whys that so?
Mateusz Szymański
@matszym
May 29 2016 03:18
@ALMY91
VM172:2 Uncaught SyntaxError: Unexpected identifier(…)
@ALMY91 try running the code you wrote
ALMY91
@ALMY91
May 29 2016 03:19
@matszym yep i did but i don really understand why it doesn allow me to run when i took away methodOnObject
Mateusz Szymański
@matszym
May 29 2016 03:19
@ALMY91 object is collection of key: value pairs
@ALMY91 you didnt specify key in your object
ALMY91
@ALMY91
May 29 2016 03:20
@matszym what if i didn want it to be an object but just a function inside a variable declaration?
Mateusz Szymański
@matszym
May 29 2016 03:21

@ALMY91

var staticFunction = function staticFuction() { return 'Hello"};

Like that?

ALMY91
@ALMY91
May 29 2016 03:23
@matszym yeps... tt should be a non staticfunction by the way
@matszym tried that in my console and it ain working
Mateusz Szymański
@matszym
May 29 2016 03:24
yes, typo, did ' and " on string
ALMY91
@ALMY91
May 29 2016 03:24
@matszym oh wait it did...
var staticFunction = 
  function staticFunction(){ return "hello";} 

console.log(staticFunction)
@matszym this was my code
and it returned this in my browser
blob
@matszym now if i did this
var staticFunction = 
  function staticFunction(){ return "hello";} 

console.log(staticFunction())
it returns
Mateusz Szymański
@matszym
May 29 2016 03:26
@ALMY91 So, again: Term static functions carry badgagge from other languages like c, and it doesnt apply here. javascript is prototypal language, not class based one
ALMY91
@ALMY91
May 29 2016 03:27
blob
Mateusz Szymański
@matszym
May 29 2016 03:27
@ALMY91 You wont really hear much about static functions in contex of js
If someone would be saying about static functions, I would asume hes talking about function, not methods - because that the only real distinction in js
ALMY91
@ALMY91
May 29 2016 03:29
@matszym actually im starting to wonder whats the purpose of picking up javascript other than for the beauty of the language, my friend kept persuading me not to dive in too deep bcos its "not practical" ..
Mateusz Szymański
@matszym
May 29 2016 03:30
@ALMY91 if you dont want to program anything in servers, browser and internet of things devices I agree, its not practical
ALMY91
@ALMY91
May 29 2016 03:30
@matszym he keeps on lamenting that im basically wasting my time trying to dive this deep into the language... im actually now on the Definitive guide book on Javascript
@matszym im hoping to develop some professional looking websites of my own in the near future... prolly create apps as well
Mateusz Szymański
@matszym
May 29 2016 03:32
If you want to program drivers, kernels, apps for android, osx, windows, I would say the same, not practical
Eric Murta
@murtinha
May 29 2016 03:32
Guys, I'm having problems with my userPlay function, I need it to mark the X or O wherever row/column the player clicks...
http://codepen.io/murtinha/pen/VaJmgM?editors=1000
ALMY91
@ALMY91
May 29 2016 03:32
@matszym so why would u be interested in this language?
Mateusz Szymański
@matszym
May 29 2016 03:33
servers, browsers, IoT @ALMY91
Elbert Cortez
@trip16661
May 29 2016 03:34
How can i tore ajax json response into javascript variable using promise
ALMY91
@ALMY91
May 29 2016 03:34
@matszym sigh im been on this for close to 6mths now... i did html and css for the first 3 mths tho. this is depressing to hear
@matszym i might hv to give it up as much as i don want to..
Mateusz Szymański
@matszym
May 29 2016 03:34
@ALMY91 Depresing? How so?
ALMY91
@ALMY91
May 29 2016 03:36
@matszym im being told that all my efforts are impractical n gg down the drain after 6 mths of coding....
Mateusz Szymański
@matszym
May 29 2016 03:37
Javascript is the only language that there is to do DOM manipulation in browser. As a bonus we go backend, you can create moder web aplication with knowing single language. We are living in times where javascript is evrywhere, can you point to more versatile language?
ALMY91
@ALMY91
May 29 2016 03:38
@matszym i dont really understand what ur saying.. u mean we are able to create modern web applications without knowing a single language?
Mateusz Szymański
@matszym
May 29 2016 03:39
@ALMY91 no, I said we can, with single language
ALMY91
@ALMY91
May 29 2016 03:40
@matszym so does it mean that by learning html , css , javascript and jquery i would be able to set up a customized professional looking website of my own.
@matszym i just don understand why my friend said it was an impractical language yet everybody is picking up javascript these days...
Mateusz Szymański
@matszym
May 29 2016 03:41
javascript is key here. Dont focus on learning frameworks, you will start to notice they all follow specific design patterns that are simmilar to all of them. I really wish that I know what dependency injection is, before I started learning angular
@ALMY91 It depends - like is said, you arent going to write drivers in javascript, kernels or do memory manipulation
ALMY91
@ALMY91
May 29 2016 03:44
@matszym okay i just need some affirmation here that investing my time in this language is not a waste of time.. if my final goal was to customize a professional website of my own (and probably do that for others) , and also to create apps. Otherwise what wld u suggest
Mateusz Szymański
@matszym
May 29 2016 03:47
@ALMY91 Well, if you want to just make a website for yourself, it might me waste of time. Assuming you could get a job at minimal wage, you would spent lest time working to earn money for website, than learning how to do it yourself.
@ALMY91 If you dont want to commit your time, I wouldnt recommend jumping in, expecting unrealisting outcomes. There is a lot of misinformation spreaded around the web about how easy it is to learn enough to get hired, etc. Most of it are lies
ALMY91
@ALMY91
May 29 2016 03:49
@matszym yep i know that.. im actually holding on a fulltime finance job while learning how to code.. its not tt im forcing myself to code tho, i find it interesting almost like a hobby to keep my mind occupied in my freetime
Mateusz Szymański
@matszym
May 29 2016 03:50
@ALMY91 In other hand, you can start making prototype of applications with very limited knowledge
ALMY91
@ALMY91
May 29 2016 03:50
@matszym my end goal isn really to get hired in a company as an IT developer tho... i wld prolly do it freelance but not in a 9 to 6 job that would definitely suck the fun out of it
Mateusz Szymański
@matszym
May 29 2016 03:50
@ALMY91 Those would be enough to test a concept, but would have to be rewritten by professionals to scale for millions hits
@ALMY91 small freelancing jobs are similar, totally different skillset required
@ALMY91 You kind of have to be jack of all trades, from seling to coding, to deploing to servers
@ALMY91 in other hand customers wont be picky about the quality of code you write, they would focus more on the look of website
@matszym it states that learning these 4 languages wld be sufficient for me to build a proper website tho :(
KingCodeV
@KingCodeV
May 29 2016 03:54
got a q, how is used the filter method?
Xavier Velez
@JonSnow08
May 29 2016 03:56
can anybody help with the Make Object Properties Private checkpoint?
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

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

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

var myCar = new Car();

var myBike = new Bike();
Mateusz Szymański
@matszym
May 29 2016 03:56
@KingCodeV filter is method on array, that will return only those elements, that meet your criteria. simple example of filter:
[1, 2, 3, 4].filter(function(value){
//return only numbers bigger than 2
return value > 2;
});
Xavier Velez
@JonSnow08
May 29 2016 03:57
i think I'm okay up to the this.setGear function but I may be wrong
Mateusz Szymański
@matszym
May 29 2016 03:58
@JonSnow08
you are declaring another variable in your function scope, so your outer gear variable is not affected
KingCodeV
@KingCodeV
May 29 2016 03:58
@matszym let me check
Xavier Velez
@JonSnow08
May 29 2016 03:59
@matszym so my issue is that function? or I have work on the other code as well?
Mateusz Szymański
@matszym
May 29 2016 04:00

@JonSnow08 after you correct

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

to

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

Let me know what tests doesnt pass

Xavier Velez
@JonSnow08
May 29 2016 04:00
this better?
this.setGear = function(gear){
this.getGear = gear;
};
};
Mateusz Szymański
@matszym
May 29 2016 04:01
@JonSnow08 no
Xavier Velez
@JonSnow08
May 29 2016 04:01
the last 3
still
Mateusz Szymański
@matszym
May 29 2016 04:01
@JonSnow08 quote them
Xavier Velez
@JonSnow08
May 29 2016 04:01
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Mateusz Szymański
@matszym
May 29 2016 04:02
@JonSnow08 post your code after changes
Xavier Velez
@JonSnow08
May 29 2016 04:02
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

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

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

var myCar = new Car();

var myBike = new Bike();
Mateusz Szymański
@matszym
May 29 2016 04:03

@JonSnow08
the issue is variable shadowing

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

you have to use different variable for argument

  this.setGear = function(g){
      gear = g; 
  };
Xavier Velez
@JonSnow08
May 29 2016 04:03
okay cool
thank you
Mateusz Szymański
@matszym
May 29 2016 04:04
@JonSnow08 works now?
Xavier Velez
@JonSnow08
May 29 2016 04:04
yep
@matszym tyvm
@matszym thanks (wanted you to get brownies haha)
CamperBot
@camperbot
May 29 2016 04:04
jonsnow08 sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 75 | @matszym |http://www.freecodecamp.com/matszym
Kris Greason
@AureliaWarleader
May 29 2016 04:18
okay, one more question. I was wondering why this code doesn't work. It works until the last item in the array and doesn't do a comparison.
function largestOfFour(arr) {

  for(i = 0; i < arr.length; i++){
    for(j = 0; j < arr[i].length; j++){
      if(arr[i][j] >= arr[i][j - 1]) {
        arr[i].shift();
      } else {
        arr[i].splice(j, 1);
      }
    }
  }

  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
So I end up with something like [[5, 3], [27, 26], [37, 39], [1001, 1]]
ALMY91
@ALMY91
May 29 2016 04:25
var book = {
  "main author": "JK Rowling",
};

var authorValue =book["main author"];

book["main author"]="Donald Trump";

console.log (authorValue);
hm why dont my console show "Donald Trump"
Mateusz Szymański
@matszym
May 29 2016 04:26
@ALMY91 strings are passed by value, value of authorValue is determined before you change it to Donald Trump
Kris Greason
@AureliaWarleader
May 29 2016 04:34
Well, I've got to go to bed. I'll figure it out tomorrow.
Xavier Velez
@JonSnow08
May 29 2016 04:34
@AureliaWarleader wish I could help but I'm not that far
Deanna
@DeannaB
May 29 2016 04:34
Hello all, I'm having trouble with the "Word Blanks" section
not sure what they are asking for
Xavier Velez
@JonSnow08
May 29 2016 04:35
@DeannaB give me a sec
Joseph
@revisualize
May 29 2016 04:36
@DeannaB It is asking you to create a string from variables.
jrohrssen
@jrohrssen
May 29 2016 04:36
@DeannaB It's a fill in the blanks, so create a string, adding in the words passed in
Xavier Velez
@JonSnow08
May 29 2016 04:37
@DeannaB you need to use the function to create a sentence using the words passed in by the arguments in the function
Deanna
@DeannaB
May 29 2016 04:37
@jrohrssen @revisualize @JonSnow08 so essentially, I create a new function similar to the one at the top that they provide?
Joseph
@revisualize
May 29 2016 04:37
var h = "Hello";
var w = "World";
var result = h + w;
@DeannaB You don't have to create a new function.
Xavier Velez
@JonSnow08
May 29 2016 04:38
@DeannaB nope you create a variable
jrohrssen
@jrohrssen
May 29 2016 04:38
@DeannaB ^^^
Norvin Burrus
@ndburrus
May 29 2016 04:38
@ALMY91 this may be helpful:
code:
var book = {
  "main author": "JK Rowling",
};

console.log("book, main author: " + book["main author"]);

var authorValue =book["main author"];
console.log("authorValue, main author: " + authorValue);

book["main author"]="Donald Trump";
console.log("book, main author: " + book["main author"]);

console.log ("authorValue: " + authorValue);
console.log("book, main author: " + book["main author"]);
-----------------------------------------
output:
book, main author: JK Rowling
authorValue, main author: JK Rowling
book, main author: Donald Trump
authorValue: JK Rowling
book, main author: Donald Trump
jrohrssen
@jrohrssen
May 29 2016 04:38
@DeannaB inside the function
Joseph
@revisualize
May 29 2016 04:38
@DeannaB
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
Xavier Velez
@JonSnow08
May 29 2016 04:39
and I'll give you a hint, make sure you put spaces or you won't pass
Deanna
@DeannaB
May 29 2016 04:39
@revisualize @jrohrssen @JonSnow08 ok thanks! Let me go try
CamperBot
@camperbot
May 29 2016 04:39
:cookie: 237 | @jonsnow08 |http://www.freecodecamp.com/jonsnow08
:cookie: 251 | @jrohrssen |http://www.freecodecamp.com/jrohrssen
jrohrssen
@jrohrssen
May 29 2016 04:39
stupid spaces...
CamperBot
@camperbot
May 29 2016 04:39
:star2: 1184 | @revisualize |http://www.freecodecamp.com/revisualize
deannab sends brownie points to @revisualize and @jrohrssen and @jonsnow08 :sparkles: :thumbsup: :sparkles:
Xavier Velez
@JonSnow08
May 29 2016 04:39
hahaha
Joseph
@revisualize
May 29 2016 04:39
@JonSnow08 @DeannaB That's actually in the instructions:
You will also need to provide additional strings, which will not change, in between the provided words.
Xavier Velez
@JonSnow08
May 29 2016 04:39
let us know what you come up with
oh haha i didn't read that part @revisualize
Joseph
@revisualize
May 29 2016 04:40

@JonSnow08 @DeannaB Kind of link.. What is the return of result in my example?

var h = "Hello";
var w = "World";
var result = h + w;

(Note: I made the mistake on purpose.)

Xavier Velez
@JonSnow08
May 29 2016 04:40
HelloWorld
Joseph
@revisualize
May 29 2016 04:41
Exactly.
jrohrssen
@jrohrssen
May 29 2016 04:41
no passy
Xavier Velez
@JonSnow08
May 29 2016 04:41
no spacey no passy
jrohrssen
@jrohrssen
May 29 2016 04:41
indeed
Deanna
@DeannaB
May 29 2016 04:41
@jrohrssen @revisualize @JonSnow08 Ok what I'm not understanding now is, am I supposed to create a new string called "result," but there's already a var called "result?" Thank you for your answers/patience--I'm quite new at JS (if you couldn't tell) :)
CamperBot
@camperbot
May 29 2016 04:41
deannab sends brownie points to @jrohrssen and @revisualize and @jonsnow08 :sparkles: :thumbsup: :sparkles:
:warning: deannab already gave revisualize points
:warning: deannab already gave jonsnow08 points
:warning: deannab already gave jrohrssen points
ALMY91
@ALMY91
May 29 2016 04:42
@matszym thanks
CamperBot
@camperbot
May 29 2016 04:42
almy91 sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 76 | @matszym |http://www.freecodecamp.com/matszym
Joseph
@revisualize
May 29 2016 04:42
@DeannaB How do you change a variable?
Deanna
@DeannaB
May 29 2016 04:42
@revisualize You write a new variable below it?
Xavier Velez
@JonSnow08
May 29 2016 04:42
@DeannaB yup you're redefining the variable
Deanna
@DeannaB
May 29 2016 04:42
like assign it again?
Xavier Velez
@JonSnow08
May 29 2016 04:42
@yup
Joseph
@revisualize
May 29 2016 04:42
@DeannaB No.
Xavier Velez
@JonSnow08
May 29 2016 04:43
well dont reassign
Joseph
@revisualize
May 29 2016 04:43
@DeannaB You just assign it again. You don't create a new variable.
Xavier Velez
@JonSnow08
May 29 2016 04:43
so instead of var result = whatever it's result = whatever
Deanna
@DeannaB
May 29 2016 04:43
Ok so

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line

I put in between the comments
Xavier Velez
@JonSnow08
May 29 2016 04:43
perfect
Joseph
@revisualize
May 29 2016 04:43
@DeannaB Bingo.
Deanna
@DeannaB
May 29 2016 04:44
like var result = ""; (something in between the quotes) ?
Xavier Velez
@JonSnow08
May 29 2016 04:44
now what do you have to pass into it to create a sentence
Joseph
@revisualize
May 29 2016 04:44
@DeannaB No.
Xavier Velez
@JonSnow08
May 29 2016 04:44
not all of it because then it will read it as a string @DeannaB
Joseph
@revisualize
May 29 2016 04:44
@DeannaB You don't need to declare the variable. It has already been declared.
Deanna
@DeannaB
May 29 2016 04:44
@JonSnow08 Pass info into parameters? I remember something like that from a JS tutorial I watched recently...
@revisualize That's what I don't understand--it's blank
jrohrssen
@jrohrssen
May 29 2016 04:45
@DeannaB have you written any code for this challenge yet? If so, post it, it will help us explain
Deanna
@DeannaB
May 29 2016 04:45
haha I tried a couple of things that were all wrong
let me post some
Joseph
@revisualize
May 29 2016 04:45
@DeannaB
var result = "";
var result = "Fish"; // this isn't correct.
result = "new text"; // no 'var' declaration is needed because it has already been declared.
Deanna
@DeannaB
May 29 2016 04:46
I thought maybe it was like this:

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var result = "myNoun + is + myAdjective + and it + myVerb + myAdverb";

// Your code above this line

ohhhh just leave out "var"
?
Xavier Velez
@JonSnow08
May 29 2016 04:46
okay so first things first. you've defined the variable already
so yes
jrohrssen
@jrohrssen
May 29 2016 04:46
@DeannaB yes, but you need quotes for the non-variables
Deanna
@DeannaB
May 29 2016 04:46
@JonSnow08 ok got it, got it
Joseph
@revisualize
May 29 2016 04:46
@jrohrssen But, @DeannaB has quotes around the variables.
Deanna
@DeannaB
May 29 2016 04:46
so once a variable is defined, you can assign it another value, but don't use "var" again, just use the name of it
right?
Joseph
@revisualize
May 29 2016 04:47
@DeannaB Correct.
Xavier Velez
@JonSnow08
May 29 2016 04:47
also if you type it with "" the entire thing will read as a string
so instead of pulling the variable
Deanna
@DeannaB
May 29 2016 04:47
so only put quotes around the words not defined in the parameters of the function?
Xavier Velez
@JonSnow08
May 29 2016 04:47
it will just return myNoun
exactly
Joseph
@revisualize
May 29 2016 04:48

What happens when I do..

var name = "Joseph";
return "name";

??

Xavier Velez
@JonSnow08
May 29 2016 04:48
and dont forget those pesky spaces
Deanna
@DeannaB
May 29 2016 04:48
I got it!
jrohrssen
@jrohrssen
May 29 2016 04:48
stupid spaces
Xavier Velez
@JonSnow08
May 29 2016 04:49
congrats @DeannaB
Deanna
@DeannaB
May 29 2016 04:49
Ok, no var, added spaces, quotes only around non-parameter words
jrohrssen
@jrohrssen
May 29 2016 04:49
@DeannaB well done
Xavier Velez
@JonSnow08
May 29 2016 04:49
exactly
Joseph
@revisualize
May 29 2016 04:49
Time for the next one.
Deanna
@DeannaB
May 29 2016 04:49
Hurray! Thank you all @JonSnow08 @jrohrssen @revisualize for helping a noob like me. I hope you have good karma or something for your kindness :)
CamperBot
@camperbot
May 29 2016 04:49
deannab sends brownie points to @jonsnow08 and @jrohrssen and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: deannab already gave jrohrssen points
:warning: deannab already gave jonsnow08 points
:warning: deannab already gave revisualize points
Joseph
@revisualize
May 29 2016 04:49
@DeannaB Have fun playing with arrays
Xavier Velez
@JonSnow08
May 29 2016 04:50
@DeannaB no problem I'm only this far because of people who helped me in chat =]
Deanna
@DeannaB
May 29 2016 04:50
I have learned HTML, CSS, and SQL pretty well, but holy moley Javascript is something else
well I will have to do the same @JonSnow08
Joseph
@revisualize
May 29 2016 04:50
@DeannaB What are the four basic SQL commands?
jrohrssen
@jrohrssen
May 29 2016 04:50
@revisualize yeah, chunky monkey is kicking my behind
Xavier Velez
@JonSnow08
May 29 2016 04:50
thats funny, i felt the same way about HTML maybe because i learned JS first
Joseph
@revisualize
May 29 2016 04:50
Without looking.
Deanna
@DeannaB
May 29 2016 04:50
@revisualize Let's see, Select,
Joseph
@revisualize
May 29 2016 04:50
1
jrohrssen
@jrohrssen
May 29 2016 04:51
@DeannaB hint: it's an acronym
Deanna
@DeannaB
May 29 2016 04:51
@jrohrssen Oh ok! That's helpful
I use SQL at work to pull pretty simple queries
Joseph
@revisualize
May 29 2016 04:51
@jrohrssen It is?
jrohrssen
@jrohrssen
May 29 2016 04:51
yes
Xavier Velez
@JonSnow08
May 29 2016 04:51
Select, Query, Library?
Deanna
@DeannaB
May 29 2016 04:51
so usually it's SELECT x from x tables, WHERE x is what you want,
Xavier Velez
@JonSnow08
May 29 2016 04:52
and thats just a guess lmfao
Joseph
@revisualize
May 29 2016 04:52
@JonSnow08 Nope.
Xavier Velez
@JonSnow08
May 29 2016 04:52
lol damn
Deanna
@DeannaB
May 29 2016 04:52
haha idk the acronym
Joseph
@revisualize
May 29 2016 04:52
@JonSnow08 Also SQL stands for Structured Query Language
Xavier Velez
@JonSnow08
May 29 2016 04:52
I havent dipped into SQL yet
thanks @revisualize
CamperBot
@camperbot
May 29 2016 04:52
jonsnow08 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1185 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 29 2016 04:52
Select, Insert, Update, Delete
jinrawx
@jinrawx
May 29 2016 04:53
yooo anyone here pretty good with configuring gulpfiles?
Deanna
@DeannaB
May 29 2016 04:53
so @revisualize I just know the basics of like select, from, where,
basic joins, etc.
Joseph
@revisualize
May 29 2016 04:53
@DeannaB That's good.
I do not like Joins.
Deanna
@DeannaB
May 29 2016 04:53
I'm not an expert, but fluent enough to use it for what I need at work
oh ya?
Joseph
@revisualize
May 29 2016 04:53
I have to print out that picture.
That's how I remember joins.
That picture.
Deanna
@DeannaB
May 29 2016 04:55
@revisualize that's pretty cool
Actually my co-worker who is a data science wiz told me about Free Code Camp
Joseph
@revisualize
May 29 2016 04:55
@DeannaB But, yeah.. The answer was: Select, Insert, Update, Delete
jrohrssen
@jrohrssen
May 29 2016 04:55
@revisualize no one likes joins, but unfortunately with a normalized db you need them
Deanna
@DeannaB
May 29 2016 04:55
I had been using a few others apps, tutorials, etc.
@revisualize ahhhh ok
Joseph
@revisualize
May 29 2016 04:55
@DeannaB WHat do you do for where where you need SQL queries?
Deanna
@DeannaB
May 29 2016 04:56
I use a db at work that does the last 3 for you, has tools for end users
but for pulling quick reports, I use mostly Select and define what I need
@revisualize I work in college admissions, and we use a pretty old-school database, so I don't have anything fancy for data visualization/reporting
Joseph
@revisualize
May 29 2016 04:57
Ahh.
Deanna
@DeannaB
May 29 2016 04:57
@revisualize I think we are going to get a new system that integrates with Tableau
but hey, it gave me an excuse to learn the basics of SQL!
Joseph
@revisualize
May 29 2016 04:58
I'm currently a Network Operations Center Administrator. I used to be a ... Information Technology Administrator (System, Network, Database and Help Desk) ... I'm looking at moving to a job where I'll be a Network / System Administrator. Salary Negotiations have started.
@DeannaB SQL + Development Skills === $$$
Deanna
@DeannaB
May 29 2016 05:00
@revisualize Awesome! I see you live in Seattle--that's a great place for tech jobs. I'm from the Bay Area, but currently living in NorCal
Joseph
@revisualize
May 29 2016 05:00
@DeannaB Take notes about what you do and be sure to add the skills to your resume.. It will be helpful if you want to get a dev job.
Deanna
@DeannaB
May 29 2016 05:00
It's funny, I didn't start learning to code at all until I left Silicon Valley
Joseph
@revisualize
May 29 2016 05:00
@DeannaB I loathe the company that I work for.
Suzanne Atkinson
@AdventureBear
May 29 2016 05:00
evening all
jrohrssen
@jrohrssen
May 29 2016 05:01
@DeannaB nice, I grew up in Santa Rosa
jinrawx
@jinrawx
May 29 2016 05:01
@DeannaB : where in norcal, if i may ask?
Deanna
@DeannaB
May 29 2016 05:01
@revisualize Ughhh that sucks...well good luck on the salary negotiations! Decent money + happy company life sounds good!
Joseph
@revisualize
May 29 2016 05:01
@DeannaB That's a dream for me.
Deanna
@DeannaB
May 29 2016 05:01
@jinrawx Hi John, Sacramento area--there's a Sac meetup for Free Code Camp--we just did a meetup on Thursday
Joseph
@revisualize
May 29 2016 05:01
@AdventureBear Greetings.
Well.. I think I'm going to get naked.. rub water and soap all over my body... put on clean clothes... Then grab my pool cue and go bust some balls.
You kids have a good one.
jinrawx
@jinrawx
May 29 2016 05:02
@DeannaB : LOL. I wanted to go but I had some prior engagements. How was it?
Deanna
@DeannaB
May 29 2016 05:03
@revisualize Thanks for your help!
CamperBot
@camperbot
May 29 2016 05:03
deannab sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: deannab already gave revisualize points
Joseph
@revisualize
May 29 2016 05:03
:v:
Deanna
@DeannaB
May 29 2016 05:03
@jinrawx It was good! We met up at a coffee house, talked about FCC, how far along everyone was, etc. Planning to do it again some time soon
Suzanne Atkinson
@AdventureBear
May 29 2016 05:04
Can anyone help me with a javascript question? I'm trying to reverse engineer my own wordpress website a developer helped me with 3 years ago and have one sticking point. The developer jumped ship and moved overseas never to be heard from again
TechAgent
@cyberwizkid
May 29 2016 05:04
@DeannaB hi
Deanna
@DeannaB
May 29 2016 05:05
@cyberwizkid Hi there
TechAgent
@cyberwizkid
May 29 2016 05:05
@DeannaB @DeannaB were a path of the valve team?
Deanna
@DeannaB
May 29 2016 05:05
@cyberwizkid ? I'm not sure what that means
TechAgent
@cyberwizkid
May 29 2016 05:05
@DeannaB where u a part of the valve team
Deanna
@DeannaB
May 29 2016 05:06
@cyberwizkid No...not sure what that is
@jinrawx Nice portfolio site, btw--looks good
TechAgent
@cyberwizkid
May 29 2016 05:06
@DeannaB K, did u participate in the development of the valve platform?
@DeannaB u seem to look familiar on that project
Deanna
@DeannaB
May 29 2016 05:08
@cyberwizkid Nope, not me!
jinrawx
@jinrawx
May 29 2016 05:08
@DeannaB : Why thank you for the compliment, and also for informing of how the meetup went! Hopefully we can have another meetup soon! I'll definitely do my best to attend and we can meet!
CamperBot
@camperbot
May 29 2016 05:08
jinrawx sends brownie points to @deannab :sparkles: :thumbsup: :sparkles:
:cookie: 164 | @deannab |http://www.freecodecamp.com/deannab
Suzanne Atkinson
@AdventureBear
May 29 2016 05:09
@revisualize have fun playing pool
Deanna
@DeannaB
May 29 2016 05:09
@jinrawx Yeah, it's a nice group, nice people, everyone learning and helping each other. It sounds like a lot of them go to lots of various dev meetups around the Sac area
jinrawx
@jinrawx
May 29 2016 05:10
@DeannaB: Is that so? I have seen that one of the guys that went to the meetup is active on both the davis and sacramento fb group.
Deanna
@DeannaB
May 29 2016 05:11
@jinrawx Oh I didn't know there was a Davis one. I joined the Sac and Folsom ones
@jinrawx But ya, a couple of those guys who came on Thursday go to lots of meetups, it seems like.
jinrawx
@jinrawx
May 29 2016 05:13
@DeannaB : How about you? do you often go to dev meetups?
Deanna
@DeannaB
May 29 2016 05:13
@jinrawx I just started. I actually work out of the Bay Area 2 days a week still, so unfortunately, I can't make too many.
jinrawx
@jinrawx
May 29 2016 05:15
@DeannaB I see! I haven't gone to one yet. I'm a little nervous since I've done such a meetup before. And dang, that commute to the bay must be a pain huh?
Deanna
@DeannaB
May 29 2016 05:16
@jinrawx Oh ya! The Free Code Camp meetup was pretty chill--I think like 6 of us went, a couple brought friends. I've done a few meetups of various kinds--as long as they're in a public place haha, it's cool
ALMY91
@ALMY91
May 29 2016 05:17
Hi guys
would like u all to do a check on my code
Xavier Velez
@JonSnow08
May 29 2016 05:17
Filter Arrays challenge isnt working for me even though I'm getting the right values in console
jrohrssen
@jrohrssen
May 29 2016 05:17
@ALMY91 post it
ALMY91
@ALMY91
May 29 2016 05:17
this was what was written in my book
var addr="";
for(i=0;i<4;i++){
addr+= customer["address"+i] +'\n';
Xavier Velez
@JonSnow08
May 29 2016 05:17

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
oldArray = oldArray.filter(function(val){
  return val <= 5 ;
});
var newArray = oldArray;
Use filter to create a new array with all the values from oldArray which are less than 6. The oldArray should not change.
it's returning [1,2,3,4,5] but im not passing
ALMY91
@ALMY91
May 29 2016 05:19
It states that this code reads and concatenates the address0, address1, address2 and address3 properties of the customer object. This brief example demonstrates the flexibility of using array notations to access properties of an object with string expressions.
jinrawx
@jinrawx
May 29 2016 05:19
@DeannaB : That's wassup. I don't feel a bit less nervouse about it now
ALMY91
@ALMY91
May 29 2016 05:19
im not too sure if im doing it right but this is what i got
var customer = {
  "address0": "Bedok",
  "address1": "Tampines",  
  "address2": "Holland V", 
  "address3": "Dempsey", 
};


var addr="";
for(i=0;i<4;i++){
addr+= customer["address"+i] +'\n';

console.log(addr)}
i added in the extra parts
is this what they are asking for?
Deanna
@DeannaB
May 29 2016 05:20
@jinrawx Cool! Well ya, the guy who asked about meeting up last week said he'll organize another meetup again soon, so I'm sure we'll see it in the group.
jrohrssen
@jrohrssen
May 29 2016 05:20
@JonSnow08 I don't think you need the var declaration at the end
jinrawx
@jinrawx
May 29 2016 05:21
@ALMY91 : 2 main things you should understand from this: 1) how to access keys in an object/array, 2) how to run a for loop on an array
Xavier Velez
@JonSnow08
May 29 2016 05:22
@jrohrssen tried that and nada
jinrawx
@jinrawx
May 29 2016 05:22
@DeannaB doooooope! I look forward to meeting you and the rest of the peeps!
Deanna
@DeannaB
May 29 2016 05:23
@jinrawx Sounds good!
jrohrssen
@jrohrssen
May 29 2016 05:23
@JonSnow08 what challenge is that?
ALMY91
@ALMY91
May 29 2016 05:23
@jinrawx im just not too sure if this is what they are asking for, ive got my console working tho
Xavier Velez
@JonSnow08
May 29 2016 05:24
Filter arrays with Filter @jrohrssen
jinrawx
@jinrawx
May 29 2016 05:24
@JonSnow08 : run the filter function on the variable declaration
@JonSnow08 : instead of on a separate line. so...
jrohrssen
@jrohrssen
May 29 2016 05:26
@JonSnow08 yes, set the newArray variable = to the function
Xavier Velez
@JonSnow08
May 29 2016 05:27
@jinrawx @jrohrssen thank you guys
CamperBot
@camperbot
May 29 2016 05:27
jonsnow08 sends brownie points to @jinrawx and @jrohrssen :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @jrohrssen |http://www.freecodecamp.com/jrohrssen
:cookie: 317 | @jinrawx |http://www.freecodecamp.com/jinrawx
jinrawx
@jinrawx
May 29 2016 05:27
@ALMY91 : Lol, well, do you understand how to access keys in an object and how to run for loops on array?
jrohrssen
@jrohrssen
May 29 2016 05:28
@JonSnow08 yw
jinrawx
@jinrawx
May 29 2016 05:28
@JonSnow08 : np, pay it forward when you see an opportunity!
Norvin Burrus
@ndburrus
May 29 2016 05:31
@JonSnow08 did you resolve it? val<6?
Xavier Velez
@JonSnow08
May 29 2016 05:32
@ndburrus hey man how are you? Yeah, these guys helped me out. I just wasnt setting the newArray variable to the actual function
Norvin Burrus
@ndburrus
May 29 2016 05:32
@JonSnow08 doing well.. ok, sounds good :)
TechAgent
@cyberwizkid
May 29 2016 05:37
hey guys
this challenges gets tougher each step, im stuck can i get assistance?
Damon Redding
@DamonRedding
May 29 2016 05:38
Hey everyone I've been tryin to do this palindrome challenge anyone have any pointers?
TechAgent
@cyberwizkid
May 29 2016 05:38
@DamonRedding hi
@DamonRedding can u help me out
topic: converting cecius to fah @DamonRedding
Damon Redding
@DamonRedding
May 29 2016 05:38
@cyberwizkid for sure what is it?
TechAgent
@cyberwizkid
May 29 2016 05:39
the first que, how do i write the answer to this que
convertToF(0) should return a number

```function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fa = (0 * 1.8)/32;

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

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

DJ
@qualitymanifest
May 29 2016 05:39
@DamonRedding paste your code if you have a specific question, but the gist of it is like this:
convert string to lowercase using toLowerCase() method
remove all non-alphanumerics using regex
compare string to itself backwards
TechAgent
@cyberwizkid
May 29 2016 05:40
code @DamonRedding
ALMY91
@ALMY91
May 29 2016 05:40
@jinrawx im pretty confused with regards to the difference between accessing using the dot and accessing w square brackets
TechAgent
@cyberwizkid
May 29 2016 05:40

```function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fa = (0 * 1.8)/32;

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

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

ALMY91
@ALMY91
May 29 2016 05:41
@jinrawx the book mentions that when we use the .operator to access a property of an object, howver the name of the property is expressed as an identifier and they must be typed literally into your Javascript program as they are not a datatype so they cannot b manipulated
@jinrawx on the other hand when we access a property of an object with the []array notations the name of the property is expressed as a string. Strings are datatypes so they can be manipulated n created while a program is running
TechAgent
@cyberwizkid
May 29 2016 05:42

```function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fa = (0 * 1.8)/32;

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

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

ALMY91
@ALMY91
May 29 2016 05:42
@jinrawx its kind of confusing
Jack Lyons
@JackEdwardLyons
May 29 2016 05:42
hey guys i'm struggling with my algorithm scripting -- not sure what to return in the loop :\

function diffArray(arr1, arr2) {
  // concatenate the two arrays
  var newArr = arr1.concat(arr2).sort();
  //scan the entire array for double ups
  for (var i = 0; i < newArr.length; i++) {
    if (newArr.indexOf(i) === newArr.lastIndexOf(i)) {

    }
  }


  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
TechAgent
@cyberwizkid
May 29 2016 05:42
can somehelp
Damon Redding
@DamonRedding
May 29 2016 05:43
@cyberwizkid you have to use the argument celsius should in the equatoin that you delcared fahrenheit equal to
@cyberwizkid for example var fahrenheit = celsius num num
fahrenheit = celsius number number
Idk why they keep deletin my * between number, but hopefully you get the jest
Damon Redding
@DamonRedding
May 29 2016 05:49
Screen Shot 2016-05-29 at 1.48.56 AM.png
I'm used to coding python where there's an elif @qualitymanifest
andyst81
@andyst81
May 29 2016 05:51
Hi guys, has anyone done the "Record Collection" activity?
Norvin Burrus
@ndburrus
May 29 2016 05:53
@andyst81 yes... can you post what you've got?
andyst81
@andyst81
May 29 2016 05:55

function updateRecords(id, prop, value) {

if (value !=="" && prop !=="tracks") {
collection[id][prop].push(value);
} else if (prop === "tracks" && value !=="") {
collection[id][prop]push(value);
} else if (value === "") {
delete collection[id][prop];
}
}
return collection;

function updateRecords(id, prop, value) {

if (value !=="" && prop !=="tracks") {
collection[id][prop].push(value);
} else if (prop === "tracks" && value !=="") {
collection[id][prop]push(value);
} else if (value === "") {
delete collection[id][prop];
}
}
return collection;

Coy Sanders
@coymeetsworld
May 29 2016 05:56
@DamonRedding you could use else if as a statement, you don't need to nest an if like that
andyst81
@andyst81
May 29 2016 05:56
sorry, trying to get the hang of this chat, can i post code in tags? or do I have to post a screenshot?
Coy Sanders
@coymeetsworld
May 29 2016 05:57
you can also simplify that code too a bit
Norvin Burrus
@ndburrus
May 29 2016 05:57
@cyberwizkid review/check (formula accuracy) the line var fa = (0 * 1.8)/32; :)
Coy Sanders
@coymeetsworld
May 29 2016 05:57
and I think it has some errors, think you should replace all non-alpha characters in your string
before you start checking if the String matches its reverse
Norvin Burrus
@ndburrus
May 29 2016 05:58
help format @andyst81
CamperBot
@camperbot
May 29 2016 05:58

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

andyst81
@andyst81
May 29 2016 05:59
thank you @ndburrus
CamperBot
@camperbot
May 29 2016 05:59
andyst81 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 29 2016 06:00
@andyst81 you're welcome...! nice work :+1:
Damon Redding
@DamonRedding
May 29 2016 06:00
@coymeetsworld Thank you, can you show me what you mean>
CamperBot
@camperbot
May 29 2016 06:00
damonredding sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 984 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 29 2016 06:00
which part @DamonRedding ?
for if/else if:
if (something) {

} 
else if (something else) {

}
else if (or something else) {

} 
else {

}
Damon Redding
@DamonRedding
May 29 2016 06:01
@coymeetsworld Simplification,
Norvin Burrus
@ndburrus
May 29 2016 06:01
@andyst81 these lines need attention: collection[id][prop]push(value); collection[id][prop]push(value); hint: is an operation necessary in these code lines? :) need to check the logic here (the action taken per the if statement) collection[id][prop].push(value);
Coy Sanders
@coymeetsworld
May 29 2016 06:01
oh well you have two checks to see if the strings match, and if they don't you put the string into lowercase and see if that matches.
you could just change the case of the strings before hand, actually I don't think that logic you have will work anyways, because you're not downcasing the reverse string either
Damon Redding
@DamonRedding
May 29 2016 06:03
What would be the best way to approach it?
Coy Sanders
@coymeetsworld
May 29 2016 06:05
do all the necessary processing on str first before anything else.
remove all non-alphanumeric characters, and downcase (or upcase) str
andyst81
@andyst81
May 29 2016 06:05
@ndburrus I got it now, thank you very much!!
CamperBot
@camperbot
May 29 2016 06:05
andyst81 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: andyst81 already gave ndburrus points
Coy Sanders
@coymeetsworld
May 29 2016 06:06
then after that see if str matches its reverse
Norvin Burrus
@ndburrus
May 29 2016 06:06
@andyst81 most excellent :sparkles: well done...
Coy Sanders
@coymeetsworld
May 29 2016 06:06
you would need only one if statement then
Damon Redding
@DamonRedding
May 29 2016 06:08
@coymeetsworld I see, thank you for your guidance good sir
CamperBot
@camperbot
May 29 2016 06:08
damonredding sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: damonredding already gave coymeetsworld points
Coy Sanders
@coymeetsworld
May 29 2016 06:09
no problem @DamonRedding good luck
Norvin Burrus
@ndburrus
May 29 2016 06:09
@ALMY91 here is an article you may enjoy: JS dot-notation vs. bracket notation {ref: https://medium.com/@prufrock123/js-dot-notation-vs-bracket-notation-797c4e34f01d#.iydeslvpl } (4 min. read) :+1:
Thompson Ike
@hubhubace
May 29 2016 06:09
pls help
js
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];





function lookUpProfile(firstName, prop) {

// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {


   if  (contacts[i].hasOwnProperty(prop)) {
         return contacts[i].prop; 

}

  else if (firstName !== contacts) {
    return "No such contact";
  }

       else  {
    return "No such property";
     }

}
}  


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
Coy Sanders
@coymeetsworld
May 29 2016 06:10
got a couple of issues @hubhubace
else if (firstName !== contacts) is not right. firstName is a String, contacts is an array. you can't compare those together
Also the placement of where you're checking for "No such contact" is wrong. You want to state theres no such contact after you've checked the entire array
also return contacts[i].prop needs to be fixed.
everything else looks ok
ALMY91
@ALMY91
May 29 2016 06:13
@ndburrus thank u it sure seems interesting to read
CamperBot
@camperbot
May 29 2016 06:13
almy91 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 454 | @ndburrus |http://www.freecodecamp.com/ndburrus
Ivan Aganin
@criativ
May 29 2016 06:14
I don't get it - I got the exercise - I look at it and freak out, that I have NO IDEA how to do this... WHILE freaking out in my head(and making myself some coffee), SOMEHOW I managed to get half of exercise done. I don't understand myself... is it just lack of experience or what???
Norvin Burrus
@ndburrus
May 29 2016 06:15
@ALMY91 i think it will improve your understanding... :) adding order to chaos... :sparkles:
Thompson Ike
@hubhubace
May 29 2016 06:16
@coymeetsworld ok
let me see
Coy Sanders
@coymeetsworld
May 29 2016 06:18
coding isn't easy @criativ, having some learning problems is normal. Try not to freak out as much :)
Ivan Aganin
@criativ
May 29 2016 06:19
@coymeetsworld yeah.... trying to do that :)
Norvin Burrus
@ndburrus
May 29 2016 06:19
@criativ i think it has something to do with continually being on the edge of learning something new... it's related to a feeling of being uncomfortable, which is a part of learning. how we handle/manage this process is important to developing into something greater... ...and that is my entire 2 cents :)
Coy Sanders
@coymeetsworld
May 29 2016 06:20
if you don't understand something you can always ask here, but important thing is to learn it. Some people I see breeze through these challenges as fast as they can and they don't seem to learn anything in the process
Ivan Aganin
@criativ
May 29 2016 06:23
@ndburrus thing is - couple days ago I helped someone here with some REALLY basic stuff. And I noticed - that "I was THAT person" just a couple months ago... Now, very basic stuff is OK with me, but then again, I'm going further - to more difficult stuff. So on one side - I'm better now than I was 2-3 months ago, but - I realize how little I know in a bigger picture.
Thompson Ike
@hubhubace
May 29 2016 06:23
@coymeetsworld pls check
js
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];





function lookUpProfile(firstName, prop) {

// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {


   if  (contacts[i].hasOwnProperty(prop)) {
         return contacts[i].prop; 

}

  else if (contacts[i].firstName !== contacts) {
    return "No such contact";
  }

       else  {
    return "No such property";
     }

}
}  


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
Ivan Aganin
@criativ
May 29 2016 06:24
@coymeetsworld I do understand th importance of REALNING it, not just finding it online and copy/pasting it :)
Thompson Ike
@hubhubace
May 29 2016 06:24
taking it step at a time
Coy Sanders
@coymeetsworld
May 29 2016 06:25
contacts[i].firstName !== contacts @hubhubace this still won't work. contacts[i].firstName is a string. contacts is an array. you can't compare a String and an Array of objects like that
also you need to fix contacts[i].prop
and also, you need to check for "No such contact" after you go through all contacts. In your logic you're not doing that
thats good @criativ, because I see alot of that too :)
some people put their challenges and ziplines online, in github or their blogs
which is fine I think there's not a rule you can't do that
but then other people just go and copy that and say they completed something
which you don't want to do, if it can be helped
Norvin Burrus
@ndburrus
May 29 2016 06:28
@criativ i think pausing occasionally to ascertain what is important/useful can be very helpful in moving forward. by this i mean, figuring out what tools help you (that you didn't use previously), what resources can be supportive (that were not consulted earlier), etc. by doing some of these types of things, i find i feel better about the process (while reducing uneasiness :) )... i also think it's great that you were nudged to notice (and appreciate) your own progress, while helping someone.
Coy Sanders
@coymeetsworld
May 29 2016 06:30
you also won't learn everything you need to learn about coding or even just JavaScript here, but it helps you get started. Theres alot of good (free) material out there to supplement FCC
Ivan Aganin
@criativ
May 29 2016 06:30
I try not to rush it but to do stuff every single day :) To learn thing or two each day and let myself get used to it :)
@ndburrus Helping is not hard, specially if you are able to help! :)
Norvin Burrus
@ndburrus
May 29 2016 06:32
@criativ indeed...
Shubham Mehta
@ZeusEm
May 29 2016 06:33
Er..Hi everybody! I tried the main room but apparently people didn't know about what I was talking so came here. I wanted to confirm something related to the call and apply functions in JS. Does anybody here know about them?
Ivan Aganin
@criativ
May 29 2016 06:36
@ZeusEm I'm not sure I can be of any help, but out of curiosity - what is your question? :)
Ankur sharma
@ankur1163
May 29 2016 06:37
i am trying to solve tic tac toe
I have to use minimax algorithm
where can i find mor einfo about minimax algo applied to tic tac toe
in some easy way :)
I can tell you about call function @ZeusEm
mrcsscco
@marcussacco
May 29 2016 06:38
I
I'm having a strange problem with Caesars Cipher. https://repl.it/CWXA
Norvin Burrus
@ndburrus
May 29 2016 06:39
@ankur1163 you may find this useful: Building a Tic-Tac-Toe AI with Javascript, {ref: http://mostafa-samir.github.io/Tic-Tac-Toe-AI/ } :)
Shubham Mehta
@ZeusEm
May 29 2016 06:39
I just read them yesterday and the idea what they did was a bit fuzzy in my mind. Basically I wanted to confirm that the call requires you to specify the comma separated list of arguments, for the object's method in whose context you're calling it, that you want to pass in and that the apply requires you to give in an array of args that can vary in number and/ or type from one call to another. Am I right?
Ankur sharma
@ankur1163
May 29 2016 06:40
all I know we use call. when we have two separate object. One object has data, other got method
we use call method to bind both of them together
suppose you have 5000 objects which contain employees data.
there is method calculator salary
now, if you put this method in 5000 objects. there is lot of wastage of memory
so , we create another object containing only the calculate salary method
we use call method to use that method with any other object
we can have
shubham.call(calculatesalary)
thats the farthest I have reached with this :)
Shubham Mehta
@ZeusEm
May 29 2016 06:46
thank you. thank you for that :)
mrcsscco
@marcussacco
May 29 2016 06:47
In caesars cipher, instead of returning FREE CODE CAMP, I return F8EE C5DE CAM6. I subtract 13 from the character codes, and the program returns the correct characters for the codes given. In order to get the R in FREE, I would need to switch to adding 13 to the character codes. Why is that?
Ankur sharma
@ankur1163
May 29 2016 06:49
@ZeusEm please watch this video
mrcsscco
@marcussacco
May 29 2016 06:56
Is it hopeless?
Shusil Banjade
@shusil123
May 29 2016 07:13

function palindrome(str) {
  // Good luck!
  var replacedStr = str.replace(/\W+/g, "");
  var mainStr = replacedStr.toLowerCase();
  var toCheck = mainStr.split("");
  var theArray = toCheck.reverse();
  var rString = theArray.join("");
  var fToCheck = rString.toLowerCase();
  if (mainStr === fToCheck) {
    return true;
  }

  else {
    return false;
  }

}



palindrome("eye");
What's wrong with this code ? I got all true except "palindrome("0_0 (: /-\ :) 0-0") should return true. "
Ivan Aganin
@criativ
May 29 2016 07:20
You can do it a little bit easier :)
Shusil Banjade
@shusil123
May 29 2016 07:22
Help me on this palindrome check .. ....
CamperBot
@camperbot
May 29 2016 07:22
no wiki entry for: me on this palindrome check
Ivan Aganin
@criativ
May 29 2016 07:23
@shusil123 The idea that i liked was make two arrays.
One - break all letters into an array and make them small characters
Second - make the same but reverse it
Third step - compare them
This is just the concept
Nick Svanidze
@nikasvan
May 29 2016 07:24
Hi Guys I am on Twitch JSON API project and having a weird bug. Code works only when debugging the script in dev tools. Am I missing anything?
$(document).ready(function() {
        var channels = ["OgamingSC2","sheevergaming", "ESL_SC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
        for (var i = 0; i < channels.length; i++) {
            $.getJSON('https://api.twitch.tv/kraken/streams/' + channels[i] + '?callback=?', function(data) {
                if (data.stream) {
                    $('.wrapper li').eq(i).css('background-color', "blue");
                } else {
                    $('.wrapper li').eq(i).css('background-color', "red");
                }

            });
        };

    })
Here is the full code http://codepen.io/nikasv/pen/GqRMXq
Chris Cullen
@123xylem
May 29 2016 07:32
function convertToRoman(num) {
  var arr=[];
  var newarr = arr.splice(1,0,"num");
 return newarr;
}




convertToRoman(5);
Why isnt this giving 5?
It outputs empty array
Jack Anderson
@JackAndersonLee
May 29 2016 07:36
Perhaps try removing the quotes around num
Also, return arr gives you 5
Alex Karofilakis
@juice9090
May 29 2016 07:42
Hello everyone!This is tictactoe zipline.
Im getting infinite loop at line 42 and 64.Can someone take a look and help me?
https://codepen.io/juice9090/pen/PzYadm?editors=0011
lightsomali
@lightsomali
May 29 2016 07:42
hi guys
Chris Cullen
@123xylem
May 29 2016 07:42
@JackAndersonLee it returns nothing
newarr is the newarr its stored in tho right?
Krzysztof Borowy
@Krizzu
May 29 2016 07:43
@123xylem your array is empty
Achillesthewarrior
@Achillesthewarrior
May 29 2016 07:43
palindrome("0_0 (: /-\:) 0-0");
Krzysztof Borowy
@Krizzu
May 29 2016 07:43
@123xylem you try to slice an empty array
Chris Cullen
@123xylem
May 29 2016 07:43
@Krizzu but isnt num defined as 5 at the bottom/
?
Krzysztof Borowy
@Krizzu
May 29 2016 07:44
@123xylem It is not, num is a number Where you stop slice, but since your array is empty, it will return nothing
  var arr=[];
  var newarr = arr.splice(1,0,"num");
Chris Cullen
@123xylem
May 29 2016 07:44
ah so splice doesnt know where to enter num
function convertToRoman(num) {
  var arr=[0];
  var newarr = arr.splice(0,1, num);
 return newarr;
}      
convertToRoman(5);
returns 0
Krzysztof Borowy
@Krizzu
May 29 2016 07:46
no no no
@123xylem arr = [0] means it's empty
Chris Cullen
@123xylem
May 29 2016 07:47
o lol
well ar1 returns 1 aswell tho :worried:
Krzysztof Borowy
@Krizzu
May 29 2016 07:48
@123xylem oh wait, are you trying to put something into array?
Chris Cullen
@123xylem
May 29 2016 07:49
yea and remove old nums
Krzysztof Borowy
@Krizzu
May 29 2016 07:49
If yes, arr.splice is changing the original array, so var newarr = arr.splice(0,1, num); is your problem
just leave arr.splice(0,1,num)
Chris Cullen
@123xylem
May 29 2016 07:50
ah strange but it works thanks
@Krizzu thanks
CamperBot
@camperbot
May 29 2016 07:50
123xylem sends brownie points to @krizzu :sparkles: :thumbsup: :sparkles:
:cookie: 387 | @krizzu |http://www.freecodecamp.com/krizzu
Chris Cullen
@123xylem
May 29 2016 07:50
what was wrong with newarr?
Krzysztof Borowy
@Krizzu
May 29 2016 07:50
@123xylem No worries! splice changes original array, but it returns what have been cut.
@123xylem so if you do var arr = otherArr.splice(0,1,3), arr will contain what have been cut out from otherArr
and otherArr will be without that part that was cut out
Chris Cullen
@123xylem
May 29 2016 07:51
ah right. its returning the splice not the new arr
Krzysztof Borowy
@Krizzu
May 29 2016 07:51
yup
Chris Cullen
@123xylem
May 29 2016 07:51
ty
Krzysztof Borowy
@Krizzu
May 29 2016 07:51
no worries
Norvin Burrus
@ndburrus
May 29 2016 07:59
@Krizzu i don't get that... i get a return [], with (0,1,num)
Krzysztof Borowy
@Krizzu
May 29 2016 08:00
@ndburrus hmm? :D
show me ur code
Norvin Burrus
@ndburrus
May 29 2016 08:00
function convertToRoman(num) {
  var arr=[];
  var newarr = arr.splice(0,1,num);
  //  array.splice(start, deleteCount[, item 1[, item 2[, ...]]])
  //  start: Index at which to start changing the array (with origin 0). 
  //  deleteCount: An integer indicating the number of old array elements to remove. 
  //  item 1, item 2, ...: The elements to add to the array, beginning at the start index.
  //  Returns: An array containing the deleted elements.
 return newarr;
}

convertToRoman(5);
Krzysztof Borowy
@Krizzu
May 29 2016 08:02
@ndburrus Yeah, splice is returning what has been cut out from array
and it is changing the array on what it was invoked on
Norvin Burrus
@ndburrus
May 29 2016 08:02
@Krizzu yes, however, it starts w/ an empty array - unless there is more code than i saw..
Krzysztof Borowy
@Krizzu
May 29 2016 08:03
@ndburrus
var arr = [];
var newarr = arr.splice(0,1,num)
arr is empty
Norvin Burrus
@ndburrus
May 29 2016 08:04
@Krizzu yes, i see that (an empty array - arr). so, splice starts at o (there are no array elements), eliminates 1/value (again no array items), and adds 5?
Krzysztof Borowy
@Krizzu
May 29 2016 08:04
@ndburrus so yeah, if you assign newarr to what have been cut out, it will be []
instead of return newarr; do return arr
and see what I mean
Norvin Burrus
@ndburrus
May 29 2016 08:06
ok, so why was a variable created?
Krzysztof Borowy
@Krizzu
May 29 2016 08:07
I don't know
:D
Norvin Burrus
@ndburrus<