These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Feb 2016
alpox
@alpox
Feb 25 2016 00:00 UTC
@caleb272 You have a wrong query string: action:random should be action=random
@caleb272 But this action is unknown by the wiki anyway. I don't know the right actions and whatsoever, i have just seen a wrong query string :D
Andrew Dutton
@andrew-dutton
Feb 25 2016 00:03 UTC
Hey all... I'm working on the titleCase bonfire... breaking it down in to smaller parts... I can't see what I've done wrong here... I can split the string in to an array, but my for loop isn't return each new array item... can't figure out why...
function titleCase(str) {
//convert string in an array of words
var strArray = str.split(" ");
//loop over array of words for way to access each word individually
for (var i=0; i<strArray.length; i++) {
return strArray[i];
}
Nairuz.Abulhul
@nairuzabulhul
Feb 25 2016 00:03 UTC
i have general question Is weather API or Wikipedia API considered RESTful services ????
Andrew Dutton
@andrew-dutton
Feb 25 2016 00:04 UTC
it returns only the first item (which would be strArray[0])
alpox
@alpox
Feb 25 2016 00:05 UTC
@ZeeMax I would say yes but don't blame me if i'm wrong :D
@caleb272 Your main problem would be:
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=opensearch&titles=test&format=json. Origin http://s.codepen.io is not allowed by Access-Control-Allow-Origin.
There are workarounds... But its not very nice. You will have to ask google i think
@AndreWaroux you return on the first occurrence in the loop. That breaks the loop and ends the function immediately without counting up
John Espinoza
@johnlovespi
Feb 25 2016 00:08 UTC
help!!!!!!!!!!
CamperBot
@camperbot
Feb 25 2016 00:08 UTC

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

Basic Commands:

  • find TOPIC find all entries about topic. ex: 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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

John Espinoza
@johnlovespi
Feb 25 2016 00:09 UTC
Accessing Nested Arrays in JSON ::
Andrew Dutton
@andrew-dutton
Feb 25 2016 00:09 UTC
thank you @alpox !
CamperBot
@camperbot
Feb 25 2016 00:09 UTC
andrewaroux sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
John Espinoza
@johnlovespi
Feb 25 2016 00:09 UTC
whats wrong with my code

var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.trees[0]; // Change this line

Norman Dela Cruz
@dcnr
Feb 25 2016 00:10 UTC
@johnlovespi look carefully at what your myPlants is. What type of variable is it?
John Espinoza
@johnlovespi
Feb 25 2016 00:11 UTC
object
Norman Dela Cruz
@dcnr
Feb 25 2016 00:11 UTC
@johnlovespi well technically it is, but specifically it's an array. Notice the starting [ and the ending ]. So you should first access myPlants as you would an array.
Orestis Gklavas
@oglavas
Feb 25 2016 00:12 UTC

Can someone tell me what I've done wrong? I get "Type error: this.setFullName is not a function
'''js
var Person = function(firstAndLast) {
var firstName = null;
var lastName = null;

Object.defineProperty(Person.prototype, 'getFirstName', {
get: function() {
return firstName;
}
});

Object.defineProperty(Person.prototype, 'setFirstName', {
set: function(name) {
firstName = name;
}
});

Object.defineProperty(Person.prototype, 'getLastName', {
get: function() {
return lastName;
}
});

Object.defineProperty(Person.prototype, 'setLastName', {
set: function(name) {
lastName = name;
}
});

Object.defineProperty(Person.prototype, 'getFullName', {
get: function() {
return firstName+ ' '+ lastName;
}
});

Object.defineProperty(Person.prototype, 'setFullName', {
set: function(name) {
firstName = name.split(' ')[0];
lastName = name.split(' ')1;
}
});

this.setFullName(firstAndLast);
};

var bob = new Person('Bob Ross');
bob.getLastName();
'''

CamperBot
@camperbot
Feb 25 2016 00:12 UTC
:bulb: to format code use backticks! ``` more info
John Espinoza
@johnlovespi
Feb 25 2016 00:12 UTC
so myPlants.tress[1] @dcnr ?
Norman Dela Cruz
@dcnr
Feb 25 2016 00:13 UTC
@johnlovespi no myPlants is an array of objects, it's an array that holds your object
Pavel Isp
@pavelisp
Feb 25 2016 00:13 UTC
yo, homeslices, anyone do the counting cards thing ? i just don't get how it should function
Orestis Gklavas
@oglavas
Feb 25 2016 00:14 UTC
var Person = function(firstAndLast) {
  var firstName = null;
  var lastName = null;

  Object.defineProperty(Person.prototype, 'getFirstName', {
    get: function() {
      return firstName;
    }
  });

  Object.defineProperty(Person.prototype, 'setFirstName', {
    set: function(name) {
      firstName = name;
    }
  });

  Object.defineProperty(Person.prototype, 'getLastName', {
    get: function() {
      return lastName;
    }
  });

  Object.defineProperty(Person.prototype, 'setLastName', {
    set: function(name) {
      lastName = name;
    }
  });

  Object.defineProperty(Person.prototype, 'getFullName', {
    get: function() {
      return firstName+ ' '+ lastName;
    }
  });

  Object.defineProperty(Person.prototype, 'setFullName', {
    set: function(name) {
      firstName = name.split(' ')[0];
      lastName = name.split(' ')[1];
    }
  });

   this.setFullName(firstAndLast);
};

var bob = new Person('Bob Ross');
bob.getLastName();
Nairuz.Abulhul
@nairuzabulhul
Feb 25 2016 00:14 UTC
@alpox thanks you are right . I just checked it with others :)
CamperBot
@camperbot
Feb 25 2016 00:14 UTC
zeemax sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
Orestis Gklavas
@oglavas
Feb 25 2016 00:15 UTC
Sorry about the previous paste! I can't understand why my setters/getters can't seem to work
alpox
@alpox
Feb 25 2016 00:16 UTC
@oglavas You define properties there. that means that are not functions, they are like variables. -> this.setFullName = firstAndLast
James Sangalli
@James-Sangalli
Feb 25 2016 00:16 UTC

Hi all, trying to figure out how to get the first letter of the array[i] to capitalize it then lower case the remainder, any ideas?

function titleCase(str) {
str.split(" ");
for (i = 0; i < str.length; i++){

}
return str;
}

titleCase("I'm a little tea pot");

John Espinoza
@johnlovespi
Feb 25 2016 00:17 UTC
@dcnr ok so if i need to grab an object from the list
James Sangalli
@James-Sangalli
Feb 25 2016 00:17 UTC
@khaduch after much trial and tribulation I got it to work, thanks dude
CamperBot
@camperbot
Feb 25 2016 00:17 UTC
james-sangalli sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 584 | @khaduch | http://www.freecodecamp.com/khaduch
John Espinoza
@johnlovespi
Feb 25 2016 00:18 UTC
can i just call the object and its proper
alpox
@alpox
Feb 25 2016 00:18 UTC
@James-Sangalli First lowercase the string, then loop over the strings and capitalize first letter. This should be enough for the start

@johnlovespi You have to get an object of an array with

var p = [ "foo", "bar"]
console.log(p[0]) // Prints "foo"

And access objects like:

var p = { 
  foo: "bar",
  some: "thing"
}
console.log(p.some) // Prints "thing"
Orestis Gklavas
@oglavas
Feb 25 2016 00:23 UTC
@alpox I'm not sure I get it. They are defined as functions, via Object.defineProperty()
John Espinoza
@johnlovespi
Feb 25 2016 00:23 UTC
@alpox i am acessing it var plants={
var secondTree = myPlants.trees1;
getting in to the array myPlants.trees and array 1
Richard Corbett
@reacorbett
Feb 25 2016 00:25 UTC
help js resources
alpox
@alpox
Feb 25 2016 00:26 UTC
@oglavas Object.defineProperty() defines a property on the given object. Not a function. That means, it creates something like a variable (named property) which on assignment (p.foo = something) calls the function you defined with the variable something. Abstract code:
function(input) {
  this.foo = yourDefinedFunction(input);
}
@johnlovespi myPlants is an array. It holds two objects. Each object has the defined fields "type", and "list".
Orestis Gklavas
@oglavas
Feb 25 2016 00:27 UTC
@alpox: In this page, under "Custom setters and getters", it seems that Mozilla are defining functions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
alpox
@alpox
Feb 25 2016 00:29 UTC
This message was deleted
Craig Banach
@CraigBanach
Feb 25 2016 00:30 UTC
help class
CamperBot
@camperbot
Feb 25 2016 00:30 UTC

:point_right: challenge create a class to target with jquery selectors [wiki]

Create a Class to Target with jQuery Selectors

Not every class needs to have corresponding CSS. Sometimes we create classes just for the purpose of selecting these elements more easily using jQuery.

For this we use the target class on the button elements.

:pencil: read more about challenge create a class to target with jquery selectors on the FCC Wiki

alpox
@alpox
Feb 25 2016 00:30 UTC

@oglavas It doesnt say it defines functions. It says it defines properties. You just define the getter and the setter of the property as a function.
If you look at how they access the defined property in the example you see:

arc.temperature; // 'get!'
arc.temperature = 11;
arc.temperature = 13;

Orestis Gklavas
@oglavas
Feb 25 2016 00:31 UTC
@alpox Yes, but the 'get!' is the result of the function being called (its console.log output).
alpox
@alpox
Feb 25 2016 00:32 UTC
@oglavas Of course it is :-) if accessing a property, your defined functions get called. But the syntax of accessing the property is not a function call syntax
L Yeh
@PhotoGeek1
Feb 25 2016 00:33 UTC

Confused. This waypoint should not be that hard.
"Make Unique Objects by Passing Parameters to our Constructor"

var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(4, 5, 1);

results should be:
Calling new Car(3,1,2) should produce an object with a wheels property of 3, a seats property of 1, and an engines property of 2.
Calling new Car(4,4,2) should produce an object with a wheels property of 4, a seats property of 4, and an engines property of 2.
Calling new Car(2,6,3) should produce an object with a wheels property of 2, a seats property of 6, and an engines property of 3.
myCar should have number values for the wheels, seats, and engines properties.

Mine failed all but the last one. I think I just lost 10 IQ points.

Orestis Gklavas
@oglavas
Feb 25 2016 00:33 UTC
@alpox, OK, I think I got what you're saying!!! I tried a simpler syntax and it seems to work, so I'll revisit it at a later time...now, how do I send these brownies? Let's see!
Caleb Martin
@caleb272
Feb 25 2016 00:34 UTC
what does this mean No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
Orestis Gklavas
@oglavas
Feb 25 2016 00:34 UTC
wiki brownie points
CamperBot
@camperbot
Feb 25 2016 00:34 UTC

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

Caleb Martin
@caleb272
Feb 25 2016 00:34 UTC
use thanks and his name using the at symbols @oglavas
CamperBot
@camperbot
Feb 25 2016 00:34 UTC
caleb272 sends brownie points to @oglavas :sparkles: :thumbsup: :sparkles:
alpox
@alpox
Feb 25 2016 00:34 UTC
@PhotoGeek1 You don't assign the function parameters to the this.<something> variables
CamperBot
@camperbot
Feb 25 2016 00:34 UTC
:star: 311 | @oglavas | http://www.freecodecamp.com/oglavas
Orestis Gklavas
@oglavas
Feb 25 2016 00:34 UTC
thanks @alpox
CamperBot
@camperbot
Feb 25 2016 00:34 UTC
oglavas sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
alpox
@alpox
Feb 25 2016 00:35 UTC
I cannot get these :D i'm not a freecodecamp member
Caleb Martin
@caleb272
Feb 25 2016 00:35 UTC
thats cool what made you want to jump on the chat and help
alpox
@alpox
Feb 25 2016 00:36 UTC
@caleb272 That means that the requested server is not allowed to unknown domains (this is caused by the header settings)
ratishidm
@ratishidm
Feb 25 2016 00:36 UTC

var Bike = function() {

// Only change code below this line.
var gear=0;
this.setGear = function(change){
gear=gear+4;
};

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

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(change);

Orestis Gklavas
@oglavas
Feb 25 2016 00:36 UTC
@alpox Oh, I see...
alpox
@alpox
Feb 25 2016 00:36 UTC
@caleb272 I just stumpled on that thing here today and found it quite cool :D and i like to help out
ratishidm
@ratishidm
Feb 25 2016 00:36 UTC
can some one tell me where is it going wrong
Craig Banach
@CraigBanach
Feb 25 2016 00:37 UTC

Hi guys, can anyone explain to me what the this. operator does. I tried using it for a challenge to set a private variable, but it didn't work. So can someone explain to me the differences of the two following lines of code?

var name = "hello";

this.name = namePassed;

name = namePassed;

Assume all code is inside their appropiate methods and classes.

Caleb Martin
@caleb272
Feb 25 2016 00:37 UTC
@alpox thats awesome could you help we with this error i have been working on it all day http://codepen.io/thecoder15/pen/grYOdW?editors=0010
Orestis Gklavas
@oglavas
Feb 25 2016 00:37 UTC
@ratishidm Your gear only seems to add 4 each time you try to shift
Caleb Martin
@caleb272
Feb 25 2016 00:38 UTC
the call to the wiki api is returning an error and google isn’t helping
alpox
@alpox
Feb 25 2016 00:38 UTC
@ratishidm in your function setGear you make no use of your parameter change.
In myBike.setGear(change) you use a variable change which is not defined anywhere. you have a var mica = new Car() without having defined an Object Car.
@caleb272 In the browsers own console there occurs exactly the error i showed you... google has some workarounds... wait i will take a look
L Yeh
@PhotoGeek1
Feb 25 2016 00:40 UTC
@alpox Not sure I understand. I copied the code in the example provided in the waypoint.
example provided:
var Car = function(wheels, seats, engines) {
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};
Craig Banach
@CraigBanach
Feb 25 2016 00:41 UTC
@PhotoGeek1 ok, so what error messages are you getting?
alpox
@alpox
Feb 25 2016 00:41 UTC
@PhotoGeek1 That looks good to me...
Caleb Martin
@caleb272
Feb 25 2016 00:41 UTC
same^
maybe its the way he is calling it?
paste all the code please
@alpox and i know it posts the error i can’t find any fix
alpox
@alpox
Feb 25 2016 00:42 UTC
@CraigBanach var name = "hello"; sets a local variable (only usable in current or inner scopes). this.name sets a variable name which sticks to the current object. name = namePassed creates a global variable (usable in all scopes)
@caleb272 I think i have the solution. wait a bit :-)
Caleb Martin
@caleb272
Feb 25 2016 00:43 UTC
k thanks @alpox
CamperBot
@camperbot
Feb 25 2016 00:43 UTC
caleb272 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
Caleb Martin
@caleb272
Feb 25 2016 00:43 UTC
dam haha
Eric
@Code-Eric
Feb 25 2016 00:44 UTC
hey guys think someone could help me out with something? Im stuck on escaping.
Caleb Martin
@caleb272
Feb 25 2016 00:44 UTC
code please ^
Eric
@Code-Eric
Feb 25 2016 00:44 UTC
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
L Yeh
@PhotoGeek1
Feb 25 2016 00:45 UTC

@CraigBanach
This is my code:

var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(4, 5, 1);

It still produces an object with 4 wheels, 1 seat and 1 engine, not 5 seats

Eric
@Code-Eric
Feb 25 2016 00:45 UTC
what i did was:var myStr=\ \t \t \r \n;
Caleb Martin
@caleb272
Feb 25 2016 00:45 UTC
@PhotoGeek1 what is wrong with it what doesn’t work
Craig Banach
@CraigBanach
Feb 25 2016 00:45 UTC
@PhotoGeek1 Well, that's what you are setting the variables to .... why wouldn't it?
Caleb Martin
@caleb272
Feb 25 2016 00:46 UTC
o you need to change the this.wheels = 4 to this.wheels = wheels
and so on with the other ones
Craig Banach
@CraigBanach
Feb 25 2016 00:46 UTC
@Code-Eric You need to set myStr to a string.
L Yeh
@PhotoGeek1
Feb 25 2016 00:46 UTC
Oh, duh. Ok
thanks @caleb272 @CraigBanach
CamperBot
@camperbot
Feb 25 2016 00:46 UTC
photogeek1 sends brownie points to @caleb272 and @craigbanach :sparkles: :thumbsup: :sparkles:
:star: 371 | @craigbanach | http://www.freecodecamp.com/craigbanach
:star: 284 | @caleb272 | http://www.freecodecamp.com/caleb272
Caleb Martin
@caleb272
Feb 25 2016 00:46 UTC
^ we all have that moment
Eric
@Code-Eric
Feb 25 2016 00:46 UTC
how do I set it to a string?
Caleb Martin
@caleb272
Feb 25 2016 00:46 UTC
var x = “”;
^^
Craig Banach
@CraigBanach
Feb 25 2016 00:47 UTC
@Code-Eric "enter string between quotes";
Caleb Martin
@caleb272
Feb 25 2016 00:47 UTC
‘“”’;
Eric
@Code-Eric
Feb 25 2016 00:47 UTC
Oh wow okay, thank you @CraigBanach
CamperBot
@camperbot
Feb 25 2016 00:47 UTC
code-eric sends brownie points to @craigbanach :sparkles: :thumbsup: :sparkles:
:star: 372 | @craigbanach | http://www.freecodecamp.com/craigbanach
ratishidm
@ratishidm
Feb 25 2016 00:48 UTC

@alpox var Bike = function() {

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

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

};

var myBike = new Bike();
myBike.setGear(change);
i still have the same problem
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Craig Banach
@CraigBanach
Feb 25 2016 00:49 UTC
@ratishidm ok, so where is the setGear function?
Caleb Martin
@caleb272
Feb 25 2016 00:49 UTC
use gear += change;
Craig Banach
@CraigBanach
Feb 25 2016 00:49 UTC
@caleb272 don't use that.
Caleb Martin
@caleb272
Feb 25 2016 00:49 UTC
why
Craig Banach
@CraigBanach
Feb 25 2016 00:50 UTC
@caleb272 gear = change;
ratishidm
@ratishidm
Feb 25 2016 00:50 UTC
this.setGear = function(change){
gear=change+gear;
};
Craig Banach
@CraigBanach
Feb 25 2016 00:50 UTC
@ratishidm ok, so when gear is 1 and you pass in 3, what will happen?
ratishidm
@ratishidm
Feb 25 2016 00:50 UTC
it should return 3
Craig Banach
@CraigBanach
Feb 25 2016 00:51 UTC
@ratishidm why, since when does 1+3 = 3?
ratishidm
@ratishidm
Feb 25 2016 00:51 UTC
I set gear to 0
ratishidm
@ratishidm
Feb 25 2016 00:51 UTC
and i am trying to add change to gear
Craig Banach
@CraigBanach
Feb 25 2016 00:51 UTC
@ratishidm so you call setGear(3) to make it 3, then you call setGear(1) which makes it 4.
alpox
@alpox
Feb 25 2016 00:52 UTC
@caleb272 It seems it returns the data which is in this case an object with error response from wiki :P
Craig Banach
@CraigBanach
Feb 25 2016 00:52 UTC
@ratishidm SO you need to rethink your setGear fucntion.
ratishidm
@ratishidm
Feb 25 2016 00:52 UTC
no when i call setGear(1) which makes 1
Craig Banach
@CraigBanach
Feb 25 2016 00:52 UTC
@ratishidm ok then, don't change your function.
Caleb Martin
@caleb272
Feb 25 2016 00:52 UTC
k thanks alpox
alpox
@alpox
Feb 25 2016 00:52 UTC
@caleb272 Does it work for you?
@caleb272 Oh wait it seems that i didnt create a proper link :-/ i dont know this tool...
Caleb Martin
@caleb272
Feb 25 2016 00:54 UTC
haha
ratishidm
@ratishidm
Feb 25 2016 00:54 UTC
@CraigBanach see what ever the change value is i am adding that to gear
Caleb Martin
@caleb272
Feb 25 2016 00:54 UTC
ya it wasn’t sending back anything its an error itself
Craig Banach
@CraigBanach
Feb 25 2016 00:54 UTC
@ratishidm and do you want it to do that?
ratishidm
@ratishidm
Feb 25 2016 00:54 UTC
Yes myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Caleb Martin
@caleb272
Feb 25 2016 00:54 UTC
?
alpo what link did you use
Craig Banach
@CraigBanach
Feb 25 2016 00:54 UTC
@ratishidm No, you don't want it to do that.
@ratishidm what if gear is 2?
and you add 3?
alpox
@alpox
Feb 25 2016 00:55 UTC
@caleb272 I dont know how to show you my working link
Caleb Martin
@caleb272
Feb 25 2016 00:55 UTC
why
you can paste code in here
‘’' <
or i mean ``` <
alpox
@alpox
Feb 25 2016 00:55 UTC
@caleb272 I wanted to put here the codepen thing xD
Craig Banach
@CraigBanach
Feb 25 2016 00:55 UTC
@alpox just link it, save it as your own then link.
Caleb Martin
@caleb272
Feb 25 2016 00:56 UTC
ya fork my project
alpox
@alpox
Feb 25 2016 00:56 UTC
I'm not logged in there... well i just put the code here
Caleb Martin
@caleb272
Feb 25 2016 00:56 UTC
k
alpox
@alpox
Feb 25 2016 00:56 UTC
function searchClicked() {
  var searchText = $("#search-bar").val();
  var searchQuary = baseurl + "?action=random" + "&format=json";
  console.log(searchQuary);
  $.ajax({
    url: searchQuary,
    type: 'GET',
    dataType: 'jsonp',
    error: function() { alert('Failed!'); },
  }).done(function(data) {
    console.log(data)
  })

}
Caleb Martin
@caleb272
Feb 25 2016 00:58 UTC
so i see you have to use ajax
which i don’t know how to use
alpox
@alpox
Feb 25 2016 00:58 UTC
@caleb272 The actual thing what made it work was setting the dataType of the request to 'jsonp'. A usual $.getJSON uses dataType "json"
Caleb Martin
@caleb272
Feb 25 2016 00:58 UTC
o ok thanks so much
alpox
@alpox
Feb 25 2016 00:59 UTC
@caleb272 Internal $.getJSON uses $.ajax too. There you can just make the full request setup.
You find the reference here: http://api.jquery.com/jquery.ajax/
Caleb Martin
@caleb272
Feb 25 2016 00:59 UTC
thanks i will read it over
Austin Thornley
@AustinThornley
Feb 25 2016 00:59 UTC
Can someone help me with Stand In Line? What am I doing wrong?
alpox
@alpox
Feb 25 2016 00:59 UTC
@caleb272 You're welcome. Have a good time :-)
Austin Thornley
@AustinThornley
Feb 25 2016 00:59 UTC
function queue(arr, item) {
  // Your code here
  testArr.push(item);
  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue([5,6,7,8,9], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
alpox
@alpox
Feb 25 2016 00:59 UTC
I'm going to bed now I have university early tomorrow... :D I'm sure i cannot get up ^^
Caleb Martin
@caleb272
Feb 25 2016 00:59 UTC
how many years have you been doing web dev alpox
alpox
@alpox
Feb 25 2016 01:00 UTC
@caleb272 Not just web... different kind of things. I'm programming for 7 years now and had an education in it, work and learn myself all time next to school and university and am now doing my bachelor of informatics
Caleb Martin
@caleb272
Feb 25 2016 01:01 UTC
nice i have been coding since 15 but just this past week started learning web dev
take care alpox
alpox
@alpox
Feb 25 2016 01:02 UTC
@caleb272 Nice to have you in row :D I was just from beginning a bit in web dev and i want to make a bigger project soon whats why i take a closer look. I'm currently interested in graphql requests (Apart from RESTful services), whats where i'm programming at the moment - https://github.com/alpox/graphql-go-gen my current project
Austin Thornley
@AustinThornley
Feb 25 2016 01:03 UTC
@alpox What can GO lang be used for? I'm not too familiar with it.
alpox
@alpox
Feb 25 2016 01:03 UTC
@caleb272 Well thats just a thin wrapper to make the syntax of schema creation better, but i think graphql will be soon a big part of web development
Caleb Martin
@caleb272
Feb 25 2016 01:03 UTC
ya i followed your git account i will checkin everyone and i while and read some code
@AustinThornley i have heard its backend similar to c++
Austin Thornley
@AustinThornley
Feb 25 2016 01:04 UTC
@caleb272 Oh cool. I'm currently learning C++ and will be taking a class next year with C++
Caleb Martin
@caleb272
Feb 25 2016 01:04 UTC
ya c++ is fun
by far one of my favorite languages
alpox
@alpox
Feb 25 2016 01:05 UTC
@AustinThornley Golang was created by google lately and should make low level programming easier. Its in the row of C and C++, has a garbage collector but stays fast and is made especially for fast compiling.
Recently it gets used a lot for web development for programmers which don't like NodeJS because of the javascript syntax, non-type checking and callback style.
See Farewell NodeJS
Davinw
@Davinw
Feb 25 2016 01:05 UTC
@AustinThornley : testArr.push(item); should just be arr.push(item);
Caleb Martin
@caleb272
Feb 25 2016 01:07 UTC
well I’m off for diner by guys take care
alpox
@alpox
Feb 25 2016 01:07 UTC
Yup me too, finally :D
Cya guys
Austin Thornley
@AustinThornley
Feb 25 2016 01:09 UTC
@Davinw Yeah, I finally got it :P
Davinw
@Davinw
Feb 25 2016 01:10 UTC
@AustinThornley Cool - those sort of "typed the wrong variable name" problems can be so frustrating, especially once your eyes start to go blurry from staring at text :)
ratishidm
@ratishidm
Feb 25 2016 01:15 UTC

@alpox Could you help me in this var Bike = function() {

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

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

this.getGear = function() {
return gear;
};
}; var myBike = new Bike();

myBike.setGear(4);
rphares
@rphares
Feb 25 2016 01:16 UTC
@ratishidm , your set get only needs to set it, =, not increase it in any way... :blush:
ratishidm
@ratishidm
Feb 25 2016 01:19 UTC
@rphares thanks it worked
CamperBot
@camperbot
Feb 25 2016 01:19 UTC
ratishidm sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2947 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 25 2016 01:20 UTC
anytime~
James Sangalli
@James-Sangalli
Feb 25 2016 01:57 UTC

hi all, cant see where I am going wrong on the return the largest number exercise:

function largestOfFour(arr) {
// You can do this!

var largest = 0
//return arr;
for(i = 0; i < arr.length; i ++){
if(arr[i] > largest){
largest = arr[i];
}
}
return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Norman Dela Cruz
@dcnr
Feb 25 2016 01:58 UTC
@James-Sangalli arr[i] is just your sub-array ([4,5,1,3] .. etc) you would need one more for loop to check their values
@James-Sangalli right now you're comparing the sub-array to largest: if ([4,5,1,3] > largest) { etc..
Andrew Schmidthuber
@calicode
Feb 25 2016 02:03 UTC
bonfire making a person
CamperBot
@camperbot
Feb 25 2016 02:03 UTC
Sorry, can't find a bonfire called making a person. [ Check the map? ]
Andrew Schmidthuber
@calicode
Feb 25 2016 02:04 UTC
bonfire make a person
CamperBot
@camperbot
Feb 25 2016 02:04 UTC

:fire:Bonfire: Make a Person :link:

var Person = function(firstAndLast) {
    return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();

Fill in the object constructor with the methods specified in the tests.

more info:  bf details | bf links | hint

Andrew Schmidthuber
@calicode
Feb 25 2016 02:04 UTC
having problems getting the first few test cases to pass, bob.firstname returning undefined and the object key length being 6. not sure how else to set firstname and lastname without calling setfullname which pushes the object key count over 6
var Person = function(firstAndLast) {




  this.setFirstName = (function(first) { this.firstName = first; });
  this.setLastName = (function(last) { this.lastName = last; });
  this.setFullName = (function(firstAndLast) { var splitMe = firstAndLast.split(" ");  this.firstName = splitMe[0]; this.lastName = splitMe[1]; });


  this.getFirstName = (function()  { return this.firstName;});
  this.getLastName = (function()  { return this.lastName;});
  this.getFullName = (function()  { return this.firstName.concat(" ", this.lastName);});

 this.setFullName(firstAndLast);
};



var bob = new Person('Bob Ross');

bob.getFullName();
Johannah
@eccentricafterglow
Feb 25 2016 02:13 UTC
Hey, anyone around to help?
Testing Objects for Properties — Does this one require an if statement?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {

  myObj.hasOwnProperty("gift"); //true
  myObj.hasOwnProperty("pet"); //true
  myObj.hasOwnProperty("house"); //false

}

// Test your code by modifying these values
checkObj("gift");
Andrew Schmidthuber
@calicode
Feb 25 2016 02:16 UTC
what is the expected output?
Johannah
@eccentricafterglow
Feb 25 2016 02:16 UTC
a boolean to check to see if a property has an object.
Andrew Schmidthuber
@calicode
Feb 25 2016 02:17 UTC
checkObj("house") should return "Not Found".
that looks like if statement material to me
if (!myObj.hasOwnProperty... return "Not Found", thats not complete code obviously
Johannah
@eccentricafterglow
Feb 25 2016 02:22 UTC
yeah, I’ll post what I have in a minute — finishing up.
I’m not quite sure of how to check for a something that does not have a property.
Reza Jafar
@Reza7865
Feb 25 2016 02:24 UTC

anyone know why i can’t use
var x = lastName.length - 1;

but Instead have to write it like this:
var x = lastName[lastName.length - 1];

Johannah
@eccentricafterglow
Feb 25 2016 02:24 UTC
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {

  if (myObj.hasOwnProperty("checkProp")) {
    return myObj[checkProp];
  } else (myObj.hasOwnProperty) {
    return "Not Found";
  }

}


// Test your code by modifying these values
checkObj("gift");
Richard Corbett
@reacorbett
Feb 25 2016 02:25 UTC
i guess codecademy doesn't teach zero inexing.
Examples:
  1. 100/10 evaluates to 10
  2. "Jane".length + 5 evaluates to 9
  3. 5*(3+1) evaluates to 20
Andrew Schmidthuber
@calicode
Feb 25 2016 02:25 UTC
@Reza7865 try x = (lastname.Length) - 1;
@eccentricafterglow take the quotes out of the if statement, you are checking for a variable
Norman Dela Cruz
@dcnr
Feb 25 2016 02:27 UTC
@eccentricafterglow by quoting "checkProp" you turned it into a string, when it should be a variable. So remove the quotes. You should also remove (myObj.hasOwnProperty) in your else
Davinw
@Davinw
Feb 25 2016 02:28 UTC
@Reza7865 to answer your "why" question, dot notation functions differently than bracket notation when accessing object properties.
Johannah
@eccentricafterglow
Feb 25 2016 02:28 UTC
Hrm, I’m still getting an error when I do that.
but it does pass.
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {

  if (myObj.hasOwnProperty(checkProp)) {
    return myObj[checkProp];
  } else (!(checkProp)); {
    return "Not Found";
  }

}


// Test your code by modifying these values
checkObj("gift");
At the line where it’s the else statement — It’s expecting an assignment or function call and instead saw an expression.
Reza Jafar
@Reza7865
Feb 25 2016 02:29 UTC
@Davinw ahh makes sense, thnxx
Norman Dela Cruz
@dcnr
Feb 25 2016 02:29 UTC
@eccentricafterglow you don't need a condition after an else
Johannah
@eccentricafterglow
Feb 25 2016 02:30 UTC
oh
Norman Dela Cruz
@dcnr
Feb 25 2016 02:30 UTC
@eccentricafterglow remove this (!(checkProp));
Johannah
@eccentricafterglow
Feb 25 2016 02:30 UTC
remove everyone?
er, everything?
okay.
Davinw
@Davinw
Feb 25 2016 02:30 UTC
@Reza7865 for lack of a better way to describe it, dot notation is "static" in how it works, which is why you can't use a variable name to access a property using dot notation. Whereas bracket notation is an "evaluatable" statement, if I can make up a word
Johannah
@eccentricafterglow
Feb 25 2016 02:30 UTC
thanks @calicode !!
CamperBot
@camperbot
Feb 25 2016 02:30 UTC
eccentricafterglow sends brownie points to @calicode :sparkles: :thumbsup: :sparkles:
Davinw
@Davinw
Feb 25 2016 02:30 UTC
@Reza7865 np!
Norman Dela Cruz
@dcnr
Feb 25 2016 02:30 UTC
@eccentricafterglow else is like "do this if any other if doesn't trigger"
CamperBot
@camperbot
Feb 25 2016 02:30 UTC
:star: 337 | @calicode | http://www.freecodecamp.com/calicode
Norman Dela Cruz
@dcnr
Feb 25 2016 02:30 UTC
@eccentricafterglow it's like the default in a switch
Johannah
@eccentricafterglow
Feb 25 2016 02:30 UTC
okay
Andrew Schmidthuber
@calicode
Feb 25 2016 02:31 UTC
else if might have been what you were thinking of
Johannah
@eccentricafterglow
Feb 25 2016 02:31 UTC
I’m still trying to figure out the differences between if, else, and else if.
Norman Dela Cruz
@dcnr
Feb 25 2016 02:31 UTC
@Reza7865
Here's a TLDR :P

Link to longer explanation


TLDR;

var myObj = {
  thePropertyName: "the Value";
};
  • Using . you are directly using the property name itself
    var result = myObj.thePropertyName; // the Value
  • Using [] there are two ways:
    1. Directly access by quoting the property name:
      var result = myObj["thePropertyName"]; // the Value
    2. Using a variable as property name by not quoting
      var prop = "thePropertyName";
      var result = myObj[prop]; // the Value
      here prop is the variable that holds the name of your object property
Andrew Schmidthuber
@calicode
Feb 25 2016 02:32 UTC
and in that case it would be else if (!myObj.hastOwnProperty(checkProp)) { return not found}
Reza Jafar
@Reza7865
Feb 25 2016 02:32 UTC
@Davinw ahhh thanks for clarifying, makes total sense
CamperBot
@camperbot
Feb 25 2016 02:32 UTC
reza7865 sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 211 | @davinw | http://www.freecodecamp.com/davinw
Davinw
@Davinw
Feb 25 2016 02:32 UTC
@Reza7865 Yw!
Norman Dela Cruz
@dcnr
Feb 25 2016 02:33 UTC
@eccentricafterglow
Something like this:
if (check this, and if true) {
  // do this
} else if (if the first IF is false, check this too, and if true) {
  // do this one instead
} else { 
  // if none of the if and else if passes, just do this  
}
Johannah
@eccentricafterglow
Feb 25 2016 02:33 UTC
oooh
I love these charts.
I should copy these.
PattyCreates
@PattyCreates
Feb 25 2016 02:34 UTC
Does anyone know if there's an SF room?
Johannah
@eccentricafterglow
Feb 25 2016 02:34 UTC
Thanks dcnr!
er Thanks @dcnr !
CamperBot
@camperbot
Feb 25 2016 02:34 UTC
eccentricafterglow sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 709 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 02:35 UTC
you're welcome, thanks too! @eccentricafterglow
CamperBot
@camperbot
Feb 25 2016 02:35 UTC
dcnr sends brownie points to @eccentricafterglow :sparkles: :thumbsup: :sparkles:
:star: 267 | @eccentricafterglow | http://www.freecodecamp.com/eccentricafterglow
Richard Corbett
@reacorbett
Feb 25 2016 02:35 UTC
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
},0);
I don't understand what is happening here.
Norman Dela Cruz
@dcnr
Feb 25 2016 02:41 UTC
@reacorbett reduce's previousVal is the first index of your array, but if an initial value is set
@reacorbett in this case the 0 part
@reacorbett it would be set to that
@reacorbett then after one "iteration" previousVal will be equivalent to your last return so in this case it would be previousVal + currentVal
L Yeh
@PhotoGeek1
Feb 25 2016 02:45 UTC
This message was deleted
Richard Corbett
@reacorbett
Feb 25 2016 02:46 UTC
so is currentVal the sum of the arrays indexes?
@dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 02:46 UTC

@reacorbett

[1, 2, 3, 4]

if initial value is not set:

First iteration:

previousVal = 1
currentVal = 2

return previousVal + currentVal; // 3

Second iteration:

previousVal = 3 // sum of last return
currentVal = 3

return previousVal + currentVal; // 6

Third iteration:

previousVal = 6 // sum of last return
currentVal = 4

return previousVal + currentVal; // 10

The entire array has been processed so

final value is 10

Richard Corbett
@reacorbett
Feb 25 2016 02:48 UTC
ok. @dcnr Thanks.
CamperBot
@camperbot
Feb 25 2016 02:48 UTC
reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 710 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 02:50 UTC
@reacorbett just think of it this way
  • if previousVal is not set, it's the first value of your array, and currentVal is the 2nd
  • if initial value is set, currentVal is the first value of your array instead
  • after your reduce function returns, previousVal would be the value of your last return, and currentVal is the next index
Richard Corbett
@reacorbett
Feb 25 2016 02:50 UTC
@dcnr If you ever want someone to feel really stupid, tell them to go learn javascript.
Norman Dela Cruz
@dcnr
Feb 25 2016 02:51 UTC
@reacorbett I'm sorry if I explained it in a terrible way
err I mean, I'm a terrible explainer
Richard Corbett
@reacorbett
Feb 25 2016 02:51 UTC
@dcnr No it was perfect.
@dcnr I understand .reduce now.
Norman Dela Cruz
@dcnr
Feb 25 2016 02:54 UTC
@reacorbett
You can do nifty stuffs with it, see if you can trace this :D
var myArr = [["COWS", 10], ["SHEEPS", 20], ["CHICKENS", 30]];

var newObj = myArr.reduce(function(obj, animals) {
  var animal = animals[0];
  var amount = animals[1];

  obj[animal] = amount;

  return obj;
}, {}); // initial value is an empty object

// newObj is equivalent to
{
  COWS: 10,
  SHEEPS: 20,
  CHICKENS: 30
}
Since I set an initial value which is {}, obj (aka our previousval) is now that {}, and animals will be the first index in our array which is ["COWS", 10] and so on!
Richard Corbett
@reacorbett
Feb 25 2016 02:57 UTC
@dcnr so, obj would be set to cows or ["COWS", 10]?
oh ok
}, {}); that sets the value of obj? @dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 02:59 UTC
@reacorbett yeah! :D
so it would be myArray.reduce(function, initialValue)
that's why {} is the initial value
oops forgot the .reduce
@reacorbett since I set an initial value, it would be assigned to the first argument of reduce, in this case I named it obj instead of previousVal
@reacorbett and since I set an initial value, currentVal (which I named animals) would be set to myArr[0]
Richard Corbett
@reacorbett
Feb 25 2016 03:03 UTC
animals[0]?
or myArr[0]
Vasily Sidorenko
@vsidoren
Feb 25 2016 03:04 UTC
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
},0);

singleVal = array;
any idea why this code would not be adding the values of array
Mudit Bhutani
@muditbhutani
Feb 25 2016 03:04 UTC
This message was deleted
Richard Corbett
@reacorbett
Feb 25 2016 03:05 UTC
@vsidoren look at singleVal = array; and ask yourself why is that there
Norman Dela Cruz
@dcnr
Feb 25 2016 03:06 UTC
@reacorbett I dunno if this helps, but a visualizatoin
William Sugandha
@williamsugandha
Feb 25 2016 03:06 UTC
hi all, i'm getting trouble understanding the instruction in "Exact Change" project
Vasily Sidorenko
@vsidoren
Feb 25 2016 03:07 UTC
@reacorbett is the assignment not passing the value of array after the reduce function has run ?
Richard Corbett
@reacorbett
Feb 25 2016 03:07 UTC
@dcnr thats awesome, yeah.
William Sugandha
@williamsugandha
Feb 25 2016 03:07 UTC
the instruction say "return change in coin and bills, sorted in highest to lowest order.", it is mean i can return something like 0.50??
Jesus Vega
@ParagonChuy
Feb 25 2016 03:07 UTC
Help Missing Letters
CamperBot
@camperbot
Feb 25 2016 03:07 UTC

:point_right: algorithm missing letters [wiki]

Problem Explanation:

  • You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
:pencil: read more about algorithm missing letters on the FCC Wiki
William Sugandha
@williamsugandha
Feb 25 2016 03:08 UTC
Help Exact Change
CamperBot
@camperbot
Feb 25 2016 03:08 UTC

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Vasily Sidorenko
@vsidoren
Feb 25 2016 03:09 UTC
got it ......
duh
thanks @reacorbett
CamperBot
@camperbot
Feb 25 2016 03:09 UTC
vsidoren sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 261 | @reacorbett | http://www.freecodecamp.com/reacorbett
Richard Corbett
@reacorbett
Feb 25 2016 03:10 UTC

@vsidoren

var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
},0);

that line of code already defines singleVal as a var and it makes it equal to array.reduce(function(previousVal, currentVal){
return previousVal + currentVal;

bitgrower
@bitgrower
Feb 25 2016 03:12 UTC
@reacorbett -- did you understand @dcnr 's example ... ? he's creating objects ... what he's doing can be super helpful for challenges like exact change ...
Vik
@vvang044
Feb 25 2016 03:12 UTC
hey guys has anyone completed "Make Object Properties Private" ?
bitgrower
@bitgrower
Feb 25 2016 03:13 UTC
he shows what the objects created are ...
Norman Dela Cruz
@dcnr
Feb 25 2016 03:13 UTC
@reacorbett here's another example visualization I think this one is easier to follow with the console.log
Jeremy
@JeremyAntonoff
Feb 25 2016 03:13 UTC
function findLongestWord(str) {
  var array = str.split(" ");
  var longestword = 0;

  for (i=0; i < array.length;i++) {
   // i know something array[i] > something else


  }


}

findLongestWord("The quick brown fox jumped over the lazy dog");
bitgrower
@bitgrower
Feb 25 2016 03:13 UTC
@vvang044 -- many times ... :)
Vik
@vvang044
Feb 25 2016 03:13 UTC
lol.....
Jeremy
@JeremyAntonoff
Feb 25 2016 03:13 UTC
can someone point me in the right direction without giving me the answer
Norman Dela Cruz
@dcnr
Feb 25 2016 03:13 UTC
hi @bitgrower ! :candy: :cake:
bitgrower
@bitgrower
Feb 25 2016 03:13 UTC
hello @dcnr ...
nice example, thanks for that @dcnr ..
CamperBot
@camperbot
Feb 25 2016 03:13 UTC
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
Norman Dela Cruz
@dcnr
Feb 25 2016 03:13 UTC
that ellipsis always gives off the feeling that you're unhappy :(
CamperBot
@camperbot
Feb 25 2016 03:13 UTC
:star: 711 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 03:14 UTC
thanks @bitgrower ...
CamperBot
@camperbot
Feb 25 2016 03:14 UTC
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 632 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower @bitgrower still basks in the glory of @dcnr's appreciation (and perf testing) of my smallest common denominator code ... :)
Vik
@vvang044
Feb 25 2016 03:15 UTC
im confused what to do with that exercise
Richard Corbett
@reacorbett
Feb 25 2016 03:15 UTC
@bitgrower I am understanding it a lot better.
bitgrower
@bitgrower
Feb 25 2016 03:15 UTC
@JToddFL -- if you are having trouble conceptualizing ... I would suggest figuring out what the steps are that you would need to take if you were to do it without code ...
do it with pencil & paper first ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 25 2016 03:15 UTC
Hey @bitgrower @dcnr Recall discussions about the smallest common multiple other day? I MADE my own Algorithm! WHOO! Should I post it here?
Jeremy
@JeremyAntonoff
Feb 25 2016 03:15 UTC
@bitgrower well i seperated it into an array and i know i need to find the largest item of that array
dcnr @dcnr bows and is humbled and speechless
bitgrower
@bitgrower
Feb 25 2016 03:16 UTC
@JToddFL -- there are tons of different ways of doing that @JToddFL -- what tools do you have available
Norman Dela Cruz
@dcnr
Feb 25 2016 03:16 UTC
@pkshreeman that's an achievement worthy of celebration :D :D
bitgrower
@bitgrower
Feb 25 2016 03:17 UTC
@pkshreeman -- I kinda discourage posting solutions here ... maybe paste them into a jsbin or repl.it -- and paste the url in ...
Jeremy
@JeremyAntonoff
Feb 25 2016 03:17 UTC
@bitgrower I was going to do a loop to cycle through each item just dunno where to go from there.
Norman Dela Cruz
@dcnr
Feb 25 2016 03:17 UTC
@pkshreeman @bitgrower or pm us!
eeflores @eeflores waits anxiously for LCM code ...
dcnr @eeflores looks shiftily around
bitgrower
@bitgrower
Feb 25 2016 03:19 UTC
and I agree with @dcnr ... CONGRATS !!!
@caleb272 -- this part of that URL makes me nervous ... feature=em-uploademail
L Yeh
@PhotoGeek1
Feb 25 2016 03:23 UTC

Definition clarification in Condense Arrays with Reduce

Definition:
To use reduce you pass in a callback whose arguments are an accumulator (in this case, previousVal) and the current value (currentVal).

var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal - currentVal;
}, 0);

What does accumulator mean? Why are previousVal and currentVal not called parameters?

Caleb Martin
@caleb272
Feb 25 2016 03:23 UTC
o that is because it was a link emailed to me it will take you to the video
Richard Corbett
@reacorbett
Feb 25 2016 03:24 UTC

@dcnr so, you assigned previousVal to "the". and prints to console.

currentVal is assigned the first index of the array. and prints to console

previousVal then is assigned the second index of the array. prints...

the currentVal is = 3rd index , and prints

and all is complete. the new value of new_sentence is assigned, and the last console.log prints.

Is that about it?

@dcnr sorry if that is hard to understand
Vik
@vvang044
Feb 25 2016 03:28 UTC
can anyone look at my code and tell what's wrong with it?
Ryan Price
@rsprice
Feb 25 2016 03:28 UTC
@vvang044 sure thing!
Vik
@vvang044
Feb 25 2016 03:29 UTC
var Bike = function() {

  // Only change code below this line.

  var gear =0;

  this.setGear = function(change){

    gear += change;
  };

  this.getGear = function(){
    return gear;
  };
};
var myCar = new Car();
var myBike = new Bike();
Caleb Martin
@caleb272
Feb 25 2016 03:30 UTC
whats wrong
dang there are a lot of people having a problem with this tutorial
Ryan Price
@rsprice
Feb 25 2016 03:31 UTC
@vvang044 what's the error you are getting? Also, I don't see any code for the Car constructor
Vik
@vvang044
Feb 25 2016 03:31 UTC
raises his hang
sorry let me paste the whole code
Moisés Man
@moigithub
Feb 25 2016 03:32 UTC
@vvang044 no sum on setgear.. just set a value
Vik
@vvang044
Feb 25 2016 03:33 UTC
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(change){

    gear += change;
  };

this.getGear = function(){
    return gear;   
  };
};
var myCar = new Car();

var myBike = new Bike();
Ryan Price
@rsprice
Feb 25 2016 03:33 UTC
@vvang044 what is this exercise called on the map?
Vik
@vvang044
Feb 25 2016 03:34 UTC
"Make Object Properties Private"
Jesus Vega
@ParagonChuy
Feb 25 2016 03:34 UTC
Has anybody done the Missing Letters Intermediate Algorithm?
Vik
@vvang044
Feb 25 2016 03:35 UTC
@moigithub sorry i missed what you said
Ryan Price
@rsprice
Feb 25 2016 03:37 UTC
@vvang044
Vik
@vvang044
Feb 25 2016 03:37 UTC
yes?
Ryan Price
@rsprice
Feb 25 2016 03:37 UTC
var Bike = function() {

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

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

  this.setGear = function(change) {
    gear = change;
  };
};
Moisés Man
@moigithub
Feb 25 2016 03:37 UTC
 this.setGear = function(change){

    gear += change;
remove + sign
Ryan Price
@rsprice
Feb 25 2016 03:37 UTC
This code worked for me
You don't have to set an initial value for gear, and you are updating the private variable gear for each call to setGear
Josh Fisk
@JoshFisk
Feb 25 2016 03:39 UTC
@ParagonChuy What about it?
Vik
@vvang044
Feb 25 2016 03:39 UTC
it did say at the end but thats where i got confused
awesome thank you.... guys
@rsprice @moigithub thank you
CamperBot
@camperbot
Feb 25 2016 03:40 UTC
vvang044 sends brownie points to @rsprice and @moigithub :sparkles: :thumbsup: :sparkles:
:star: 355 | @rsprice | http://www.freecodecamp.com/rsprice
:star: 665 | @moigithub | http://www.freecodecamp.com/moigithub
Vik
@vvang044
Feb 25 2016 03:40 UTC
happy coding
Ryan Price
@rsprice
Feb 25 2016 03:40 UTC
@vvang044 best of luck, feel free to ping me if you have any more questions
Jesus Vega
@ParagonChuy
Feb 25 2016 03:40 UTC
@JoshFisk Am I supposed to use modulo division or am I over complicating it?
Josh Fisk
@JoshFisk
Feb 25 2016 03:41 UTC
@ParagonChuy Overcomplicating it
Jesus Vega
@ParagonChuy
Feb 25 2016 03:41 UTC
Dang it
Josh Fisk
@JoshFisk
Feb 25 2016 03:41 UTC
@ParagonChuy Don't need modulo devision to see if the char code is 1 higher do you? : )
Jesus Vega
@ParagonChuy
Feb 25 2016 03:42 UTC
What do you mean?
Josh Fisk
@JoshFisk
Feb 25 2016 03:42 UTC
@ParagonChuy You are talking about this one right? "Missing letters"
Norman Dela Cruz
@dcnr
Feb 25 2016 03:43 UTC
@reacorbett almost! you got the first 2 right, but after that previousVal is assigned the "return value" which is the concatenated "the" and currentVal". And currentVal is now the SECOND index :D
read the console.logs step by step :D
Jesus Vega
@ParagonChuy
Feb 25 2016 03:43 UTC
Yes
The way I'm thinking both the numbers before and after a given number are both the same: i.e both even or both odd , therefore me wanting to use modulo
Josh Fisk
@JoshFisk
Feb 25 2016 03:45 UTC
@ParagonChuy Okay lets double check the problem, because you are confusing me
Richard Corbett
@reacorbett
Feb 25 2016 03:45 UTC
@dcnr got it.
Andres Baltodano
@Andy-colocho
Feb 25 2016 03:45 UTC
hi guys
Jesus Vega
@ParagonChuy
Feb 25 2016 03:45 UTC
Okay
Josh Fisk
@JoshFisk
Feb 25 2016 03:45 UTC
@ParagonChuy If I give you a string like this, a b c d f
Jesus Vega
@ParagonChuy
Feb 25 2016 03:46 UTC
yes
Josh Fisk
@JoshFisk
Feb 25 2016 03:46 UTC
@ParagonChuy I skipped e in the alphabet
@ParagonChuy Your program would return e
The char code difference between d, and f is 2
Because e is missing
Jesus Vega
@ParagonChuy
Feb 25 2016 03:47 UTC
Okay if you use modulo on the character code of D and F you would have to get the same number.
cramjet
@cramjet
Feb 25 2016 03:47 UTC
i had been moving through the basic algorithm scripting til i got to the third-last one (seek and destroy) and my head is dizzy trying to solve it. the hint is to use the arguments object and Array.filter(). here's what i have, but obviously i'm grasping wildly at straws here...
function destroyer(arr) {

  function axe(nextNeck) {
  for (i = 0; i < arguments.length; i++) {
        arguments.indexOf(nextNeck) > 0; 
         }
  }
  return arr.filter(nextNeck);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Josh Fisk
@JoshFisk
Feb 25 2016 03:47 UTC
@ParagonChuy You don't have to do anything fancy, you can just check when the char code does not increase by 1
cramjet
@cramjet
Feb 25 2016 03:48 UTC
if i could get some help as to just the proper approach to it, i'd appreciate that
Jesus Vega
@ParagonChuy
Feb 25 2016 03:48 UTC
Oh I see what you mean now
I'm great at overcomplicating things
No wonder I'm jobless xD
cramjet
@cramjet
Feb 25 2016 03:49 UTC
link to the problem page: seek and destroy
Marc
@wumpafruits
Feb 25 2016 03:52 UTC
stuck on Make Object Properties Private
feeling like i'm swimming in deep waters the last 9-10 waypoints
maybe I'll just repeat JS again
Ryan Price
@rsprice
Feb 25 2016 03:54 UTC
@wumpafruits that one is a little confusing
Jesus Vega
@ParagonChuy
Feb 25 2016 03:54 UTC
@JoshFisk Still lost haha
Ryan Price
@rsprice
Feb 25 2016 03:55 UTC
@wumpafruits it's important to grasp the concept that's being presented in order to get the most out of the exercise, do you feel like you have a good understanding of what is going on?
Richard Corbett
@reacorbett
Feb 25 2016 03:55 UTC
var array = [1, 12, 21, 2];
array.sort(function(a, b) {
  return a - b;
});
so, a,b are the compare function. but, why is return written as a -b ?
Ryan Price
@rsprice
Feb 25 2016 03:55 UTC
@cramjet I can pair program with you if you'd like
Josh Fisk
@JoshFisk
Feb 25 2016 03:56 UTC
@ParagonChuy get the first letter, add 1 to the char code, see if it's the same as the next one, repeat until it does not match, then return the letter you find, return undefined if you run out of letters
DJ
@qualitymanifest
Feb 25 2016 03:56 UTC
@cramjet so. you can't use arguments like a normal array, but you'll want to. the first part of arguments is arr (in this case [1, 2, 3, 1, 2, 3]. is this making sense so far?
Marc
@wumpafruits
Feb 25 2016 03:57 UTC
might justcome back to it tomorrow @rsprice but i'll have to maybe read up on some other examples of this sort
Ryan Price
@rsprice
Feb 25 2016 03:58 UTC
@wumpafruits ok, well, it would be pretty quick :), but that's ok. Sometimes a break is all you need!
@wumpafruits also, a solid understanding of how filter works will get you pretty far with this particular exercise
Marc
@wumpafruits
Feb 25 2016 03:59 UTC
^^ I'll look into it @rsprice thankyou
cramjet
@cramjet
Feb 25 2016 04:00 UTC
whoops sorry i didn't get an audio notification of a response!
Austin Thornley
@AustinThornley
Feb 25 2016 04:00 UTC
I don't really need help with this, just wondering if I need a break; after the answer = "delta"
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      answer = "alpha";
      break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
  }


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

// Change this value to test
myTest(1);
philipsiu
@philipsiu
Feb 25 2016 04:00 UTC
help Where do I belong
CamperBot
@camperbot
Feb 25 2016 04:00 UTC

:point_right: algorithm where do i belong [wiki]

Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

:pencil: read more about algorithm where do i belong on the FCC Wiki

cramjet
@cramjet
Feb 25 2016 04:00 UTC
@rsprice not sure how to pair
Ryan Price
@rsprice
Feb 25 2016 04:01 UTC
@wumpafruits well, to nudge you in the right direction, I'll just say that the point of the exercise is all about private variable, getters and setters. The point is that you can modify a private variable by using methods as opposed to just mutating an object's property directly. Once you kind of wrap you head around that it's probably a lot easier to complete
cramjet
@cramjet
Feb 25 2016 04:01 UTC
@qualitymanifest yes, in fact i was using arr originally then tried to go to arguments
Austin Thornley
@AustinThornley
Feb 25 2016 04:01 UTC
I want to add to that; the code works with the break and without the break. Just wondering if I need it
Ryan Price
@rsprice
Feb 25 2016 04:01 UTC
@cramjet we can use google h/o or something if you'd like. I don't bite I promise. Nor am I a Nigerian prince trying to scam you in some way.
:)
cramjet
@cramjet
Feb 25 2016 04:02 UTC
@qualitymanifest know whut, i'll go step by step. i follow what you mean
Norman Dela Cruz
@dcnr
Feb 25 2016 04:02 UTC
@AustinThornley it wouldn't matter since it's the end of your switch statement anyway :P unless there's some more code inside
DJ
@qualitymanifest
Feb 25 2016 04:02 UTC
okay so, since you already have arr, you only need to be able to use the parts of arguments after the first part (index 0). so, make a for loop starting at 1, and push the rest of the arguments into an array that you can use
cramjet
@cramjet
Feb 25 2016 04:02 UTC
lol @rsprice
Austin Thornley
@AustinThornley
Feb 25 2016 04:02 UTC
@dcnr Okay, thank you!
CamperBot
@camperbot
Feb 25 2016 04:02 UTC
austinthornley sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 712 | @dcnr | http://www.freecodecamp.com/dcnr
cramjet
@cramjet
Feb 25 2016 04:03 UTC
oh ok @qualitymanifest i'll try that. that does make immediate sense.
DJ
@qualitymanifest
Feb 25 2016 04:03 UTC
@cramjet cool. there's more to it, but it's a good start
Ryan Price
@rsprice
Feb 25 2016 04:03 UTC
I agree. That's a good place to start!
Norman Dela Cruz
@dcnr
Feb 25 2016 04:05 UTC
@AustinThornley but it's good practice to always break, and always have a default case for your switch
Adi
@kiniadit
Feb 25 2016 04:06 UTC

```function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor

return (str.substring(-target.length,target.length) === target);
}

end("Bastian", "n");```

Richard Corbett
@reacorbett
Feb 25 2016 04:06 UTC

@dcnr

var array = [1, 12, 21, 2];
array.sort(function(a, b) {
  return a - b;
});

Why is it return a - b ? i beleive i understand why the compare functions are a and b, but i dont uderstand the return statement.

Adi
@kiniadit
Feb 25 2016 04:07 UTC
why doesn't the above code work?
Norman Dela Cruz
@dcnr
Feb 25 2016 04:08 UTC
@reacorbett It's the rules of sort
  • If compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
  • If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
  • If compareFunction(a, b) is greater than 0, sort b to a lower index than a.
  • compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.
@reacorbett if you're sorting numbers a - b would be ascending, and b - a would be descending
cramjet
@cramjet
Feb 25 2016 04:09 UTC

@rsprice and @qualitymanifest ok, so i tried this:

function destroyer(arr) {

  var thePen = [];
  for (i=1; i <= arr.length-1; i++) {
    if (arr[0].indexOf(i) == -1) {
      thePen.push(arr[i]);
    }
    return thePen;
  }
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

...but it doesn't work. arr[0].indexOf(i) is not allowed :/

DJ
@qualitymanifest
Feb 25 2016 04:10 UTC
@cramjet you're getting a little ahead of yourself. this far, don't do anything other than putting the rest of arguments into an array
Adi
@kiniadit
Feb 25 2016 04:10 UTC
var code
cramjet
@cramjet
Feb 25 2016 04:12 UTC
@qualitymanifest ok, sorry about that. do i have to put the split the first array into it's own array (if that makes sense)
Ryan Price
@rsprice
Feb 25 2016 04:12 UTC
I see people mess this up all the time, and for good reason: it's fairly tricky.
Adi
@kiniadit
Feb 25 2016 04:12 UTC
function end(str, target) { // "Never give up and good luck will find you." // -- Falcor return (str.substring(-target.length,target.length) === target); } end("Bastian", "n"); I'm getting a false when I'm expecting a true. Any ideas why? I tried this on the console and it worke fine. What am I missing?
Ryan Price
@rsprice
Feb 25 2016 04:12 UTC
@cramjet that sounds like a good idea
;)
cramjet
@cramjet
Feb 25 2016 04:13 UTC
@rsprice i swear i did something like this a couple hours ago... ok lemme see if i can backtrack...
Adi
@kiniadit
Feb 25 2016 04:13 UTC
and how does one get those formatted code snippets with the black background on chat?
DJ
@qualitymanifest
Feb 25 2016 04:13 UTC
@cramjet say you had an array like ["a", "b", 1, 2, 3, 4] and you wanted to just put 2, 3, 4 into a new array. you could loop over the array starting at index 3, and push the remaining parts into an array. that's what you want to do, but with the arguments object, and an index of 1
Adi
@kiniadit
Feb 25 2016 04:16 UTC
anyone?
Ryan Price
@rsprice
Feb 25 2016 04:16 UTC
!format
DJ
@qualitymanifest
Feb 25 2016 04:17 UTC
help format
CamperBot
@camperbot
Feb 25 2016 04:17 UTC

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```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 ⏎]

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

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

Ryan Price
@rsprice
Feb 25 2016 04:17 UTC
Ah, much better
@kiniadit ^^^^^
Adi
@kiniadit
Feb 25 2016 04:17 UTC
function end(str, target) {
  return (str.substring(-target.length,target.length) === target);
}

end("Bastian", "n");
cramjet
@cramjet
Feb 25 2016 04:17 UTC
@qualitymanifest not quiiite sure i'm following. would this not do to separate out the first element (the 'source' array)?
Adi
@kiniadit
Feb 25 2016 04:17 UTC
thank you!
cramjet
@cramjet
Feb 25 2016 04:18 UTC
sorry, var thePen = arr[0];
Adi
@kiniadit
Feb 25 2016 04:18 UTC
@rspice any ideas why i'm getting false returned? i'm expecting a true
DJ
@qualitymanifest
Feb 25 2016 04:18 UTC
@cramjet come on over here https://kobra.io/#/e/-KBL_Ab9hbVDccoDCycL
Ryan Price
@rsprice
Feb 25 2016 04:21 UTC
@kiniadit can you walk me through what you're trying to do with that piece of code? Sometimes that helps
Adi
@kiniadit
Feb 25 2016 04:22 UTC
well, its essentially this challenge http://www.freecodecamp.com/challenges/confirm-the-ending
check if 'target' matches the end of 'str'
Ryan Price
@rsprice
Feb 25 2016 04:23 UTC
right
So walk me through what your code is doing
You are really close btw :)
although I'm sure you know that and it's driving you slightly mad at this point... if you're anything like me anyway
@kiniadit I think the arguments you are passing to substring is causing your problem btw
Well, actually I know they are ;)
Adi
@kiniadit
Feb 25 2016 04:25 UTC
so my code is picking out a substring from the string str using the substr function. the first parameter of the substr function is the start location and if its negative the substr functions tarts from the end and counts backward. i chose 'target' length. so it goes back by the length of the target string. the second parameter then counts forward and then returns the string of that length.
@rsprice that's the crude walkthrough
George Phalen
@gphalen
Feb 25 2016 04:26 UTC
My #230 is returning "No such contact" and "No such property," but none of the others, and I can't figure out why.

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

              if(!contacts[i].hasOwnProperty(prop)) {
            return "No such property";
              }

        if(contacts[i].hasOwnProperty(firstName) && prop==="lastName"){
          return contacts[i].lastName;
        }

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

              }

}'

Adi
@kiniadit
Feb 25 2016 04:26 UTC
@rspice going nuts
@rspice hmm so the arguments are messed up?
Ryan Price
@rsprice
Feb 25 2016 04:27 UTC
@kiniadit do this
str = 'Bastian';
str.substring(-str.length, str.length);
Adi
@kiniadit
Feb 25 2016 04:27 UTC
@rsprice but when i try the following in the console it works perfectly
"Bastian".substr(-"n".length,"n".length) === "n";
true
Ryan Price
@rsprice
Feb 25 2016 04:29 UTC
@kiniadit omg that is hilarious
Adi
@kiniadit
Feb 25 2016 04:29 UTC
@rsprice i know right
Ryan Price
@rsprice
Feb 25 2016 04:29 UTC
I know why it works
I think anyway
V Arun Kumar
@arunvkumr
Feb 25 2016 04:29 UTC
i'm trying navbar-collpase but it's not working. any help?
sudheerswamy
@sudheerswamy
Feb 25 2016 04:29 UTC

```Create a function timesFive that accepts one argument, multiplies it by 5, and returns the new value.

Run tests (ctrl + enter)

Andrew Dutton
@andrew-dutton
Feb 25 2016 04:29 UTC
Hey all... so I just spent the last several hours on the "Title Case a Sentence" and I am happy to say I finally got it to work!! My question is, now that I have completed it is there anywhere to check what the "best" solution would be or at least other solutions?? I don't necessarily want to post it here as it would be a kind of spoiler to others working on it... I am sure that although my code works, it could probably be done better and would like to compare... is there somewhere to do this? Thanks guys.
Norman Dela Cruz
@dcnr
Feb 25 2016 04:30 UTC
thanks @reacorbett
CamperBot
@camperbot
Feb 25 2016 04:30 UTC
dcnr sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 265 | @reacorbett | http://www.freecodecamp.com/reacorbett
Ryan Price
@rsprice
Feb 25 2016 04:30 UTC
the first argument is an expression that is going to eval right to left, so literally the interpreter is going to look at your first argument and say "get me the length of n, then turn it into a negative number"
Norman Dela Cruz
@dcnr
Feb 25 2016 04:30 UTC
@AndreWaroux have you checked the wiki solution? You can also look at other people's profile and view their solutions
Ryan Price
@rsprice
Feb 25 2016 04:30 UTC
@kiniadit so your first argument to substr ends up being -1 which should be the last character of your string
sudheerswamy
@sudheerswamy
Feb 25 2016 04:31 UTC
// Example
function minusSeven(num) {
  return num - 7;
}

// Only change code below this line
function timesFive(num){
  return 5*5;
}

function timesFive2(num){
  return 5*2;
}

function timesFive0(){
  return 0*5;
}
Andrew Dutton
@andrew-dutton
Feb 25 2016 04:31 UTC
@dcnr no, I haven't... haven't seen the wiki solutions!
Adi
@kiniadit
Feb 25 2016 04:31 UTC
@rspice hmm, weird. ok.
sudheerswamy
@sudheerswamy
Feb 25 2016 04:32 UTC
console returns 0*5 only;
Ryan Price
@rsprice
Feb 25 2016 04:32 UTC
@kiniadit the second argument will return 1 which means you'll get one character after the last character... and there aren't any, so you'll just end up getting the last character
Norman Dela Cruz
@dcnr
Feb 25 2016 04:32 UTC
@AndreWaroux you can always start there! then look at other people's profile! http://www.freecodecamp.com/<usernamehere>
Andrew Dutton
@andrew-dutton
Feb 25 2016 04:32 UTC
@dcnr Thanks! Looking at the wiki now (for the first time!)
CamperBot
@camperbot
Feb 25 2016 04:32 UTC
andrewaroux sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 713 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 04:32 UTC
@AndreWaroux for example I always look at http://www.freecodecamp.com/bitgrower 's solutions
coz she's awesome
and well documented
Andrew Dutton
@andrew-dutton
Feb 25 2016 04:32 UTC
awesome cheers!
Adi
@kiniadit
Feb 25 2016 04:32 UTC
@rsprice so it was just a 'false positive' of sorts. thats nuts....
Ryan Price
@rsprice
Feb 25 2016 04:33 UTC
@kiniadit str.substr(str.length - 1); is how I went about it
function end(str, target) {
  return str.substr(str.length - 1) === target);
}
Jeremy
@JeremyAntonoff
Feb 25 2016 04:35 UTC
function findLongestWord(str) {
  var array = str.split(" ");
  var longestword = 0;
  var total = 0;

  for (i=0; i < array.length;i++) {
   // i know something array[i] > something else



  }
}

findLongestWord("The quick brown fox jumped over the lazy dog");
can anyone help with that
Ryan Price
@rsprice
Feb 25 2016 04:35 UTC
you can just give one argument, which tells your function take the length of my string subtract one and extract from that index
Adi
@kiniadit
Feb 25 2016 04:35 UTC
@rspice, i'll try that out. thanks!
CamperBot
@camperbot
Feb 25 2016 04:35 UTC
kiniadit sends brownie points to @rspice :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for rspice
Ryan Price
@rsprice
Feb 25 2016 04:35 UTC
@kiniadit no problem
@JToddFL what's up?
Jeremy
@JeremyAntonoff
Feb 25 2016 04:36 UTC
I just dunno where to go from here
ive sat and pondered forever lol
bitgrower
@bitgrower
Feb 25 2016 04:36 UTC

@AndreWaroux for example I always look at http://www.freecodecamp.com/bitgrower 's solutions

Now you're going to embarrass me ... some of my solutions are an unmitigated mess and badly need to be cleaned up ... but there are a couple of gems in there ... SCM is one ... seek & destroy, perhaps -- but the last time I looked at my comments, I still felt they could be way better ...

...and then there's my laziness in not using regexes ...

Jeremy
@JeremyAntonoff
Feb 25 2016 04:36 UTC
i think i have it right up until now. im trying to find the longest word in that string
Ryan Price
@rsprice
Feb 25 2016 04:37 UTC
@JToddFL that all seems reasonable
Jeremy
@JeremyAntonoff
Feb 25 2016 04:37 UTC
im just stuck now
Ryan Price
@rsprice
Feb 25 2016 04:37 UTC
@JToddFL when I get to this point, I write out in pseudocode all the logic I want my loop to execute
@JToddFL do you know what pseudocode is?
Jeremy
@JeremyAntonoff
Feb 25 2016 04:37 UTC
no
lol
Norman Dela Cruz
@dcnr
Feb 25 2016 04:37 UTC
@bitgrower eh there's always something to learn about, if you look for it!
bitgrower
@bitgrower
Feb 25 2016 04:37 UTC
so @JToddFL -- you have ...
  1. a set number of words
  2. each has a length
  3. you have to figure out which is longer than the others ...
Ryan Price
@rsprice
Feb 25 2016 04:38 UTC
//iterate over the words in the array
  // at each word, compare it to the longest word
  // ...?
  // profit
Jeremy
@JeremyAntonoff
Feb 25 2016 04:38 UTC
whenever i set a variable to array[i] though i can only get it to loop
bitgrower
@bitgrower
Feb 25 2016 04:38 UTC
how can you split the long string you have into words ?
Jeremy
@JeremyAntonoff
Feb 25 2016 04:38 UTC
to the first word "The"
and never go on
Ryan Price
@rsprice
Feb 25 2016 04:38 UTC
@JToddFL you write out in plain english what your function should be doing. That way your logic is sound even before you start coding
bitgrower
@bitgrower
Feb 25 2016 04:38 UTC
@JToddFL -- then you are probably addressing it incorrectly ...
Jeremy
@JeremyAntonoff
Feb 25 2016 04:39 UTC
@bitgrower didnt i do that with splitting it into an array?
@rspice i did that on paper i just dont know how to do it with the loop i need
bitgrower
@bitgrower
Feb 25 2016 04:39 UTC

I'm just going by the symptom, @JToddFL -- not by looking at the code ...

...this is called "sanity checking" ... because our eyes can fool us!

so ... you take the evidence (it doesn't go beyond the word The) ... and say, hmmm what would cause that ?
Ryan Price
@rsprice
Feb 25 2016 04:40 UTC
sounds like "The" is the longest word :)
Jeremy
@JeremyAntonoff
Feb 25 2016 04:41 UTC
do i need another for loop nested?
Andrew Dutton
@andrew-dutton
Feb 25 2016 04:41 UTC
@bitgrower well I just saw your solution to the Title Case problem and almost cried! lol... mine is so much longer and convoluted!!
Ryan Price
@rsprice
Feb 25 2016 04:42 UTC
@JToddFL no way Jose
@AndreWaroux did you use a functional approach? :)
Jeremy
@JeremyAntonoff
Feb 25 2016 04:43 UTC
so i would prob write out an if statement saying if (index[i] > (i dunno what to put here)
bitgrower
@bitgrower
Feb 25 2016 04:43 UTC

LOL ... I think there are 3 solutions in there (2 are commented out) ... the first time I created a mini-state machine ...

...I steal profligately ...but I do try to understand what I've stolen, with the goal that I could replicate it if I were faced with the problem again ...

...so ... you too, can steal proligately and learn and have cool solutions ... :)
Ryan Price
@rsprice
Feb 25 2016 04:44 UTC
@bitgrower can I see your solution??
bitgrower
@bitgrower
Feb 25 2016 04:44 UTC
...just make sure you understand the code ... :)
Andrew Dutton
@andrew-dutton
Feb 25 2016 04:44 UTC
@bitgrower I could see you first few solutions... but you final one is beautiful ;)
bitgrower
@bitgrower
Feb 25 2016 04:45 UTC
@rsprice ... most people's code can be seen by going to freecodecamp.com/<camper's name>
Ryan Price
@rsprice
Feb 25 2016 04:45 UTC
// iterate over each word in the string
  // if the current word is longer than the longest word
    // set the current word to be the longest word
@JToddFL ^
Something like this might work
Jeremy
@JeremyAntonoff
Feb 25 2016 04:45 UTC
and i do that with index[i]
?
bitgrower
@bitgrower
Feb 25 2016 04:46 UTC
and ... @AndreWaroux -- that last solution is one I can't take credit for ... i stole it ... :) ... i didn't know you could do that with replace ...
Andrew Dutton
@andrew-dutton
Feb 25 2016 04:46 UTC
@bitgrower this term "mini state machine"... i haven't heard it before, but I am assuming it's what I've done... a hundred steps to get to the solutions...
Norman Dela Cruz
@dcnr
Feb 25 2016 04:46 UTC
@JToddFL
yeah something like
LARGEST=0

for WORD in [#WORDS ARRAY]
do 
  if [#WORD > LARGEST]
  then
    #LARGEST=WORD
  fi
end
Ryan Price
@rsprice
Feb 25 2016 04:46 UTC
Ruby?
What sorcery is this!?
bitgrower
@bitgrower
Feb 25 2016 04:47 UTC
@JToddFL -- you're not that far from a solution ... I'm not sure why you weren't able to advance beyond "The" -- cuz I copied your code, output to console.log array[i] and it worked just fine for me ...
Eric
@Code-Eric
Feb 25 2016 04:47 UTC
Hey guys anyone care to help me ive been stuck in this local variable thing in javascript. Im sure im just overly exhausted and missing something simple. prompt: Declare a local variable myVar inside myFunction

function myFunction() {
'use strict';
var loc =("myVar");

console.log(loc);
}

console.log(loc);

Jeremy
@JeremyAntonoff
Feb 25 2016 04:47 UTC
is that ruby lol
thanks though dc
Ryan Price
@rsprice
Feb 25 2016 04:47 UTC
not really
It's probably fortran or something, I just see do and end and immediately think Ruby
Richard Corbett
@reacorbett
Feb 25 2016 04:48 UTC
@dcnr thanks
CamperBot
@camperbot
Feb 25 2016 04:48 UTC
reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 714 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 25 2016 04:48 UTC

@AndreWaroux -- a state machine is a type of ... uh ... hmmm how do I explain what a state machine is ...

...it does NOT mean something which takes a lot of steps ...

in specific ... I am keeping remembrance of what came in the past, what was my previous "state" -- specifically, was the previous character a blank or not ...

if it was blank, then I did one thing, otherwise I did something else ...

Jeremy
@JeremyAntonoff
Feb 25 2016 04:49 UTC
@bitgrower i know im not to far off. just been stuck on this one line of code foever
Ryan Price
@rsprice
Feb 25 2016 04:49 UTC
@JToddFL can you paste what you have right now?
bitgrower
@bitgrower
Feb 25 2016 04:49 UTC
@AndreWaroux -- state machines are discussed in some famous compiler books ... and there's all kinds of interesting math around them ... so there are things called finite state automata ... and other weird things .. they are kind of fun ... I wish I knew more about them ... :)
@JToddFL -- are you comfortable with console.log now ?
here's another cool resource for you: http://pythontutor.com/javascript.html ... paste your code in there and you can see, visually, how it runs ... what variables are created, what values they take, etc ...
George Phalen
@gphalen
Feb 25 2016 04:52 UTC
Can anyone help with #230 (Profile Lookup)?
Ryan Price
@rsprice
Feb 25 2016 04:53 UTC
function longest (str) {
// iterate over each word in the string
  // if the current word is longer than the longest word
    // set the current word to be the longest word
};
We start out with this, which is a perfectly cromulent place to start. We now need to parse our logic and make sure it's sound. We know that iterate means loop, and you very cleverly took care of splitting the array into words, so I'll update our code.
This message was deleted
Jeremy
@JeremyAntonoff
Feb 25 2016 04:53 UTC
sure
Eric
@Code-Eric
Feb 25 2016 04:53 UTC

@Code-Eric
Hey guys anyone care to help me ive been stuck in this local variable thing in javascript. Im sure im just overly exhausted and missing something simple. prompt: Declare a local variable myVar inside myFunction
function myFunction() {
'use strict';

console.log(myVar);
}
myFunction();

// run and check the console
// myVar is not defined outside of myFunction
console.log(myVar);

Jeremy
@JeremyAntonoff
Feb 25 2016 04:53 UTC
function findLongestWord(str) {
  var array = str.split(" ");
  var longestword = 0;
  var total = 0;

  for (i=0; i < array.length;i++) {
   total = [index[i] + total
            (if total > index[i])



  }
}

findLongestWord("The quick brown fox jumped over the lazy dog");
not sure why that bracket is there
but i took it out
Ryan Price
@rsprice
Feb 25 2016 04:55 UTC
function longest (str) {
  var words = str.split(' ');
  // iterate over each word in the string
  for (var i = 0; i < words.length; i += 1) {
    // if the current word is longer than the longest word
      // set the current word to be the longest word
  }
};
Look at what we've got now... what's left? We know we're going to have to keep track of the longest string, so that's another variable we'll have to create. Let's update again
bitgrower
@bitgrower
Feb 25 2016 04:55 UTC

:point_up: February 24, 2016 8:46 PM

it looks like bash code to me ...

Ryan Price
@rsprice
Feb 25 2016 04:56 UTC
function longest (str) {
  var words = str.split(' ');
  var longest = '';
  // iterate over each word in the string
  for (var i = 0; i < words.length; i += 1) {
    // if the current word is longer than the longest word
      // set the current word to be the longest word
  }
};
Now finally we can see that we need to use some logic to filter out the longest word. A simple if statement should do just fine. Constructing our if statement is easy now that we have our logic is simple english
Let's update again!
Jeremy
@JeremyAntonoff
Feb 25 2016 04:56 UTC
if (index[i] >= index[i -1])?
bitgrower
@bitgrower
Feb 25 2016 04:56 UTC
@AndreWaroux -- and if you want to see ES6 goodness ... check out @dcnr's portfolio ...
Jeremy
@JeremyAntonoff
Feb 25 2016 04:56 UTC
WAIT
not = to
just >
Ryan Price
@rsprice
Feb 25 2016 04:57 UTC
Huh?
Jeremy
@JeremyAntonoff
Feb 25 2016 04:57 UTC
no
that wouldnt work
what am i thinking
sudheerswamy
@sudheerswamy
Feb 25 2016 04:57 UTC

```// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function process(num) {
return (num + 3) / 5;
}

// Only change code below this line ```

bitgrower
@bitgrower
Feb 25 2016 04:58 UTC
well, you have to compare something to something, that's for sure ... what do you have to compare, @JToddFL ?
Jeremy
@JeremyAntonoff
Feb 25 2016 04:58 UTC
the current word
sudheerswamy
@sudheerswamy
Feb 25 2016 04:58 UTC
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function process(num) {
  return (num + 3) / 5;
}

// Only change code below this line
Jeremy
@JeremyAntonoff
Feb 25 2016 04:58 UTC
index[i] to the longest word so far
through the loop
i just dunno how to do that
bitgrower
@bitgrower
Feb 25 2016 04:58 UTC
...that sounds promising ...
Jeremy
@JeremyAntonoff
Feb 25 2016 04:58 UTC
i mean
words[i]
in his code
bitgrower
@bitgrower
Feb 25 2016 04:58 UTC
hmmm well you have to compare something to something ...
Ryan Price
@rsprice
Feb 25 2016 04:58 UTC
function longest (str) {
  var words = str.split(' ');
  var longest = '';
  // iterate over each word in the string
  for (var i = 0; i < words.length; i += 1) {
    var currentWord = words[i];
    // if the current word is longer than the longest word
      // set the current word to be the longest word
  }
};
@JToddFL ^
sudheerswamy
@sudheerswamy
Feb 25 2016 04:59 UTC
@bitgrower HELP please
Jeremy
@JeremyAntonoff
Feb 25 2016 04:59 UTC
@rsprice doh ok that makes sense hold on let me try
sudheerswamy
@sudheerswamy
Feb 25 2016 04:59 UTC
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function process(num) {
  return (num + 3) / 5;
}

// Only change code below this line
bitgrower
@bitgrower
Feb 25 2016 04:59 UTC
hang on, @sudheerswamy
what challenge is this, @sudheerswamy
Richard Corbett
@reacorbett
Feb 25 2016 05:00 UTC
made it to the algorithm challenges
bitgrower
@bitgrower
Feb 25 2016 05:00 UTC
coolness @reacorbett !!!
Richard Corbett
@reacorbett
Feb 25 2016 05:00 UTC
thanks @bitgrower
CamperBot
@camperbot
Feb 25 2016 05:00 UTC
reacorbett sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 633 | @bitgrower | http://www.freecodecamp.com/bitgrower
Ryan Price
@rsprice
Feb 25 2016 05:01 UTC
@JToddFL look at the pseudo code in the body of that for loop and try to construct your if statement based off of that logic
function longest (str) {
  var words = str.split(' ');
  var longest = '';
  // iterate over each word in the string
  for (var i = 0; i < words.length; i += 1) {
    var currentWord = words[i];
    // if the current word is longer than the longest word
      // set the current word to be the longest word
  }
};
After that all you'll have to do is return the longest word :)
sudheerswamy
@sudheerswamy
Feb 25 2016 05:02 UTC
@bitgrower Call the process function with an argument of 7 and assign its return value to the variable processed.
Norman Dela Cruz
@dcnr
Feb 25 2016 05:02 UTC
@bitgrower @reacorbett @JToddFL @rsprice sorry I had to step away a bit, thank you too
CamperBot
@camperbot
Feb 25 2016 05:02 UTC
dcnr sends brownie points to @bitgrower and @reacorbett and @jtoddfl and @rsprice :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave reacorbett points
:warning: could not find receiver for jtoddfl
:star: 356 | @rsprice | http://www.freecodecamp.com/rsprice
:star: 634 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 25 2016 05:02 UTC
is that a fcc challenge, @sudheerswamy ? can you link me to it ?
Norman Dela Cruz
@dcnr
Feb 25 2016 05:03 UTC
@bitgrower it's a bastardized bash code lol
bitgrower
@bitgrower
Feb 25 2016 05:03 UTC
hahahahaha ...
Jeremy
@JeremyAntonoff
Feb 25 2016 05:04 UTC
@rsprice Thank you so much
CamperBot
@camperbot
Feb 25 2016 05:04 UTC
jtoddfl sends brownie points to @rsprice :sparkles: :thumbsup: :sparkles:
:star: 357 | @rsprice | http://www.freecodecamp.com/rsprice
bitgrower
@bitgrower
Feb 25 2016 05:04 UTC
you got it @JToddFL ???? AWESOME SAUCE .. Congrats !!!
Jeremy
@JeremyAntonoff
Feb 25 2016 05:04 UTC
and thank you @bitgrower
CamperBot
@camperbot
Feb 25 2016 05:04 UTC
jtoddfl sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 635 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 25 2016 05:05 UTC
@sudheerswamy -- so ... look at the example they provide for you ...
Ryan Price
@rsprice
Feb 25 2016 05:05 UTC
@JToddFL no problem! It is extremely useful to use pseudocode to make sure your logic is sound. I would actually say it's best practice :)
Jeremy
@JeremyAntonoff
Feb 25 2016 05:05 UTC
function findLongestWord(str) {
  var array = str.split(" ");
  var longestWord = " ";
  var total = 0;

  for (i=0; i < array.length;i++) {
   var currentWord = array[i];
     if (currentWord.length > longestWord.length) {
       longestWord = currentWord;
       }





  }
  return longestWord.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
that was my code btw
bitgrower
@bitgrower
Feb 25 2016 05:05 UTC
see what they are doing with the variable changed and calling the function change ...
excellent, @JToddFL ...
Ryan Price
@rsprice
Feb 25 2016 05:06 UTC
@JToddFL how many times do you use that total variable?
Jeremy
@JeremyAntonoff
Feb 25 2016 05:06 UTC
i know i just noticed that lol
deleted it
Ryan Price
@rsprice
Feb 25 2016 05:06 UTC
;)
@JToddFL nicely done!
bitgrower
@bitgrower
Feb 25 2016 05:07 UTC

you also don't need to keep track of the actual word ... just the length ... :)

^^^^ for your consideration ... :)

Jeremy
@JeremyAntonoff
Feb 25 2016 05:07 UTC
thanks again!
Emil Aasa
@emilaasa
Feb 25 2016 05:07 UTC
Found an ES6 functional solution
if you want to see it
bitgrower
@bitgrower
Feb 25 2016 05:07 UTC
for which challenge, @emilaasa
Emil Aasa
@emilaasa
Feb 25 2016 05:07 UTC
longestword
bitgrower
@bitgrower
Feb 25 2016 05:07 UTC
ahhh ...
Jeremy
@JeremyAntonoff
Feb 25 2016 05:08 UTC
not sure what es6 means lol
bitgrower
@bitgrower
Feb 25 2016 05:08 UTC
my recommendation is to not put actual solutions here in the chat ... but put them into one of the js playgrounds like jsbin jsfiddle repl.it ... and then give people a link to the code ... that way they can see the solution if they want to ... but can also avoid seeing it if they don't want
@JToddFL -- the latest version of javascript -- came out last summer ...
Emil Aasa
@emilaasa
Feb 25 2016 05:09 UTC
Thats a good idea @bitgrower
bitgrower
@bitgrower
Feb 25 2016 05:09 UTC
:bow:
Jeremy
@JeremyAntonoff
Feb 25 2016 05:09 UTC
what version does freecodecamp use
bitgrower
@bitgrower
Feb 25 2016 05:09 UTC
it will accept ES6 syntax ...
but it accepts earlier versions as well ...
Jeremy
@JeremyAntonoff
Feb 25 2016 05:10 UTC
am i doing myself a disservice by learning an older version of javascript with freecodecamp
Charles Chung
@chulmo
Feb 25 2016 05:10 UTC
Is there a way for regex to check for ANY combination of three numbers? For example "123" <--- check for 231, 321 etc.
bitgrower
@bitgrower
Feb 25 2016 05:10 UTC
and stuff which runs under es5 is likely going to run under es6 ...
@JToddFL -- absolutely NOT ...
Jeremy
@JeremyAntonoff
Feb 25 2016 05:10 UTC
ok thanks @bitgrower
CamperBot
@camperbot
Feb 25 2016 05:10 UTC
jtoddfl sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: jtoddfl already gave bitgrower points
bitgrower
@bitgrower
Feb 25 2016 05:10 UTC
lots of browsers do not run the latest version of js ... so it helps to know different versions ...
Emil Aasa
@emilaasa
Feb 25 2016 05:11 UTC
@JToddFL nope you are not, its an extension of the language and some cleanup pretty mcuh
In this case the only thing i used it for is the arrow syntax for anonymous functions
bitgrower
@bitgrower
Feb 25 2016 05:11 UTC
have you looked at Mozilla Developer Network ? when you look on one of the pages describing various methods, they will show which versions of JS it works with ...
Norman Dela Cruz
@dcnr
Feb 25 2016 05:12 UTC
it's always best to check for browser compatibility
Jeremy
@JeremyAntonoff
Feb 25 2016 05:12 UTC
i have briefly most of my learning has been through here, code academy, and a javascript book by jon duckett
bitgrower
@bitgrower
Feb 25 2016 05:12 UTC
for instance ... there is the es6 function endsWith -- very handy for one of the challenges ... but you should know how to solve that challenge without using the es6 version ...
hmm m... don't know that I've heard his name before ... there are PLENTY of excellent & free js resources ...
help js resources
Jeremy
@JeremyAntonoff
Feb 25 2016 05:13 UTC
nice ill deff bookmark these
bitgrower
@bitgrower
Feb 25 2016 05:13 UTC
I think you might find JavaScript for Cats very helpful @JToddFL
Norman Dela Cruz
@dcnr
Feb 25 2016 05:13 UTC
wish there's a javascript the hard way series too
Jeremy
@JeremyAntonoff
Feb 25 2016 05:14 UTC
me too
i used that for python and then switched to javascript half way through
ichirped
@ichirped
Feb 25 2016 05:14 UTC
I agree with @bitgrower on this ----> "my recommendation is to not put actual solutions here in the chat"
bitgrower
@bitgrower
Feb 25 2016 05:15 UTC
now why don't they literally have Mozilla Developer Network in the wiki list of js resources ... they have devdocs ...
Norman Dela Cruz
@dcnr
Feb 25 2016 05:16 UTC
@bitgrower I like devdocs coz it's easier to search with
bitgrower
@bitgrower
Feb 25 2016 05:16 UTC
that would save me a lot of typing ... people ask too often what MDN is ... (or if I say Mozilla Developer Network .. they ask what that is ... )
@dcnr -- I know you do ... but you'd think it would be included in the js resources if devdocs is there ... LOL
Norman Dela Cruz
@dcnr
Feb 25 2016 05:17 UTC
@bitgrower maybe coz it's actually taking it from the MDN? :P lol I'm more surprised w3schools not there
bitgrower
@bitgrower
Feb 25 2016 05:17 UTC
less a matter of preference, more a matter of completeness ... esp since so many of the algo challenges ref MDN
bhagwant
@sagit2002
Feb 25 2016 05:17 UTC

function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1){
return "Hole-in-one";
}

else if (strokes <= par-2){
return "Eagle";
}

else if (strokes == par-1){
return "Birdie";
}

else if (strokes == par){
return "Par";
}

else if (strokes == par+1){
return "Bogey";
}

else if (strokes == par+2){
return "Double Bogey";
}

else if (strokes >= par+3){
return "Go Home!";
}

// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

what is wrong with this code?????????
Abhishek Kumar
@abhishekKumar1
Feb 25 2016 05:18 UTC
@sagit2002 plz use this
help format
CamperBot
@camperbot
Feb 25 2016 05:18 UTC

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```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 ⏎]

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

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

Norman Dela Cruz
@dcnr
Feb 25 2016 05:19 UTC
@sagit2002 examine your return strings closely
bitgrower
@bitgrower
Feb 25 2016 05:19 UTC
@dcnr -- w3schools has a less than positive rep in some circles ...
Norman Dela Cruz
@dcnr
Feb 25 2016 05:19 UTC
@bitgrower yeah that's why many newbies go there.. :/
bhagwant
@sagit2002
Feb 25 2016 05:20 UTC
@dcnr Ya they seems to be alright
Norman Dela Cruz
@dcnr
Feb 25 2016 05:20 UTC
@bitgrower coz the "better" ones are "too technical"
@sagit2002 no it isn't :P check again
@sagit2002 especially the failing cases
bitgrower
@bitgrower
Feb 25 2016 05:20 UTC
and I've heard some who have survived it and said they had to unlearn the stuff at w3 and re-learn it ...
cramjet
@cramjet
Feb 25 2016 05:20 UTC
the most massive, dwarf-star-heavy props to @qualitymanifest for all the super patient help!!
bitgrower
@bitgrower
Feb 25 2016 05:21 UTC
well ... I don't think that gets @qualitymanifest brownie points ...
cramjet
@cramjet
Feb 25 2016 05:21 UTC
@qualitymanifest thank you so very, very much for your help (oh, i guess i better say it regular like or the bot won't recognize)
CamperBot
@camperbot
Feb 25 2016 05:21 UTC
cramjet sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1000 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
bitgrower
@bitgrower
Feb 25 2016 05:21 UTC
ahh thanks does, though ... LOL ...
bhagwant
@sagit2002
Feb 25 2016 05:21 UTC
@dcnr thanks it was a ! problem
CamperBot
@camperbot
Feb 25 2016 05:21 UTC
sagit2002 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 715 | @dcnr | http://www.freecodecamp.com/dcnr
DJ
@qualitymanifest
Feb 25 2016 05:21 UTC
@cramjet haha :+1:
Norman Dela Cruz
@dcnr
Feb 25 2016 05:21 UTC
@sagit2002 right :D thanks too!
CamperBot
@camperbot
Feb 25 2016 05:21 UTC
dcnr sends brownie points to @sagit2002 :sparkles: :thumbsup: :sparkles:
:star: 206 | @sagit2002 | http://www.freecodecamp.com/sagit2002
bitgrower
@bitgrower
Feb 25 2016 05:21 UTC
ooooh ... 1000 -- congrats to the land of 4 figures, @qualitymanifest
DJ
@qualitymanifest
Feb 25 2016 05:22 UTC
@bitgrower tanks
whoa
@username tanks
CamperBot
@camperbot
Feb 25 2016 05:22 UTC
qualitymanifest sends brownie points to @username :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for username
Norman Dela Cruz
@dcnr
Feb 25 2016 05:22 UTC
LOL
DJ
@qualitymanifest
Feb 25 2016 05:22 UTC
lol
Norman Dela Cruz
@dcnr
Feb 25 2016 05:22 UTC
tax @qualitymanifest
CamperBot
@camperbot
Feb 25 2016 05:22 UTC
dcnr sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1001 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Norman Dela Cruz
@dcnr
Feb 25 2016 05:22 UTC
see that
DJ
@qualitymanifest
Feb 25 2016 05:22 UTC
palindrome brownies
Norman Dela Cruz
@dcnr
Feb 25 2016 05:22 UTC
thanks @obama
CamperBot
@camperbot
Feb 25 2016 05:22 UTC
dcnr sends brownie points to @obama :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for obama
bitgrower
@bitgrower
Feb 25 2016 05:22 UTC
hah ... but tanks don't work for me ?!?
Norman Dela Cruz
@dcnr
Feb 25 2016 05:23 UTC
tax @bitgrower
CamperBot
@camperbot
Feb 25 2016 05:23 UTC
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave bitgrower points
Norman Dela Cruz
@dcnr
Feb 25 2016 05:23 UTC
help file tax returns
CamperBot
@camperbot
Feb 25 2016 05:23 UTC
no wiki entry for: file tax returns
Norman Dela Cruz
@dcnr
Feb 25 2016 05:23 UTC
:/
DJ
@qualitymanifest
Feb 25 2016 05:23 UTC
dont remind me
Norman Dela Cruz
@dcnr
Feb 25 2016 05:24 UTC
almost time!
Raghuram
@Raghuram1994
Feb 25 2016 05:26 UTC
var total=0;
for(total=0;total<=myArr.length;total++);{
console.log(myArr[total]);
}
whats wrong?
Norman Dela Cruz
@dcnr
Feb 25 2016 05:26 UTC
@Raghuram1994 try removing the = in total <= myArr.length
Raghuram
@Raghuram1994
Feb 25 2016 05:26 UTC
got it thak you @dcnr
CamperBot
@camperbot
Feb 25 2016 05:26 UTC
raghuram1994 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 716 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 05:27 UTC
array indices are always n1n-1 !
Matios
@MatiosTV
Feb 25 2016 05:30 UTC
Has any one had trouble with the Local Scope and Functions lesson in Javascript?
Norman Dela Cruz
@dcnr
Feb 25 2016 05:31 UTC
@MatiosTV oh have you declared myVar?
Matios
@MatiosTV
Feb 25 2016 05:31 UTC
The instructions were to declare a variable inside of a function (for scope) ... and then in the editor is a comment saying to "remove the console log line to pass"
Norman Dela Cruz
@dcnr
Feb 25 2016 05:31 UTC
@MatiosTV if you have, then you need to follow what that comments say to pass
yeah
Matios
@MatiosTV
Feb 25 2016 05:32 UTC
@dcnr So I tried, I deleted the console.log() in the function, then the one outside of the function
Then both of them and it's still not working.
Norman Dela Cruz
@dcnr
Feb 25 2016 05:32 UTC
@MatiosTV you only need [to delete] the one outside the function because myVar is scoped inside the function, you might need to refresh your browser
after you delete the log
@MatiosTV "need to delete the one outside I mean"
Matios
@MatiosTV
Feb 25 2016 05:33 UTC
@dcnr Lmao. Wow. Thank you so much.
CamperBot
@camperbot
Feb 25 2016 05:33 UTC
matiostv sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 717 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 05:34 UTC
@MatiosTV yeah often times a refresh solves many problems!
Matios
@MatiosTV
Feb 25 2016 05:34 UTC
Ahahahahahahaha effing RIDICULOUS!!
bitgrower
@bitgrower
Feb 25 2016 05:36 UTC
well ... see youse all manana ...
g'night ...
DJ
@qualitymanifest
Feb 25 2016 05:36 UTC
:wave:
Raghuram
@Raghuram1994
Feb 25 2016 05:38 UTC
can any one Explain Nesting For Loops ?
Caleb Martin
@caleb272
Feb 25 2016 05:38 UTC
what do you need explained about it
Norman Dela Cruz
@dcnr
Feb 25 2016 05:38 UTC
g'night @bitgrower buhbyes
Raghuram
@Raghuram1994
Feb 25 2016 05:39 UTC
This message was deleted
This message was deleted
This message was deleted
This message was deleted
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:41 UTC
Hi guys, I'm having some trouble getting some data from a JSON request. The link http://quotes.stormconsultancy.co.uk/random.json is valid JSON according to jsonlint.com but when I execute a $.getJSON I get the error: No Access-Control-Allow-Origin header is present on the requested resource. and if I request it as jsonp I get the error Uncaught SyntaxError: Unexpected token : BUT there is the correct data when I click on the link in the console. How can I get that data to be read correctly?
Norman Dela Cruz
@dcnr
Feb 25 2016 05:45 UTC

@Raghuram1994

var myArr = [10, 20, 30];

We access array values via the element's index

var result = myArr[0]; // result would be 10

So we can use a variable to represent the index number too

var index = 1;
var result = myArr[index]; // result would be 20

So we can use use a for loop to "automate" the incrementing
of the variable we use as index, so we can "go through" the
entire array.

for (var index = 0; index < myArr.length; index++) {
  console.log(myArr[index]);
}

Will output:

10
20
30
@eagarcia8 have you tried asking in the Front End and the main room? They are more active about this kind of question
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:47 UTC
@dcnr Can you provide a link for those rooms? I thought JS would be the best room for jQuery stuff
Norman Dela Cruz
@dcnr
Feb 25 2016 05:48 UTC
@eagarcia8 here's the one for the front end https://gitter.im/FreeCodeCamp/HelpFrontEnd
DJ
@qualitymanifest
Feb 25 2016 05:48 UTC
you'll want to use https://gitter.im/FreeCodeCamp/HelpFrontEnd that said, someone else was having problems with that API yesterday, and neither myself nor another (more experienced) person here could figure it out. it doesn't help that the documentation on that API is really poor, so i would probably just recommend using another API.
Norman Dela Cruz
@dcnr
Feb 25 2016 05:49 UTC
@eagarcia8 this room's actually more focused on the challenges rather than using libs like jquery
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:49 UTC
@dcnr Gotcha, thanks for the link
CamperBot
@camperbot
Feb 25 2016 05:49 UTC
eagarcia8 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 718 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 05:50 UTC
@eagarcia8 you can click the globe thingy next to the star at the upper right part of the chat room to get the list of FCC rooms
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:50 UTC
I looked online for a quotes API, but that's the only free one I found lol. @qualitymanifest
@dcnr Thanks for the tip.
CamperBot
@camperbot
Feb 25 2016 05:50 UTC
eagarcia8 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: eagarcia8 already gave dcnr points
DJ
@qualitymanifest
Feb 25 2016 05:51 UTC
@eagarcia8 there's others. you could also just use an array of quotes instead of an API. plenty of challenges later where you will learn about using API's
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:52 UTC
@qualitymanifest Yea but I liked the idea of having access to a large amount of quotes. I've done API's before using PHP->XML but I'm new to JSON.
There has to be a way though, that link provides the data I want, just in an error, and jsonlint.com says its all good JSON and jsonp.
sudheerswamy
@sudheerswamy
Feb 25 2016 05:53 UTC

```function queue(arr, item) {

return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
```

function queue(arr, item) {

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
Norman Dela Cruz
@dcnr
Feb 25 2016 05:58 UTC
@sudheerswamy Read about Array.push and Array.shift for that exercise
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:00 UTC
var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
newArray = oldArray.filter(function(val) {
  return val < 6;
} );

var newArray = oldArray;
any idea on why the newArray does not return [1, 2, 3, 4, 5]
sudheerswamy
@sudheerswamy
Feb 25 2016 06:00 UTC
@dcnr thanks
CamperBot
@camperbot
Feb 25 2016 06:00 UTC
sudheerswamy sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 719 | @dcnr | http://www.freecodecamp.com/dcnr
Eduardo Garcia
@eagarcia8
Feb 25 2016 06:01 UTC
@vsidoren because 1 - 5 is smaller than 6
Norman Dela Cruz
@dcnr
Feb 25 2016 06:01 UTC
@vsidoren because of this var newArray = oldArray;
Richard Corbett
@reacorbett
Feb 25 2016 06:01 UTC
did the first alg. challenge on my own! !!!
Caleb Martin
@caleb272
Feb 25 2016 06:01 UTC
anyone want to try out my wiki search http://codepen.io/thecoder15/full/grYOdW?editors=0100
Norman Dela Cruz
@dcnr
Feb 25 2016 06:02 UTC
@vsidoren you were supposed to add the .filter part there, but since you made your own, just delete that part var newArray = oldArray;
@reacorbett congratulations :D
Richard Corbett
@reacorbett
Feb 25 2016 06:02 UTC
@dcnr thanks. Im proud of it.
CamperBot
@camperbot
Feb 25 2016 06:02 UTC
reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 720 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 06:03 UTC
@reacorbett as you should be :D hahah
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:03 UTC
oh so that part is returning the original array @dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 06:03 UTC
@caleb272 post it in the Front End room too! https://gitter.im/FreeCodeCamp/HelpFrontEnd :D
@vsidoren yeah!
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:04 UTC
keeps getting me .... @dcnr thanks
CamperBot
@camperbot
Feb 25 2016 06:04 UTC
vsidoren sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 721 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 06:04 UTC
@vsidoren that part gets a lot of people!
Hereshk
@Hereshk
Feb 25 2016 06:15 UTC
  var toFilter = [];

  for (var i = 1; i < arguments.length; i++){
    toFilter.push(arguments[i]);
  }

  function seekNd(val){
    for (var i = 0; i < toFilter.length; i++){
      if(val === toFilter[i]){
      return false;
      }
      return true;
    }
  }

  return arr.filter(seekNd);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
it will only filter the first argument out
I can<T see why
can I modify it to make it work or I need a complete different approach? (its the seek and destroy challenge)
DJ
@qualitymanifest
Feb 25 2016 06:18 UTC
@Hereshk you need to return true only after the loop has completed
@Hereshk there's better ways of doing it, but if you change that part, it should work
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:18 UTC
var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a, b) {
  return b-a;
});
I passed the challege but confused as to why b-a return a sorted array from largest to smallest
Hereshk
@Hereshk
Feb 25 2016 06:20 UTC
@qualitymanifest It means that the loop was always stoping after the first test because the "return true" is misplaced?
DJ
@qualitymanifest
Feb 25 2016 06:21 UTC
@Hereshk yes. when you return, you exit the function. so you only want to return true if val isn't equal to any parts of toFilter ( the loop has to run the whole way through )
Hereshk
@Hereshk
Feb 25 2016 06:22 UTC
ok I understand :) thanks @qualitymanifest
CamperBot
@camperbot
Feb 25 2016 06:22 UTC
hereshk sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1002 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Feb 25 2016 06:23 UTC
:+1:
please refer to the above link
it has good explanation
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:27 UTC
thanks @vinitm theres a lot there
CamperBot
@camperbot
Feb 25 2016 06:27 UTC
vsidoren sends brownie points to @vinitm :sparkles: :thumbsup: :sparkles:
:star: 317 | @vinitm | http://www.freecodecamp.com/vinitm
PattyCreates
@PattyCreates
Feb 25 2016 06:44 UTC
Hm, totally not even knowing what this means.

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.

I've been rocking and rolling on this course as a whole, but this prompt is unfamiliar and it's not registering. Anyone have any tips?
Ryan Price
@rsprice
Feb 25 2016 06:58 UTC
@PattyCreates want to show me what you've got so far?
@PattyCreates if the concept of a queue is what's confusing, just think of a line of people. People enter a queue (line) from the back and remove themselves from the front. You want to do the same thing with your data. It's just a way of structuring the data you're working with.
PattyCreates
@PattyCreates
Feb 25 2016 07:03 UTC
a queue makes sense in order
But, I'm not sure as to what the prompt is asking?
function queue(arr, item) {
  // Your code here
  queue = [arr, item];
  var item = "";

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Olawale Akinseye
@brainyfarm
Feb 25 2016 07:05 UTC
@PattyCreates, queue is a function not a variable.
PattyCreates
@PattyCreates
Feb 25 2016 07:05 UTC
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array.
Ryan Price
@rsprice
Feb 25 2016 07:06 UTC
@PattyCreates the prompt is asking you to take an array as your first argument, and an item as your second. In the body of your function you should add the item to the back of your array, and remove the first element of your array.
PattyCreates
@PattyCreates
Feb 25 2016 07:06 UTC
So it mentions adding a queue as a function with arguments, which it looks like is inherited by the code snippet. But i'm not sure how you add an array to a function?
Marina
@chandra90
Feb 25 2016 07:06 UTC
hello! Please help! I did not quite understand this task
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Ryan Price
@rsprice
Feb 25 2016 07:07 UTC
@PattyCreates you add data to a function by passing in arguments. You'll want to pass in an array as the first argument of your function
Marina
@chandra90
Feb 25 2016 07:07 UTC
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
PattyCreates
@PattyCreates
Feb 25 2016 07:07 UTC
@chandra90 try concantenating within var result = "";
oh.
Marina
@chandra90
Feb 25 2016 07:08 UTC
@PattyCreates I did not get it. sorry
PattyCreates
@PattyCreates
Feb 25 2016 07:08 UTC
@rsprice okay. so maybe it's arr = [array of things]?
Ankit Panwar
@coderNoob
Feb 25 2016 07:09 UTC
In Symmetric Difference Bonfire, the sym function only accepts a single parameter but there are n number of arguments being passed. How ? I don't get it.
Mihai Lita
@atryx
Feb 25 2016 07:09 UTC
hello
  var strReverse = str.replace(/[^A-Za-z0-9]/g,"").toLowerCase().split('').reverse().join('');
  if(str == strReverse) {
    return true;
  }

  return false;
PattyCreates
@PattyCreates
Feb 25 2016 07:09 UTC
@chandra90 concatenating. so var result = "This is the beginning " + myNoun + " etc";
Mihai Lita
@atryx
Feb 25 2016 07:09 UTC
any idea why it doesn't work
PattyCreates
@PattyCreates
Feb 25 2016 07:09 UTC
and you'll have to do it for all of them.
Ryan Price
@rsprice
Feb 25 2016 07:09 UTC
var testArr = [1,2,3,4,5];
console.log(queue(testArr, 6)); // Modify this line to test
@PattyCreates ^ you pass testArr in as the first argument
Ankit Panwar
@coderNoob
Feb 25 2016 07:10 UTC
@atryx are you trying to reverse a string or make it blank?
Ryan Price
@rsprice
Feb 25 2016 07:11 UTC
@PattyCreates you will manipulate the data in array, but you do not need to define it in any way
Mihai Lita
@atryx
Feb 25 2016 07:11 UTC
@coderNoob First I remove al punctuation char, then make it to lower case, then reverse it
@coderNoob I've test it with alert, and it print correct, the if doesn't work
doesn't know why
Ankit Panwar
@coderNoob
Feb 25 2016 07:12 UTC
@atryx Can i have your sample string?
Mihai Lita
@atryx
Feb 25 2016 07:12 UTC
@coderNoob I think I know why
Damn, i'm dumb
it worked :D
@coderNoob Thanks man!
CamperBot
@camperbot
Feb 25 2016 07:13 UTC
atryx sends brownie points to @codernoob :sparkles: :thumbsup: :sparkles:
:star: 339 | @codernoob | http://www.freecodecamp.com/codernoob
Mihai Lita
@atryx
Feb 25 2016 07:13 UTC
The original string had spaces and punctuation
I was comparing apples with oranges
PattyCreates
@PattyCreates
Feb 25 2016 07:14 UTC
@rsprice I'm here.
```
function queue(arr, item) {
  // Your code here
  arr = testArr.shift(testArr[0]);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 5)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ryan Price
@rsprice
Feb 25 2016 07:16 UTC
@PattyCreates first just try adding the element to the back of the array
@PattyCreates your intuition is correct to use shift, but you don't need to specify the element you want to remove
@PattyCreates Also, you want to perform the operations on arr, or the array that you'll be passing in as an argument
@PattyCreates to clarify, you can simply use arr.shift() to remove the first element of an array
This message was deleted
PattyCreates
@PattyCreates
Feb 25 2016 07:20 UTC
What does "add the number" mean? I generally confused on what the prompt is really asking for.
Ryan Price
@rsprice
Feb 25 2016 07:21 UTC
@PattyCreates the number will be item, the thing being passed in to be added to the back of the queue
PattyCreates
@PattyCreates
Feb 25 2016 07:21 UTC
so am i supposed to define item?
Ryan Price
@rsprice
Feb 25 2016 07:22 UTC
Nope
queue(testArr, 5)
you pass in your array as your first argument @PattyCreates and then you pass in your item, a number, as your second argument
your function will take the item and add it to the back of arr, then you will remove the item from the front of arr and return it
@PattyCreates and that, as they say, is that.
To be honest, I really don't like the way they explained this. It's really confusing and I wouldn't explain a queue in this way.
PattyCreates
@PattyCreates
Feb 25 2016 07:24 UTC
Ah, so okay. you're saying if i understand this.
The first argument arr is being taken in as the whole testArr and thats the end of the first argument accepted?
then second argument is the only one that you get to really see interpreted?
@rsprice ?
as in the items from the testArr?
Ryan Price
@rsprice
Feb 25 2016 07:25 UTC
the first argument arr represents any array that you pass in to your function
the second argument is any item you pass in, in our case a number
testArray = [1,2,3,4]; queue(testArr, 5)
@PattyCreates you just as easily do queue([1,2,3,4], 5);
They just happened to save the array to a variable, and pass that reference into the function.
@PattyCreates does that make sense?
PattyCreates
@PattyCreates
Feb 25 2016 07:27 UTC
Hm, like half way?
Ryan Price
@rsprice
Feb 25 2016 07:28 UTC
@PattyCreates Ok, so where is your understanding breaking down? Can you pinpoint what is confusing you?
@PattyCreates if you want, we can jump in a google hangout and I'll explain it to you if that's easier
should take 5 mins
PattyCreates
@PattyCreates
Feb 25 2016 07:29 UTC
I'm looking at this currently.
I mean, if you're willing to hop on a call, that would be awesome.
Ryan Price
@rsprice
Feb 25 2016 07:30 UTC
@PattyCreates yeah I'll PM you a link
Reza Jafar
@Reza7865
Feb 25 2016 07:30 UTC
Is this buggy?
Screen Shot 2016-02-24 at 11.29.43 PM.png
Ryan Price
@rsprice
Feb 25 2016 07:30 UTC
If anyone else is confused by queue feel free to PM me and I'll give you the link as well
PattyCreates
@PattyCreates
Feb 25 2016 07:31 UTC
@Reza7865 not buggy.
read the commented out section. you're supposed to remove something to continue.
i hit the same issue.
Denis
@DenisDov
Feb 25 2016 07:32 UTC
bot
CamperBot
@camperbot
Feb 25 2016 07:32 UTC

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

Basic Commands:

  • find TOPIC find all entries about topic. ex: 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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Denis
@DenisDov
Feb 25 2016 07:32 UTC
find counting
CamperBot
@camperbot
Feb 25 2016 07:32 UTC

find counting

:zero: checkpoint counting cards

Denis
@DenisDov
Feb 25 2016 07:33 UTC
find counting
CamperBot
@camperbot
Feb 25 2016 07:33 UTC

find counting

:zero: checkpoint counting cards

Reza Jafar
@Reza7865
Feb 25 2016 07:33 UTC
@DenisDov ah ok thank you
CamperBot
@camperbot
Feb 25 2016 07:33 UTC
reza7865 sends brownie points to @denisdov :sparkles: :thumbsup: :sparkles:
Denis
@DenisDov
Feb 25 2016 07:33 UTC
bot
CamperBot
@camperbot
Feb 25 2016 07:33 UTC

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

Basic Commands:

  • find TOPIC find all entries about topic. ex: 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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

:star: 79 | @denisdov | http://www.freecodecamp.com/denisdov
Denis
@DenisDov
Feb 25 2016 07:33 UTC
bot
CamperBot
@camperbot
Feb 25 2016 07:33 UTC

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

Basic Commands:

  • find TOPIC find all entries about topic. ex: 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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Denis
@DenisDov
Feb 25 2016 07:33 UTC
bot find
CamperBot
@camperbot
Feb 25 2016 07:33 UTC

:point_right: algorithm find the longest word in a string [wiki]

Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

:pencil: read more about algorithm find the longest word in a string on the FCC Wiki

Denis
@DenisDov
Feb 25 2016 07:34 UTC
bot
CamperBot
@camperbot
Feb 25 2016 07:34 UTC

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

Basic Commands:

  • find TOPIC find all entries about topic. ex: 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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Denis
@DenisDov
Feb 25 2016 07:34 UTC
find counting
CamperBot
@camperbot
Feb 25 2016 07:34 UTC

find counting

:zero: checkpoint counting cards

Hey guys need help
bhagwant
@sagit2002
Feb 25 2016 07:38 UTC
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Not making any sense to me can anybody explain what they want
Richard Andrews
@Whiplash5057
Feb 25 2016 07:39 UTC
I dont know how to display latitude and longitude
API
bhagwant
@sagit2002
Feb 25 2016 07:40 UTC

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

// Only change code above this line

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

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

can anybody out there help me
@Whiplash5057 good going.
codewalker007
@codewalker007
Feb 25 2016 07:45 UTC
@sagit2002 I believe the instructions are saying "if" a is less than 0 exit the function of "if" b is less than 0 exit the function then return "undefined"
of = or
bhagwant
@sagit2002
Feb 25 2016 07:47 UTC

@codewalker007 if (a < 0 && b < 0){
return undefined;

}
this is not working

Any code suggestions
kirbyedy
@kirbyedy
Feb 25 2016 07:48 UTC
does it have to be AND or OR, I cant remember
codewalker007
@codewalker007
Feb 25 2016 07:49 UTC
@sagit2002 use "or" and you might want to try return "undefined";
Sloth
@RMo-Sloth
Feb 25 2016 07:49 UTC
@sagit2002 if you want to return undefined as a string use "undefined"
kirbyedy
@kirbyedy
Feb 25 2016 07:50 UTC
I am not sure if it has to be returned as a string
bhagwant
@sagit2002
Feb 25 2016 07:50 UTC

if (a < 0 || b < 0){
return "undefined";

}
No Luck

kirbyedy
@kirbyedy
Feb 25 2016 07:50 UTC
what challenge is that, I have to read the explanation
bhagwant
@sagit2002
Feb 25 2016 07:51 UTC
@kirbyedy Javascript - Return early pattern for functions
kirbyedy
@kirbyedy
Feb 25 2016 07:52 UTC
ah
you just have to return
no undefined or anything
bhagwant
@sagit2002
Feb 25 2016 07:53 UTC
@kirbyedy Thanks a lot
CamperBot
@camperbot
Feb 25 2016 07:53 UTC
sagit2002 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 535 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Sloth
@RMo-Sloth
Feb 25 2016 07:53 UTC
@sagit2002 if it returns nothing it returns undefined
codewalker007
@codewalker007
Feb 25 2016 07:53 UTC
ah
bhagwant
@sagit2002
Feb 25 2016 07:54 UTC
Thanks everybody for the help
Timothy Musimbi
@tmusimbi
Feb 25 2016 07:58 UTC

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

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

}

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

want checkObj("gift") to return "pony". Any help?
Markus Kiili
@Masd925
Feb 25 2016 08:00 UTC
@tmusimbi The dot notation only works if the property key string is a valid JS identifier and you write the key after the dot. Bracket notation works with keys that can be arbitrary strings, variables, or expressions.
@tmusimbi .checkProp looks for property "checkProp". That is the problem there.
Wes
@weslez
Feb 25 2016 08:01 UTC
Can anyone point me in the right direction. I've got all of the elements in place to solve the Check for Palindromes bonfire, but there's something missing that won't let it check the === vs !==. Help!

function palindrome(str) {
  if (str === "") {
    return "unknown";
  } 
  var lowerCase = str.toLowerCase();
  var noSpaces = lowerCase.replace(/ /g, "");
  var splitIt = noSpaces.split("");

  if (splitIt === splitIt.reverse) {
    return true;
  } else if (splitIt !== splitIt.reverse) {
    return false;
  }
  // Good luck!
}



palindrome("racecar");
Markus Kiili
@Masd925
Feb 25 2016 08:03 UTC
@weslez The array method is .reverse but you invoke it with (), so use .reverse();
@weslez Your regexp for removing non-aplhanumerics is also wrong I believe.
Timothy Musimbi
@tmusimbi
Feb 25 2016 08:04 UTC
@Masd925 Thanks alot!
CamperBot
@camperbot
Feb 25 2016 08:04 UTC
tmusimbi sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1050 | @masd925 | http://www.freecodecamp.com/masd925
Wes
@weslez
Feb 25 2016 08:05 UTC
Thanks @Masd925 ! I don't know what regexp is, but I saw something about it while googling, so if I look into that I might find the solution. Thank you!!
CamperBot
@camperbot
Feb 25 2016 08:05 UTC
weslez sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1051 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Feb 25 2016 08:07 UTC
This message was deleted
@weslez You have to join the array and the reverse array before comparing. You cannot compare array content with === because arrays are objects. === compares object identity (memory location). You can join the arrays to strings and compare them because strings are primitives.
Ryan Price
@rsprice
Feb 25 2016 08:15 UTC
^ this
codewalker007
@codewalker007
Feb 25 2016 08:22 UTC
@weslez look for help on PERL regex for Perl regular expressions. This is the standard that many languages now use to perform string matching. https://www.cs.tut.fi/~jkorpela/perl/regexp.html
codewalker007
@codewalker007
Feb 25 2016 08:30 UTC
@weslez in this line of code var noSpaces = lowerCase.replace(/ /g, ""); / /g is the regular expression part. http://www.w3schools.com/jsref/jsref_replace.asp explains more
Pedro Abel Díaz Sánchez
@coderHook
Feb 25 2016 08:36 UTC
Can someone explain me why am getting the browser down after running this code, is from the fibonnaci intermediate algorithm:
function sumFibs(num) {  
  var fib = [];

  fib[0] = 0;
  fib[1] = 1;

  for (var i = 2; i < num; i++){

    fib[i] = fib[i-2] + fib[i-1];

  }

  return fib;
}

sumFibs(4);
L Yeh
@PhotoGeek1
Feb 25 2016 08:36 UTC
If I wanted to delete all non-alphanumeric characters in a lengthy string how would I go about identifying them?
codewalker007
@codewalker007
Feb 25 2016 08:39 UTC
@PhotoGeek1 I am guessing something like myString.replace(/\d/g, "");
this should delete all numbers from a string
but you would change it to target non-alphanumeric characters
L Yeh
@PhotoGeek1
Feb 25 2016 08:40 UTC
@codewalker007 Thanks - I'm looking to keep 0-9 & a-z. I want to delete punctuation, spaces and symbols. Not sure where to look.
CamperBot
@camperbot
Feb 25 2016 08:40 UTC
photogeek1 sends brownie points to @codewalker007 :sparkles: :thumbsup: :sparkles:
:star: 148 | @codewalker007 | http://www.freecodecamp.com/codewalker007
Emil Aasa
@emilaasa
Feb 25 2016 08:42 UTC
@PhotoGeek1 https://regex101.com/
I like that one
L Yeh
@PhotoGeek1
Feb 25 2016 08:44 UTC
@emilaasa thank you!
CamperBot
@camperbot
Feb 25 2016 08:44 UTC
photogeek1 sends brownie points to @emilaasa :sparkles: :thumbsup: :sparkles:
:star: 294 | @emilaasa | http://www.freecodecamp.com/emilaasa
Emil Aasa
@emilaasa
Feb 25 2016 08:45 UTC
Also if you are new to regex, http://regexone.com/ is great
They even have an exercise called Any Non-alphanumeric character :)
alpox
@alpox
Feb 25 2016 08:49 UTC
@Abel1987 in the loop you try to assign a value to non-existing indexes in the array fib
codewalker007
@codewalker007
Feb 25 2016 08:49 UTC
@PhotoGeek1 try this code
var str = "Mr Blue has a blue house and a blue car0123456789";
var res = str.replace(/[^A-Za-z0-9]/g, "");
console.log(res);
Bartosz
@CataciD
Feb 25 2016 08:51 UTC
hi ther emates
im back again
L Yeh
@PhotoGeek1
Feb 25 2016 08:56 UTC
@codewalker007 Thank you! You rock!
CamperBot
@camperbot
Feb 25 2016 08:56 UTC
photogeek1 sends brownie points to @codewalker007 :sparkles: :thumbsup: :sparkles:
:warning: photogeek1 already gave codewalker007 points
codewalker007
@codewalker007
Feb 25 2016 08:59 UTC
np
Bartosz
@CataciD
Feb 25 2016 08:59 UTC
anyone here did the no repeats please ?
im trying heaps algorithm but i keep getting circular object arrays and my shit freezes : |
Pedro Abel Díaz Sánchez
@coderHook
Feb 25 2016 09:06 UTC
@alpox I supose I will be creating it that way.
L Yeh
@PhotoGeek1
Feb 25 2016 09:07 UTC
Can I just say that the algorithms are really hard? And I'm on the easy set. Brain is already getting fried.
Robert Uivarosi
@URobert
Feb 25 2016 09:10 UTC
@SaintPeter thanks
CamperBot
@camperbot
Feb 25 2016 09:10 UTC
urobert sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2555 | @saintpeter | http://www.freecodecamp.com/saintpeter
Robert Uivarosi
@URobert
Feb 25 2016 09:12 UTC
@CataciD can you send your code ?
Bartosz
@CataciD
Feb 25 2016 09:13 UTC
i have a generator but it freezes so im trying out a new way
but the code is
function permGen(n,arr){
  var holder=[];
  if(n===1){
    perms.push(arr);
    console.log(arr);
    return;
  } else {
    for(var i=0; i<n-1; i++){
      if(n%2===0){
        holder=arr[i];
        arr[i]=arr[n-1];
        arr[n-1]=holder;
        permGen(n-1,arr);
      } else {
        holder=arr[0];
        arr[0]=arr[n-1];
        arr[n-1]=holder;
        permGen(n-1,arr);
      }
    }
  }
  return;
}
console.logs are for me to check
the function gets str.length and str.split(""); as the arguments
though the code here isnt what it should, permGen(n-1,arr); in the if statement should be before it and after for
then the generator works
but if i try pushing eac harray when n===1 to an array i declared outside, it pushes the second element every time