text:
25th
Feb 2016
alpox
@alpox
Feb 25 2016 00:00
@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
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
i have general question Is weather API or Wikipedia API considered RESTful services ????
Andrew Dutton
@andrew-dutton
Feb 25 2016 00:04
it returns only the first item (which would be strArray[0])
alpox
@alpox
Feb 25 2016 00:05
@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
help!!!!!!!!!!
CamperBot
@camperbot
Feb 25 2016 00:08

### 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!

John Espinoza
@johnlovespi
Feb 25 2016 00:09
Accessing Nested Arrays in JSON ::
Andrew Dutton
@andrew-dutton
Feb 25 2016 00:09
thank you @alpox !
CamperBot
@camperbot
Feb 25 2016 00:09
andrewaroux sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
John Espinoza
@johnlovespi
Feb 25 2016 00:09
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
@johnlovespi look carefully at what your myPlants is. What type of variable is it?
John Espinoza
@johnlovespi
Feb 25 2016 00:11
object
Norman Dela Cruz
@dcnr
Feb 25 2016 00:11
@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

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
:bulb: to format code use backticks!  more info
John Espinoza
@johnlovespi
Feb 25 2016 00:12
so myPlants.tress[1] @dcnr ?
Norman Dela Cruz
@dcnr
Feb 25 2016 00:13
@johnlovespi no myPlants is an array of objects, it's an array that holds your object
Pavel Isp
@pavelisp
Feb 25 2016 00:13
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
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
@alpox thanks you are right . I just checked it with others :)
CamperBot
@camperbot
Feb 25 2016 00:14
zeemax sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
Orestis Gklavas
@oglavas
Feb 25 2016 00:15
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
@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

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
@dcnr ok so if i need to grab an object from the list
James Sangalli
@James-Sangalli
Feb 25 2016 00:17
@khaduch after much trial and tribulation I got it to work, thanks dude
CamperBot
@camperbot
Feb 25 2016 00:17
james-sangalli sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
John Espinoza
@johnlovespi
Feb 25 2016 00:18
can i just call the object and its proper
alpox
@alpox
Feb 25 2016 00:18
@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
@alpox I'm not sure I get it. They are defined as functions, via Object.defineProperty()
John Espinoza
@johnlovespi
Feb 25 2016 00:23
@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
help js resources
CamperBot
@camperbot
Feb 25 2016 00:25

## :point_right: js resources [wiki]

### References

Find javascript libraries at http://jster.net

See Also: :loop: Quick JS | :watch: Challenges | :wrench: Exercises | :clipboard: Editors | :newspaper: Blogs | :books: Books

alpox
@alpox
Feb 25 2016 00:26
@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
@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
This message was deleted
Craig Banach
@CraigBanach
Feb 25 2016 00:30
help class
CamperBot
@camperbot
Feb 25 2016 00:30

# 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.

alpox
@alpox
Feb 25 2016 00:30

@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
@alpox Yes, but the 'get!' is the result of the function being called (its console.log output).
alpox
@alpox
Feb 25 2016 00:32
@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

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
@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
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
wiki brownie points
CamperBot
@camperbot
Feb 25 2016 00:34

## :point_right: brownie points [wiki]

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

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.

Caleb Martin
@caleb272
Feb 25 2016 00:34
use thanks and his name using the at symbols @oglavas
CamperBot
@camperbot
Feb 25 2016 00:34
caleb272 sends brownie points to @oglavas :sparkles: :thumbsup: :sparkles:
alpox
@alpox
Feb 25 2016 00:34
@PhotoGeek1 You don't assign the function parameters to the this.<something> variables
CamperBot
@camperbot
Feb 25 2016 00:34
:star: 311 | @oglavas | http://www.freecodecamp.com/oglavas
Orestis Gklavas
@oglavas
Feb 25 2016 00:34
thanks @alpox
CamperBot
@camperbot
Feb 25 2016 00:34
oglavas sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
alpox
@alpox
Feb 25 2016 00:35
I cannot get these :D i'm not a freecodecamp member
Caleb Martin
@caleb272
Feb 25 2016 00:35
thats cool what made you want to jump on the chat and help
alpox
@alpox
Feb 25 2016 00:36
@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

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
@alpox Oh, I see...
alpox
@alpox
Feb 25 2016 00:36
@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
can some one tell me where is it going wrong
Craig Banach
@CraigBanach
Feb 25 2016 00:37

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
@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
@ratishidm Your gear only seems to add 4 each time you try to shift
Caleb Martin
@caleb272
Feb 25 2016 00:38
the call to the wiki api is returning an error and google isn’t helping
alpox
@alpox
Feb 25 2016 00:38
@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
@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
@PhotoGeek1 ok, so what error messages are you getting?
alpox
@alpox
Feb 25 2016 00:41
@PhotoGeek1 That looks good to me...
Caleb Martin
@caleb272
Feb 25 2016 00:41
same^
maybe its the way he is calling it?
@alpox and i know it posts the error i can’t find any fix
alpox
@alpox
Feb 25 2016 00:42
@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
k thanks @alpox
CamperBot
@camperbot
Feb 25 2016 00:43
caleb272 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alpox
Caleb Martin
@caleb272
Feb 25 2016 00:43
dam haha
Eric
@Code-Eric
Feb 25 2016 00:44
hey guys think someone could help me out with something? Im stuck on escaping.
Caleb Martin
@caleb272
Feb 25 2016 00:44
Eric
@Code-Eric
Feb 25 2016 00:44
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

@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
what i did was:var myStr=\ \t \t \r \n;
Caleb Martin
@caleb272
Feb 25 2016 00:45
@PhotoGeek1 what is wrong with it what doesn’t work
Craig Banach
@CraigBanach
Feb 25 2016 00:45
@PhotoGeek1 Well, that's what you are setting the variables to .... why wouldn't it?
Caleb Martin
@caleb272
Feb 25 2016 00:46
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
@Code-Eric You need to set myStr to a string.
L Yeh
@PhotoGeek1
Feb 25 2016 00:46
Oh, duh. Ok
thanks @caleb272 @CraigBanach
CamperBot
@camperbot
Feb 25 2016 00:46
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
^ we all have that moment
Eric
@Code-Eric
Feb 25 2016 00:46
how do I set it to a string?
Caleb Martin
@caleb272
Feb 25 2016 00:46
var x = “”;
^^
Craig Banach
@CraigBanach
Feb 25 2016 00:47
@Code-Eric "enter string between quotes";
Caleb Martin
@caleb272
Feb 25 2016 00:47
‘“”’;
Eric
@Code-Eric
Feb 25 2016 00:47
Oh wow okay, thank you @CraigBanach
CamperBot
@camperbot
Feb 25 2016 00:47
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

@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
@ratishidm ok, so where is the setGear function?
Caleb Martin
@caleb272
Feb 25 2016 00:49
use gear += change;
Craig Banach
@CraigBanach
Feb 25 2016 00:49
@caleb272 don't use that.
Caleb Martin
@caleb272
Feb 25 2016 00:49
why
Craig Banach
@CraigBanach
Feb 25 2016 00:50
@caleb272 gear = change;
ratishidm
@ratishidm
Feb 25 2016 00:50
this.setGear = function(change){
gear=change+gear;
};
Craig Banach
@CraigBanach
Feb 25 2016 00:50
@ratishidm ok, so when gear is 1 and you pass in 3, what will happen?
ratishidm
@ratishidm
Feb 25 2016 00:50
it should return 3
Craig Banach
@CraigBanach
Feb 25 2016 00:51
@ratishidm why, since when does 1+3 = 3?
ratishidm
@ratishidm
Feb 25 2016 00:51
I set gear to 0
alpox
@alpox
Feb 25 2016 00:51
ratishidm
@ratishidm
Feb 25 2016 00:51
and i am trying to add change to gear
Craig Banach
@CraigBanach
Feb 25 2016 00:51
@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
@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
@ratishidm SO you need to rethink your setGear fucntion.
ratishidm
@ratishidm
Feb 25 2016 00:52
no when i call setGear(1) which makes 1
Craig Banach
@CraigBanach
Feb 25 2016 00:52
@ratishidm ok then, don't change your function.
Caleb Martin
@caleb272
Feb 25 2016 00:52
k thanks alpox
alpox
@alpox
Feb 25 2016 00:52
@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
haha
ratishidm
@ratishidm
Feb 25 2016 00:54
@CraigBanach see what ever the change value is i am adding that to gear
Caleb Martin
@caleb272
Feb 25 2016 00:54
ya it wasn’t sending back anything its an error itself
Craig Banach
@CraigBanach
Feb 25 2016 00:54
@ratishidm and do you want it to do that?
ratishidm
@ratishidm
Feb 25 2016 00:54
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
?
alpo what link did you use
Craig Banach
@CraigBanach
Feb 25 2016 00:54
@ratishidm No, you don't want it to do that.
@ratishidm what if gear is 2?
alpox
@alpox
Feb 25 2016 00:55
@caleb272 I dont know how to show you my working link
Caleb Martin
@caleb272
Feb 25 2016 00:55
why
you can paste code in here
‘’' <
or i mean  <
alpox
@alpox
Feb 25 2016 00:55
@caleb272 I wanted to put here the codepen thing xD
Craig Banach
@CraigBanach
Feb 25 2016 00:55
Caleb Martin
@caleb272
Feb 25 2016 00:56
ya fork my project
alpox
@alpox
Feb 25 2016 00:56
I'm not logged in there... well i just put the code here
Caleb Martin
@caleb272
Feb 25 2016 00:56
k
alpox
@alpox
Feb 25 2016 00:56
function searchClicked() {
var searchText = $("#search-bar").val(); var searchQuary = baseurl + "?action=random" + "&format=json"; console.log(searchQuary);$.ajax({
url: searchQuary,
type: 'GET',
dataType: 'jsonp',
}).done(function(data) {
console.log(data)
})

}
Caleb Martin
@caleb272
Feb 25 2016 00:58
so i see you have to use ajax
which i don’t know how to use
alpox
@alpox
Feb 25 2016 00:58
@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 o ok thanks so much alpox @alpox Feb 25 2016 00:59 @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 thanks i will read it over Austin Thornley @AustinThornley Feb 25 2016 00:59 Can someone help me with Stand In Line? What am I doing wrong? alpox @alpox Feb 25 2016 00:59 @caleb272 You're welcome. Have a good time :-) Austin Thornley @AustinThornley Feb 25 2016 00:59 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 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 how many years have you been doing web dev alpox alpox @alpox Feb 25 2016 01:00 @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 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 @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 @alpox What can GO lang be used for? I'm not too familiar with it. alpox @alpox Feb 25 2016 01:03 @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 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 @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 ya c++ is fun by far one of my favorite languages alpox @alpox Feb 25 2016 01:05 @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 @AustinThornley : testArr.push(item); should just be arr.push(item); Caleb Martin @caleb272 Feb 25 2016 01:07 well I’m off for diner by guys take care alpox @alpox Feb 25 2016 01:07 Yup me too, finally :D Cya guys Austin Thornley @AustinThornley Feb 25 2016 01:09 @Davinw Yeah, I finally got it :P Davinw @Davinw Feb 25 2016 01:10 @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 @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 @ratishidm , your set get only needs to set it, =, not increase it in any way... :blush: ratishidm @ratishidm Feb 25 2016 01:19 @rphares thanks it worked CamperBot @camperbot Feb 25 2016 01:19 ratishidm sends brownie points to @rphares :sparkles: :thumbsup: :sparkles: :star: 2947 | @rphares | http://www.freecodecamp.com/rphares rphares @rphares Feb 25 2016 01:20 anytime~ James Sangalli @James-Sangalli Feb 25 2016 01:57 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 @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 bonfire making a person CamperBot @camperbot Feb 25 2016 02:03 Sorry, can't find a bonfire called making a person. [ Check the map? ] Andrew Schmidthuber @calicode Feb 25 2016 02:04 bonfire make a person CamperBot @camperbot Feb 25 2016 02:04 ## :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 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 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 what is the expected output? Johannah @eccentricafterglow Feb 25 2016 02:16 a boolean to check to see if a property has an object. Andrew Schmidthuber @calicode Feb 25 2016 02:17 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 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 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 // 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 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 @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 @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 @Reza7865 to answer your "why" question, dot notation functions differently than bracket notation when accessing object properties. Johannah @eccentricafterglow Feb 25 2016 02:28 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 @Davinw ahh makes sense, thnxx Norman Dela Cruz @dcnr Feb 25 2016 02:29 @eccentricafterglow you don't need a condition after an else Johannah @eccentricafterglow Feb 25 2016 02:30 oh Norman Dela Cruz @dcnr Feb 25 2016 02:30 @eccentricafterglow remove this (!(checkProp)); Johannah @eccentricafterglow Feb 25 2016 02:30 remove everyone? er, everything? okay. Davinw @Davinw Feb 25 2016 02:30 @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 thanks @calicode !! CamperBot @camperbot Feb 25 2016 02:30 eccentricafterglow sends brownie points to @calicode :sparkles: :thumbsup: :sparkles: Davinw @Davinw Feb 25 2016 02:30 @Reza7865 np! Norman Dela Cruz @dcnr Feb 25 2016 02:30 @eccentricafterglow else is like "do this if any other if doesn't trigger" CamperBot @camperbot Feb 25 2016 02:30 :star: 337 | @calicode | http://www.freecodecamp.com/calicode Norman Dela Cruz @dcnr Feb 25 2016 02:30 @eccentricafterglow it's like the default in a switch Johannah @eccentricafterglow Feb 25 2016 02:30 okay Andrew Schmidthuber @calicode Feb 25 2016 02:31 else if might have been what you were thinking of Johannah @eccentricafterglow Feb 25 2016 02:31 I’m still trying to figure out the differences between if, else, and else if. Norman Dela Cruz @dcnr Feb 25 2016 02:31 @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 and in that case it would be else if (!myObj.hastOwnProperty(checkProp)) { return not found} Reza Jafar @Reza7865 Feb 25 2016 02:32 @Davinw ahhh thanks for clarifying, makes total sense CamperBot @camperbot Feb 25 2016 02:32 reza7865 sends brownie points to @davinw :sparkles: :thumbsup: :sparkles: :star: 211 | @davinw | http://www.freecodecamp.com/davinw Davinw @Davinw Feb 25 2016 02:32 @Reza7865 Yw! Norman Dela Cruz @dcnr Feb 25 2016 02:33 @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 oooh I love these charts. I should copy these. PattyCreates @PattyCreates Feb 25 2016 02:34 Does anyone know if there's an SF room? Johannah @eccentricafterglow Feb 25 2016 02:34 Thanks dcnr! er Thanks @dcnr ! CamperBot @camperbot Feb 25 2016 02:34 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 you're welcome, thanks too! @eccentricafterglow CamperBot @camperbot Feb 25 2016 02:35 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 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 @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 This message was deleted Richard Corbett @reacorbett Feb 25 2016 02:46 so is currentVal the sum of the arrays indexes? @dcnr Norman Dela Cruz @dcnr Feb 25 2016 02:46 @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 ok. @dcnr Thanks. CamperBot @camperbot Feb 25 2016 02:48 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 @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 @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 @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 @dcnr No it was perfect. @dcnr I understand .reduce now. Norman Dela Cruz @dcnr Feb 25 2016 02:54 @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 @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 @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 animals[0]? or myArr[0] Vasily Sidorenko @vsidoren Feb 25 2016 03:04 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 This message was deleted Richard Corbett @reacorbett Feb 25 2016 03:05 @vsidoren look at singleVal = array; and ask yourself why is that there Norman Dela Cruz @dcnr Feb 25 2016 03:06 @reacorbett I dunno if this helps, but a visualizatoin William Sugandha @williamsugandha Feb 25 2016 03:06 hi all, i'm getting trouble understanding the instruction in "Exact Change" project Vasily Sidorenko @vsidoren Feb 25 2016 03:07 @reacorbett is the assignment not passing the value of array after the reduce function has run ? Richard Corbett @reacorbett Feb 25 2016 03:07 @dcnr thats awesome, yeah. William Sugandha @williamsugandha Feb 25 2016 03:07 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 Help Missing Letters CamperBot @camperbot Feb 25 2016 03:07 ## :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 Help Exact Change CamperBot @camperbot Feb 25 2016 03:08 ## :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 got it ...... duh thanks @reacorbett CamperBot @camperbot Feb 25 2016 03:09 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 @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 @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 hey guys has anyone completed "Make Object Properties Private" ? bitgrower @bitgrower Feb 25 2016 03:13 he shows what the objects created are ... Norman Dela Cruz @dcnr Feb 25 2016 03:13 @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 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 @vvang044 -- many times ... :) Vik @vvang044 Feb 25 2016 03:13 lol..... Jeremy @JeremyAntonoff Feb 25 2016 03:13 can someone point me in the right direction without giving me the answer Norman Dela Cruz @dcnr Feb 25 2016 03:13 hi @bitgrower ! :candy: :cake: bitgrower @bitgrower Feb 25 2016 03:13 hello @dcnr ... nice example, thanks for that @dcnr .. CamperBot @camperbot Feb 25 2016 03:13 bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: Norman Dela Cruz @dcnr Feb 25 2016 03:13 that ellipsis always gives off the feeling that you're unhappy :( CamperBot @camperbot Feb 25 2016 03:13 :star: 711 | @dcnr | http://www.freecodecamp.com/dcnr Norman Dela Cruz @dcnr Feb 25 2016 03:14 thanks @bitgrower ... CamperBot @camperbot Feb 25 2016 03:14 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 im confused what to do with that exercise Richard Corbett @reacorbett Feb 25 2016 03:15 @bitgrower I am understanding it a lot better. bitgrower @bitgrower Feb 25 2016 03:15 @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 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 @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 @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 @pkshreeman that's an achievement worthy of celebration :D :D bitgrower @bitgrower Feb 25 2016 03:17 @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 @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 @pkshreeman @bitgrower or pm us! eeflores @eeflores waits anxiously for LCM code ... dcnr @eeflores looks shiftily around bitgrower @bitgrower Feb 25 2016 03:19 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 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 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 @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 can anyone look at my code and tell what's wrong with it? Ryan Price @rsprice Feb 25 2016 03:28 @vvang044 sure thing! Vik @vvang044 Feb 25 2016 03:29 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 whats wrong dang there are a lot of people having a problem with this tutorial Ryan Price @rsprice Feb 25 2016 03:31 @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 raises his hang sorry let me paste the whole code Moisés Man @moigithub Feb 25 2016 03:32 @vvang044 no sum on setgear.. just set a value Vik @vvang044 Feb 25 2016 03:33 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 @vvang044 what is this exercise called on the map? Vik @vvang044 Feb 25 2016 03:34 "Make Object Properties Private" Jesus Vega @ParagonChuy Feb 25 2016 03:34 Has anybody done the Missing Letters Intermediate Algorithm? Vik @vvang044 Feb 25 2016 03:35 @moigithub sorry i missed what you said Ryan Price @rsprice Feb 25 2016 03:37 @vvang044 Vik @vvang044 Feb 25 2016 03:37 yes? Ryan Price @rsprice Feb 25 2016 03:37 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  this.setGear = function(change){ gear += change; remove + sign Ryan Price @rsprice Feb 25 2016 03:37 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 @ParagonChuy What about it? Vik @vvang044 Feb 25 2016 03:39 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 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 happy coding Ryan Price @rsprice Feb 25 2016 03:40 @vvang044 best of luck, feel free to ping me if you have any more questions Jesus Vega @ParagonChuy Feb 25 2016 03:40 @JoshFisk Am I supposed to use modulo division or am I over complicating it? Josh Fisk @JoshFisk Feb 25 2016 03:41 @ParagonChuy Overcomplicating it Jesus Vega @ParagonChuy Feb 25 2016 03:41 Dang it Josh Fisk @JoshFisk Feb 25 2016 03:41 @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 What do you mean? Josh Fisk @JoshFisk Feb 25 2016 03:42 @ParagonChuy You are talking about this one right? "Missing letters" Norman Dela Cruz @dcnr Feb 25 2016 03:43 @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 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 @ParagonChuy Okay lets double check the problem, because you are confusing me Richard Corbett @reacorbett Feb 25 2016 03:45 @dcnr got it. Andres Baltodano @Andy-colocho Feb 25 2016 03:45 hi guys Jesus Vega @ParagonChuy Feb 25 2016 03:45 Okay Josh Fisk @JoshFisk Feb 25 2016 03:45 @ParagonChuy If I give you a string like this, a b c d f Jesus Vega @ParagonChuy Feb 25 2016 03:46 yes Josh Fisk @JoshFisk Feb 25 2016 03:46 @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 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 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 @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 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 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 link to the problem page: seek and destroy Marc @wumpafruits Feb 25 2016 03:52 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 @wumpafruits that one is a little confusing Jesus Vega @ParagonChuy Feb 25 2016 03:54 @JoshFisk Still lost haha Ryan Price @rsprice Feb 25 2016 03:55 @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 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 @cramjet I can pair program with you if you'd like Josh Fisk @JoshFisk Feb 25 2016 03:56 @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 @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 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 @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 ^^ I'll look into it @rsprice thankyou cramjet @cramjet Feb 25 2016 04:00 whoops sorry i didn't get an audio notification of a response! Austin Thornley @AustinThornley Feb 25 2016 04:00 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 help Where do I belong CamperBot @camperbot Feb 25 2016 04:00 ## :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. cramjet @cramjet Feb 25 2016 04:00 @rsprice not sure how to pair Ryan Price @rsprice Feb 25 2016 04:01 @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 @qualitymanifest yes, in fact i was using arr originally then tried to go to arguments Austin Thornley @AustinThornley Feb 25 2016 04:01 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 @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 @qualitymanifest know whut, i'll go step by step. i follow what you mean Norman Dela Cruz @dcnr Feb 25 2016 04:02 @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 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 lol @rsprice Austin Thornley @AustinThornley Feb 25 2016 04:02 @dcnr Okay, thank you! CamperBot @camperbot Feb 25 2016 04:02 austinthornley sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 712 | @dcnr | http://www.freecodecamp.com/dcnr cramjet @cramjet Feb 25 2016 04:03 oh ok @qualitymanifest i'll try that. that does make immediate sense. DJ @qualitymanifest Feb 25 2016 04:03 @cramjet cool. there's more to it, but it's a good start Ryan Price @rsprice Feb 25 2016 04:03 I agree. That's a good place to start! Norman Dela Cruz @dcnr Feb 25 2016 04:05 @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 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 @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 why doesn't the above code work? Norman Dela Cruz @dcnr Feb 25 2016 04:08 @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 @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 @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 var code cramjet @cramjet Feb 25 2016 04:12 @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 I see people mess this up all the time, and for good reason: it's fairly tricky. Adi @kiniadit Feb 25 2016 04:12 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 @cramjet that sounds like a good idea ;) cramjet @cramjet Feb 25 2016 04:13 @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 and how does one get those formatted code snippets with the black background on chat? DJ @qualitymanifest Feb 25 2016 04:13 @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 anyone? Ryan Price @rsprice Feb 25 2016 04:16 !format DJ @qualitymanifest Feb 25 2016 04:17 help format CamperBot @camperbot Feb 25 2016 04:17 ## :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 Ryan Price @rsprice Feb 25 2016 04:17 Ah, much better @kiniadit ^^^^^ Adi @kiniadit Feb 25 2016 04:17 function end(str, target) { return (str.substring(-target.length,target.length) === target); } end("Bastian", "n"); cramjet @cramjet Feb 25 2016 04:17 @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 thank you! cramjet @cramjet Feb 25 2016 04:18 sorry, var thePen = arr[0]; Adi @kiniadit Feb 25 2016 04:18 @rspice any ideas why i'm getting false returned? i'm expecting a true DJ @qualitymanifest Feb 25 2016 04:18 @cramjet come on over here https://kobra.io/#/e/-KBL_Ab9hbVDccoDCycL Ryan Price @rsprice Feb 25 2016 04:21 @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 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 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 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 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 @rspice going nuts @rspice hmm so the arguments are messed up? Ryan Price @rsprice Feb 25 2016 04:27 @kiniadit do this str = 'Bastian'; str.substring(-str.length, str.length); Adi @kiniadit Feb 25 2016 04:27 @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 @kiniadit omg that is hilarious Adi @kiniadit Feb 25 2016 04:29 @rsprice i know right Ryan Price @rsprice Feb 25 2016 04:29 I know why it works I think anyway V Arun Kumar @arunvkumr Feb 25 2016 04:29 i'm trying navbar-collpase but it's not working. any help? sudheerswamy @sudheerswamy Feb 25 2016 04:29 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 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 thanks @reacorbett CamperBot @camperbot Feb 25 2016 04:30 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 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 @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 @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 // 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 @dcnr no, I haven't... haven't seen the wiki solutions! Adi @kiniadit Feb 25 2016 04:31 @rspice hmm, weird. ok. sudheerswamy @sudheerswamy Feb 25 2016 04:32 console returns 0*5 only; Ryan Price @rsprice Feb 25 2016 04:32 @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 @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 @dcnr Thanks! Looking at the wiki now (for the first time!) CamperBot @camperbot Feb 25 2016 04:32 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 @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 awesome cheers! Adi @kiniadit Feb 25 2016 04:32 @rsprice so it was just a 'false positive' of sorts. thats nuts.... Ryan Price @rsprice Feb 25 2016 04:33 @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 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 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 @rspice, i'll try that out. thanks! CamperBot @camperbot Feb 25 2016 04:35 kiniadit sends brownie points to @rspice :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for rspice Ryan Price @rsprice Feb 25 2016 04:35 @kiniadit no problem @JToddFL what's up? Jeremy @JeremyAntonoff Feb 25 2016 04:36 I just dunno where to go from here ive sat and pondered forever lol bitgrower @bitgrower Feb 25 2016 04:36 @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 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 @JToddFL that all seems reasonable Jeremy @JeremyAntonoff Feb 25 2016 04:37 im just stuck now Ryan Price @rsprice Feb 25 2016 04:37 @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 no lol Norman Dela Cruz @dcnr Feb 25 2016 04:37 @bitgrower eh there's always something to learn about, if you look for it! bitgrower @bitgrower Feb 25 2016 04:37 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 //iterate over the words in the array // at each word, compare it to the longest word // ...? // profit Jeremy @JeremyAntonoff Feb 25 2016 04:38 whenever i set a variable to array[i] though i can only get it to loop bitgrower @bitgrower Feb 25 2016 04:38 how can you split the long string you have into words ? Jeremy @JeremyAntonoff Feb 25 2016 04:38 to the first word "The" and never go on Ryan Price @rsprice Feb 25 2016 04:38 @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 @JToddFL -- then you are probably addressing it incorrectly ... Jeremy @JeremyAntonoff Feb 25 2016 04:39 @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 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 sounds like "The" is the longest word :) Jeremy @JeremyAntonoff Feb 25 2016 04:41 do i need another for loop nested? Andrew Dutton @andrew-dutton Feb 25 2016 04:41 @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 @JToddFL no way Jose @AndreWaroux did you use a functional approach? :) Jeremy @JeremyAntonoff Feb 25 2016 04:43 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 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 @bitgrower can I see your solution?? bitgrower @bitgrower Feb 25 2016 04:44 ...just make sure you understand the code ... :) Andrew Dutton @andrew-dutton Feb 25 2016 04:44 @bitgrower I could see you first few solutions... but you final one is beautiful ;) bitgrower @bitgrower Feb 25 2016 04:45 @rsprice ... most people's code can be seen by going to freecodecamp.com/<camper's name> Ryan Price @rsprice Feb 25 2016 04:45 // 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 and i do that with index[i] ? bitgrower @bitgrower Feb 25 2016 04:46 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 @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 @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 Ruby? What sorcery is this!? bitgrower @bitgrower Feb 25 2016 04:47 @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 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 is that ruby lol thanks though dc Ryan Price @rsprice Feb 25 2016 04:47 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 @dcnr thanks CamperBot @camperbot Feb 25 2016 04:48 reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 714 | @dcnr | http://www.freecodecamp.com/dcnr bitgrower @bitgrower Feb 25 2016 04:48 @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 @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 @JToddFL can you paste what you have right now? bitgrower @bitgrower Feb 25 2016 04:49 @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 Can anyone help with #230 (Profile Lookup)? Ryan Price @rsprice Feb 25 2016 04:53 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 sure Eric @Code-Eric Feb 25 2016 04:53 @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 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 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 :point_up: February 24, 2016 8:46 PM it looks like bash code to me ... Ryan Price @rsprice Feb 25 2016 04:56 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 if (index[i] >= index[i -1])? bitgrower @bitgrower Feb 25 2016 04:56 @AndreWaroux -- and if you want to see ES6 goodness ... check out @dcnr's portfolio ... Jeremy @JeremyAntonoff Feb 25 2016 04:56 WAIT not = to just > Ryan Price @rsprice Feb 25 2016 04:57 Huh? Jeremy @JeremyAntonoff Feb 25 2016 04:57 no that wouldnt work what am i thinking sudheerswamy @sudheerswamy Feb 25 2016 04:57 // 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 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 the current word sudheerswamy @sudheerswamy Feb 25 2016 04:58 // 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 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 ...that sounds promising ... Jeremy @JeremyAntonoff Feb 25 2016 04:58 i mean words[i] in his code bitgrower @bitgrower Feb 25 2016 04:58 hmmm well you have to compare something to something ... Ryan Price @rsprice Feb 25 2016 04:58 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 @bitgrower HELP please Jeremy @JeremyAntonoff Feb 25 2016 04:59 @rsprice doh ok that makes sense hold on let me try sudheerswamy @sudheerswamy Feb 25 2016 04:59 // 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 hang on, @sudheerswamy what challenge is this, @sudheerswamy Richard Corbett @reacorbett Feb 25 2016 05:00 made it to the algorithm challenges bitgrower @bitgrower Feb 25 2016 05:00 coolness @reacorbett !!! Richard Corbett @reacorbett Feb 25 2016 05:00 thanks @bitgrower CamperBot @camperbot Feb 25 2016 05:00 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 @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 @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 @bitgrower @reacorbett @JToddFL @rsprice sorry I had to step away a bit, thank you too CamperBot @camperbot Feb 25 2016 05:02 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 is that a fcc challenge, @sudheerswamy ? can you link me to it ? Norman Dela Cruz @dcnr Feb 25 2016 05:03 @bitgrower it's a bastardized bash code lol bitgrower @bitgrower Feb 25 2016 05:03 hahahahaha ... sudheerswamy @sudheerswamy Feb 25 2016 05:03 Jeremy @JeremyAntonoff Feb 25 2016 05:04 @rsprice Thank you so much CamperBot @camperbot Feb 25 2016 05:04 jtoddfl sends brownie points to @rsprice :sparkles: :thumbsup: :sparkles: :star: 357 | @rsprice | http://www.freecodecamp.com/rsprice bitgrower @bitgrower Feb 25 2016 05:04 you got it @JToddFL ???? AWESOME SAUCE .. Congrats !!! Jeremy @JeremyAntonoff Feb 25 2016 05:04 and thank you @bitgrower CamperBot @camperbot Feb 25 2016 05:04 jtoddfl sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star: 635 | @bitgrower | http://www.freecodecamp.com/bitgrower bitgrower @bitgrower Feb 25 2016 05:05 @sudheerswamy -- so ... look at the example they provide for you ... Ryan Price @rsprice Feb 25 2016 05:05 @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 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 see what they are doing with the variable changed and calling the function change ... excellent, @JToddFL ... Ryan Price @rsprice Feb 25 2016 05:06 @JToddFL how many times do you use that total variable? Jeremy @JeremyAntonoff Feb 25 2016 05:06 i know i just noticed that lol deleted it Ryan Price @rsprice Feb 25 2016 05:06 ;) @JToddFL nicely done! bitgrower @bitgrower Feb 25 2016 05:07 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 thanks again! Emil Aasa @emilaasa Feb 25 2016 05:07 Found an ES6 functional solution if you want to see it bitgrower @bitgrower Feb 25 2016 05:07 for which challenge, @emilaasa Emil Aasa @emilaasa Feb 25 2016 05:07 longestword bitgrower @bitgrower Feb 25 2016 05:07 ahhh ... Jeremy @JeremyAntonoff Feb 25 2016 05:08 not sure what es6 means lol bitgrower @bitgrower Feb 25 2016 05:08 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 Thats a good idea @bitgrower bitgrower @bitgrower Feb 25 2016 05:09 :bow: Jeremy @JeremyAntonoff Feb 25 2016 05:09 what version does freecodecamp use bitgrower @bitgrower Feb 25 2016 05:09 it will accept ES6 syntax ... but it accepts earlier versions as well ... Jeremy @JeremyAntonoff Feb 25 2016 05:10 am i doing myself a disservice by learning an older version of javascript with freecodecamp Charles Chung @chulmo Feb 25 2016 05:10 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 and stuff which runs under es5 is likely going to run under es6 ... @JToddFL -- absolutely NOT ... Jeremy @JeremyAntonoff Feb 25 2016 05:10 ok thanks @bitgrower CamperBot @camperbot Feb 25 2016 05:10 jtoddfl sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :warning: jtoddfl already gave bitgrower points bitgrower @bitgrower Feb 25 2016 05:10 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 @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 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 it's always best to check for browser compatibility Jeremy @JeremyAntonoff Feb 25 2016 05:12 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 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 CamperBot @camperbot Feb 25 2016 05:13 ## :point_right: js resources [wiki] ### Tutorials ### References Find javascript libraries at http://jster.net See Also: :loop: Quick JS | :watch: Challenges | :wrench: Exercises | :clipboard: Editors | :newspaper: Blogs | :books: Books Jeremy @JeremyAntonoff Feb 25 2016 05:13 nice ill deff bookmark these bitgrower @bitgrower Feb 25 2016 05:13 I think you might find JavaScript for Cats very helpful @JToddFL Norman Dela Cruz @dcnr Feb 25 2016 05:13 wish there's a javascript the hard way series too Jeremy @JeremyAntonoff Feb 25 2016 05:14 me too i used that for python and then switched to javascript half way through ichirped @ichirped Feb 25 2016 05:14 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 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 @bitgrower I like devdocs coz it's easier to search with bitgrower @bitgrower Feb 25 2016 05:16 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 @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 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 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 @sagit2002 plz use this help format CamperBot @camperbot Feb 25 2016 05:18 ## :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 Norman Dela Cruz @dcnr Feb 25 2016 05:19 @sagit2002 examine your return strings closely bitgrower @bitgrower Feb 25 2016 05:19 @dcnr -- w3schools has a less than positive rep in some circles ... Norman Dela Cruz @dcnr Feb 25 2016 05:19 @bitgrower yeah that's why many newbies go there.. :/ bhagwant @sagit2002 Feb 25 2016 05:20 @dcnr Ya they seems to be alright Norman Dela Cruz @dcnr Feb 25 2016 05:20 @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 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 the most massive, dwarf-star-heavy props to @qualitymanifest for all the super patient help!! bitgrower @bitgrower Feb 25 2016 05:21 well ... I don't think that gets @qualitymanifest brownie points ... cramjet @cramjet Feb 25 2016 05:21 @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 cramjet sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles: :star: 1000 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest bitgrower @bitgrower Feb 25 2016 05:21 ahh thanks does, though ... LOL ... bhagwant @sagit2002 Feb 25 2016 05:21 @dcnr thanks it was a ! problem CamperBot @camperbot Feb 25 2016 05:21 sagit2002 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 715 | @dcnr | http://www.freecodecamp.com/dcnr DJ @qualitymanifest Feb 25 2016 05:21 @cramjet haha :+1: Norman Dela Cruz @dcnr Feb 25 2016 05:21 @sagit2002 right :D thanks too! CamperBot @camperbot Feb 25 2016 05:21 dcnr sends brownie points to @sagit2002 :sparkles: :thumbsup: :sparkles: :star: 206 | @sagit2002 | http://www.freecodecamp.com/sagit2002 bitgrower @bitgrower Feb 25 2016 05:21 ooooh ... 1000 -- congrats to the land of 4 figures, @qualitymanifest DJ @qualitymanifest Feb 25 2016 05:22 @bitgrower tanks whoa @username tanks CamperBot @camperbot Feb 25 2016 05:22 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 LOL DJ @qualitymanifest Feb 25 2016 05:22 lol Norman Dela Cruz @dcnr Feb 25 2016 05:22 tax @qualitymanifest CamperBot @camperbot Feb 25 2016 05:22 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 see that DJ @qualitymanifest Feb 25 2016 05:22 palindrome brownies Norman Dela Cruz @dcnr Feb 25 2016 05:22 thanks @obama CamperBot @camperbot Feb 25 2016 05:22 dcnr sends brownie points to @obama :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for obama bitgrower @bitgrower Feb 25 2016 05:22 hah ... but tanks don't work for me ?!? Norman Dela Cruz @dcnr Feb 25 2016 05:23 tax @bitgrower CamperBot @camperbot Feb 25 2016 05:23 dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :warning: dcnr already gave bitgrower points Norman Dela Cruz @dcnr Feb 25 2016 05:23 help file tax returns CamperBot @camperbot Feb 25 2016 05:23 no wiki entry for: file tax returns Norman Dela Cruz @dcnr Feb 25 2016 05:23 :/ DJ @qualitymanifest Feb 25 2016 05:23 dont remind me Norman Dela Cruz @dcnr Feb 25 2016 05:24 almost time! Raghuram @Raghuram1994 Feb 25 2016 05:26 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 @Raghuram1994 try removing the = in total <= myArr.length Raghuram @Raghuram1994 Feb 25 2016 05:26 got it thak you @dcnr CamperBot @camperbot Feb 25 2016 05:26 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 array indices are always $n-1$ ! Matios @MatiosTV Feb 25 2016 05:30 Has any one had trouble with the Local Scope and Functions lesson in Javascript? Norman Dela Cruz @dcnr Feb 25 2016 05:31 @MatiosTV oh have you declared myVar? Matios @MatiosTV Feb 25 2016 05:31 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 @MatiosTV if you have, then you need to follow what that comments say to pass yeah Matios @MatiosTV Feb 25 2016 05:32 @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 @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 @dcnr Lmao. Wow. Thank you so much. CamperBot @camperbot Feb 25 2016 05:33 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 @MatiosTV yeah often times a refresh solves many problems! Matios @MatiosTV Feb 25 2016 05:34 Ahahahahahahaha effing RIDICULOUS!! bitgrower @bitgrower Feb 25 2016 05:36 well ... see youse all manana ... g'night ... DJ @qualitymanifest Feb 25 2016 05:36 :wave: Raghuram @Raghuram1994 Feb 25 2016 05:38 can any one Explain Nesting For Loops ? Caleb Martin @caleb272 Feb 25 2016 05:38 what do you need explained about it Norman Dela Cruz @dcnr Feb 25 2016 05:38 g'night @bitgrower buhbyes Raghuram @Raghuram1994 Feb 25 2016 05:39 This message was deleted This message was deleted This message was deleted This message was deleted Eduardo Garcia @eagarcia8 Feb 25 2016 05:41 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

@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
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:47
@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
@eagarcia8 here's the one for the front end https://gitter.im/FreeCodeCamp/HelpFrontEnd
DJ
@qualitymanifest
Feb 25 2016 05:48
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
@eagarcia8 this room's actually more focused on the challenges rather than using libs like jquery
Eduardo Garcia
@eagarcia8
Feb 25 2016 05:49
@dcnr Gotcha, thanks for the link
CamperBot
@camperbot
Feb 25 2016 05:49
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
@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
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
eagarcia8 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: eagarcia8 already gave dcnr points
DJ
@qualitymanifest
Feb 25 2016 05:51
@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
@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

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
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:00
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
@dcnr thanks
CamperBot
@camperbot
Feb 25 2016 06:00
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
@vsidoren because 1 - 5 is smaller than 6
Norman Dela Cruz
@dcnr
Feb 25 2016 06:01
@vsidoren because of this var newArray = oldArray;
Richard Corbett
@reacorbett
Feb 25 2016 06:01
did the first alg. challenge on my own! !!!
Caleb Martin
@caleb272
Feb 25 2016 06:01
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
@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
@dcnr thanks. Im proud of it.
CamperBot
@camperbot
Feb 25 2016 06:02
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
@reacorbett as you should be :D hahah
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:03
oh so that part is returning the original array @dcnr
Norman Dela Cruz
@dcnr
Feb 25 2016 06:03
@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
keeps getting me .... @dcnr thanks
CamperBot
@camperbot
Feb 25 2016 06:04
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
@vsidoren that part gets a lot of people!
Hereshk
@Hereshk
Feb 25 2016 06:15
  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
@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
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
@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
@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
ok I understand :) thanks @qualitymanifest
CamperBot
@camperbot
Feb 25 2016 06:22
hereshk sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1002 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Feb 25 2016 06:23
:+1:
Vinit Mav
@vinitm
Feb 25 2016 06:25
it has good explanation
Vasily Sidorenko
@vsidoren
Feb 25 2016 06:27
thanks @vinitm theres a lot there
CamperBot
@camperbot
Feb 25 2016 06:27
vsidoren sends brownie points to @vinitm :sparkles: :thumbsup: :sparkles:
:star: 317 | @vinitm | http://www.freecodecamp.com/vinitm
PattyCreates
@PattyCreates
Feb 25 2016 06:44
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
@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
a queue makes sense in order
But, I'm not sure as to what the prompt is asking?
function queue(arr, item) {
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
@PattyCreates, queue is a function not a variable.
PattyCreates
@PattyCreates
Feb 25 2016 07:05
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
@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
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
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
@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
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.