These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Apr 2016
Puvendran Pillay
@puven12
Apr 10 2016 00:00
@bitgrower @khaduch got reference error
Ken Haduch
@khaduch
Apr 10 2016 00:00
@puven12 - please post your updated code?
Carlos Pulido
@carlosfrontend
Apr 10 2016 00:00
@bitgrower Not Where You Start From :(
bitgrower
@bitgrower
Apr 10 2016 00:00
on which line, @puven12 ?
Puvendran Pillay
@puven12
Apr 10 2016 00:01
got it guys
bitgrower
@bitgrower
Apr 10 2016 00:01
can you post your code, @carlospulido ?
Puvendran Pillay
@puven12
Apr 10 2016 00:01
i changed the myTest to the other name
@bitgrower @khaduch thanks
CamperBot
@camperbot
Apr 10 2016 00:01
puven12 sends brownie points to @bitgrower and @khaduch :sparkles: :thumbsup: :sparkles:
:star: 972 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 901 | @khaduch | http://www.freecodecamp.com/khaduch
bitgrower
@bitgrower
Apr 10 2016 00:03
hmm ... is that a new challenge? I'm not pulling up a challenge by that name ...
Carlos Pulido
@carlosfrontend
Apr 10 2016 00:05
function largestOfFour(arr) {
  var result =[];
  for(var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length;j++){
      result.push(Math.max(arr[i][j]));
    }

  }
  return result;
} 

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Ken Haduch
@khaduch
Apr 10 2016 00:06
@Nolo900 - you should not have return statements in the middle of the switch / caseconstruct.... that meanst hat you are never going down to the place in the code where you are calculating the Bet or Hold results...
@puven12 - great! You're welcome! Make sure to keep an eye on that function name change - always compare what the test is telling you it is looking for. (I opened an issue on this to put an initial test in there for the proper function names, but I'm sure there hasn't been time to look at it. But this is a fairly recent change, you'll even see it if you have completed challenges that pre-date the name changes!) Good luck!
Austin Miles
@Nolo900
Apr 10 2016 00:08
@khaduch Oh snap, you're right. Solved, thx!
CamperBot
@camperbot
Apr 10 2016 00:08
nolo900 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 902 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 10 2016 00:14
@carlospulido - at least one problem is that taking Math.max() of a single value is probably not going to get the desired answer. And you should only obtain one (the largest) number from each of the sub-arrays. So you have to change the way your inner loop is processing the numbers to make sure that you look at all 4 values, selecting the largest of the four, and then pushing that to the result...
Puvendran Pillay
@puven12
Apr 10 2016 00:16
guys do you know where can i get good cheatsheets for js?
i am always forgetting the syntax
can you please email to me?
bitgrower
@bitgrower
Apr 10 2016 00:18
@puven12 -- I would recommend creating your own cheatsheets as you go along ... this will help you with the syntax, especially since you will be re-writing the syntax in a way that makes sense to you, with your notes, and the repetition will help re-enforce your knowledge ...make it stick better ..
Christian
@cenamorado1
Apr 10 2016 00:19
can some one help with the "golf code " assignment?
Puvendran Pillay
@puven12
Apr 10 2016 00:19
oh i see @bitgrower good idea!
Ramana Venkata
@vramana
Apr 10 2016 00:19
@puven12 Write more programs. It's doesn't matter if you have to lookup syntax as long as you are able solve the problem.
Puvendran Pillay
@puven12
Apr 10 2016 00:19
i will start creating it then. if finish it i will share it to you guys
@vramana the problem is that the programs would work without the correct syntax
Ramana Venkata
@vramana
Apr 10 2016 00:20
@cenamorado1 What have you tried ??
@puven12 Get your code reviewed by someone else. That way you can find out your mistakes and may be learn other ways to solve too.
Christian
@cenamorado1
Apr 10 2016 00:22
well for the second one I put else if (4 > 2){
return "Eagle"; and its not working
Puvendran Pillay
@puven12
Apr 10 2016 00:22
@vramana who can i ask? im the only one in my circle of friends
who is coding
Ramana Venkata
@vramana
Apr 10 2016 00:23
@puven12 You can ask here
Puvendran Pillay
@puven12
Apr 10 2016 00:23
wow ok @vramana
Justin
@daemedeor
Apr 10 2016 00:23
@vramana i like Op!
Christian
@cenamorado1
Apr 10 2016 00:23
I'm not sure what the list of strokes is telling me to do
Ramana Venkata
@vramana
Apr 10 2016 00:33
@cenamorado1 It is similar to problem where I pass a number to function and it will return me whether it's "even" or "odd". Here instead of one variable there are two variables and more conditions. Does that help??
Ken Haduch
@khaduch
Apr 10 2016 00:33
@cenamorado1 - they basically have a table that tells you what you need to do by way of comparing the number of strokes to the "par", which is the expected number of strokes. So you just make a set of if ... else if ... else... statements that implement the tests that are in that table.
Andy Roush
@AndyRoush
Apr 10 2016 00:39
I need help with this queue thing. I created the fucntion, now what do I do?
"Write a function nextInLine 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 nextInLine function should then return the element that was removed."
function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Charlotte N.
@clnquacky
Apr 10 2016 00:39
Can anyone help me with this.

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;
this.getGear = function(){
return gear;
};
this.setGear = function() {
return (gear-1);
};
};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);
myBike.setGear(3);
myBike.getGear(1);

Andy Roush
@AndyRoush
Apr 10 2016 00:41
I tried nextInLine.push("item"); but is says nextInLine.push is not a function.
Charlotte N.
@clnquacky
Apr 10 2016 00:41
I am supposed to have a private property called gear then 2 public methods.
jiuhua xu
@xujiuhua
Apr 10 2016 00:42
@carlospulido do you have get the Largest Numbers in Arrays?
Charlotte N.
@clnquacky
Apr 10 2016 00:42
It is in the Make Object Properties Private.
Ken Haduch
@khaduch
Apr 10 2016 00:43

@AndyRoush - are you familiar with the concept of a "Queue" as a computer programming data structure? Basically, it is a first-in / first-out way of processing items. You can think of it in a similar way to a bank teller line - the first person in line goes to the next teller, a new person coming in goes to the back of the queue.

In a queue data structure, the same type of action is taken. In this case, an Array is being used. A new item is added to the highest-numbered end of the array, and when an item is removed, it is removed from the lowest numbered end. You just need to use the Array methods that insert an element at the high-numbered end of the array, and remove it from the low-numbered end of the array.

@AndyRoush - the instructions tell you Write a function nextInLine 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 nextInLine function should then return the element that was removed.
So you add the number to the end (the highest-numbered index) with an array method that does that, and then remove the lowest-numbered indexed value and return that...

@AndyRoush - I see this comment:

I tried nextInLine.push("item"); but is says nextInLine.push is not a function.

You are supposed to use the arr argument (which is an array) and push onto that variable...

Andy Roush
@AndyRoush
Apr 10 2016 00:46
@khaduch Ok that makes sense. So it says to add "THE" number to the end of the array, then remove the first element. What number am I supposed to use? All I see in the function is (arr) and (item). I don't see any numbers
Ken Haduch
@khaduch
Apr 10 2016 00:47
@AndyRoush - the description says: ... and a number (item) as arguments... - that means that the number is being passed to the function and associated with the variable (function arguments are variables to be used in the function's code) item.
Chris Cullen
@123xylem
Apr 10 2016 00:49
Hey can some1 help me with the counting card game?
Ken Haduch
@khaduch
Apr 10 2016 00:49
you can look at the example function call and see that they are passing an array, and a number to the function. Within the function, item is the number...
Chris Cullen
@123xylem
Apr 10 2016 00:49
Im close but missing something...
Elijah
@Elijahhh
Apr 10 2016 00:50
@123xylem Ooo yea I have the same problem, and I think my the bigest problem I dont understand card games (
Ken Haduch
@khaduch
Apr 10 2016 00:50
@123xylem - you are supposed to return those value + action results back to the function caller, not just print them to the console.log
Andy Roush
@AndyRoush
Apr 10 2016 00:52
@khaduch Ken I really appreciate the thorough explanation, and I am sure this is super basic stuff but for some reason I am just not getting it at all.... I have been staring at this for like 3 days and this is the third time I have been on this chat asking for help. Not gonna lie I feel pretty dumb and discouraged.
Chris Cullen
@123xylem
Apr 10 2016 00:55
@khaduch so could I just say return count + "Bet"
V Arun Kumar
@arunvkumr
Apr 10 2016 00:56

@123xylem case doesn't work like.
case 2, 3, 4, 5, 6: you have use then like..

case 2:
case 3:
case 4:
...
count+=1;
break;

and you have to return the result like -3 Hold. which you will not get using console.log.

Andy Roush
@AndyRoush
Apr 10 2016 00:56
So I have and array and an item, but where are the numbers?? The test setup shows 1-5. Is that like a default array? How do I know what numbers to use? is 1-5 standard?
Chris Cullen
@123xylem
Apr 10 2016 00:58
@arunkumrv Yea I thoiught so, but when i did case1 do this case 2 do this BREAK it said it expected a break after each case
V Arun Kumar
@arunvkumr
Apr 10 2016 00:59
@123xylem when you use case with comma's like case 2, 3, 4, 5, 6: this will always takes the last value i.e 6.
Ken Haduch
@khaduch
Apr 10 2016 00:59

@AndyRoush - not to worry... There is a picture at this wikipedia link, showing the representation of a queue. https://en.wikipedia.org/wiki/Queue_%28abstract_data_type%29. The idea is that new elements are added at the back of the queue (as I said, similar to a bank teller line, but in a computer program it might be keeping track of events to be processed, "print queues" are a term that you might be familiar with, the first print job to be requested goes first, the second goes section, etc.) You can get a picture of this in terms of an array looking like this, with the print jobs name "job1", "job2", etc.

var printQueueArray = [ "job1", "job2", "job3" ];

so if a "job4" comes in, it would be "pushed" onto the end of the queue (array) with code like printQueueArray.push("job4"); and the array would then be:

var printQueueArray = [ "job1", "job2", "job3", "job4" ];

Now, say that the printer is ready to print the jobs, there is a software driver that will look at the print queue and take the first job to send to the printer. It will take "job1", and use code like var printJob = printQueueArray.shift();, the printJob variable would then have the value "job1", and the queue array would look this:

var printQueueArray = [ "job2", "job3", "job4" ];

So that is the basic action of the queue. there are hints in there about how to solve this challenge...

Chris Cullen
@123xylem
Apr 10 2016 01:01
@arunkumrv why is it saying it expecxted break after each case even thought they have the same action associated?
Ken Haduch
@khaduch
Apr 10 2016 01:01
@AndyRoush - but don't be afraid to ask again... I know these concepts can be counter-intuitive, many people get stuck on this particular challenge!
Andy Roush
@AndyRoush
Apr 10 2016 01:03
@khaduch Again Ken, I really appreciate the thorough explanations! I will continue to work on this, and a lot of what you said makes sense. If I have any more questions I will let you know!
@khaduch thanks
CamperBot
@camperbot
Apr 10 2016 01:03
andyroush sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 903 | @khaduch | http://www.freecodecamp.com/khaduch
V Arun Kumar
@arunvkumr
Apr 10 2016 01:03

@123xylem break is to used to break the switch statement.. but it's not mandatory to write break after every case. if you take this example.

val = 1;
switch(val){
case 1: console.log("1");
break;
case 2: console.log("2");
break;
}

:point_up_2: the above code will print "1".

val = 1;
switch(val){
case 1: console.log("1");
case 2: console.log("2");
break;
}

:point_up_2: the above code will print "12".

zico
@zico0o
Apr 10 2016 01:03
[console.log(nextInLine(testArr, 10)); // Modify this line ]
how to modify this line to make my code return the removed element from the testarr ??
hjernefrys
@hjernefrys
Apr 10 2016 01:03
Hi! I'm having some problems with the Nesting For Loops challenge…
V Arun Kumar
@arunvkumr
Apr 10 2016 01:04
@123xylem break is not mandatory to use if multiple case statement has same operation.
Chris Cullen
@123xylem
Apr 10 2016 01:04
I got it
I just use case1:
case2:
answer ="blah";
break
Charlotte N.
@clnquacky
Apr 10 2016 01:04
This message was deleted
CamperBot
@camperbot
Apr 10 2016 01:04
no wiki entry for: with make object properties private pleasevar bike function only change code below this linevar gear thisgetgear functionchange return gear 3 thissetgear function return gear5 var mycar new carvar mybike new bikemybikegetgear4mybikesetgear3mybikegetgear1
V Arun Kumar
@arunvkumr
Apr 10 2016 01:05
@123xylem are you missing a ; in break?
hjernefrys
@hjernefrys
Apr 10 2016 01:05
the best/worst idea I got so far… ''' for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr[i].length; j++){
var test = [j];
var x = test * [j];'''
CamperBot
@camperbot
Apr 10 2016 01:05
:bulb: to format code use backticks! ``` more info
Charlotte N.
@clnquacky
Apr 10 2016 01:05
Help needed with Make Object Properties Private Please.
CamperBot
@camperbot
Apr 10 2016 01:05
no wiki entry for: needed with make object properties private please
Ken Haduch
@khaduch
Apr 10 2016 01:05

@AndyRoush

So I have and array and an item, but where are the numbers?? The test setup shows 1-5. Is that like a default array? How do I know what numbers to use? is 1-5 standard?

I answered this already - are you still confused about this? The function call, which you can see in the editor panel and in the tests listing looks like this: nextInLine([5,6,7,8,9], 1); the first argument is an array - it could be a literal array as in this example, or it could be a variable name that represents an array. The second argument is 1, which is accessible in the function as the variable item - the function arguments take the values in order as they are used in the function invocation parentheses...

Charlotte N.
@clnquacky
Apr 10 2016 01:05

var Bike = function() {

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

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);
myBike.setGear(3);
myBike.getGear(1);

Not sure what I am doing wrong. I have changed this a couple times.
Ken Haduch
@khaduch
Apr 10 2016 01:06
@clnquacky - are you getting help? let me look up the challenge to refresh. How is what you are doing matching up with the tests?
V Arun Kumar
@arunvkumr
Apr 10 2016 01:06
@123xylem space between case and value.. :smile: like case 1:
Chris Cullen
@123xylem
Apr 10 2016 01:06
@arunkumrv This bit is working now its just geting my return/output to run properly
hjernefrys
@hjernefrys
Apr 10 2016 01:06
´´´
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr[i].length; j++){
var test = [j];
var x = test * [j];
´´´
Charlotte N.
@clnquacky
Apr 10 2016 01:07
@khaduch I have matched up the first three of the tests.. but when it is coming to getting the correct numbers to pass, I am struggling.
sekoku
@sekoku
Apr 10 2016 01:07
@clnquacky I'm running into the same issue and resetting the code doesn't have anything outputted on testing the default to get a clue.
zico
@zico0o
Apr 10 2016 01:07

function nextInLine(arr, item) {
// Your code here
arr.push (item);
arr.shift(item);
return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
any help to make this code run correctly ????

hjernefrys
@hjernefrys
Apr 10 2016 01:07
sorry for the formatting, still learning here… can anyone help with this. Multiplying nested arrays…
sekoku
@sekoku
Apr 10 2016 01:08
I mean it seems like you want to copy the method above the example and then drop "this" to make it private. Throwing in the pass examples as replacements. But shrug
Charlotte N.
@clnquacky
Apr 10 2016 01:08
@sekoku I have even tried different versions to try to get it to pass
Jason
@BoilingOil
Apr 10 2016 01:08
class DayItem extends Component {
  render() {
    return (
      <Text style={this.style()}>
        {this.props.day}
      </Text>
    );
  }
  style() {
    return ({
      color: this.color(),
      //fontWeight: this.fontWeight(),
      fontSize: this.fontSize(),
      lineHeight: this.lineHeight(),
    });
  }
  color() {
   return 'rgba(0, 0, 0, ' + 1 / this.props.daysUntil + ')';
  }
  fontWeight() {
    var weight = 7 - this.props.daysUntil;
    return weight * 100;
  }
  fontSize() {
    return 60 - 6 * this.props.daysUntil;
  }
  lineHeight() {
    return 70 - 4 * this.props.daysUntil;
  }
}
V Arun Kumar
@arunvkumr
Apr 10 2016 01:08
@hjernefrys for formatting..
```js [shift+enter] <your code> [shift+enter] ```
sekoku
@sekoku
Apr 10 2016 01:09
@clnquacky Yeah, I'm stuck on it myself with no means of "grock"ing it.
Jason
@BoilingOil
Apr 10 2016 01:09
now, my rgba return tells me it can't be infinity, so i'm guessing this is an issue with daysUntil?
sekoku
@sekoku
Apr 10 2016 01:09
The previous stuff was simple to get because you basically copied their object.property example code now they're throwing in the functions while not declaring privates in the example before it beyond the variable.
The wiki article helps kinda but...
V Arun Kumar
@arunvkumr
Apr 10 2016 01:10
@123xylem now you have to return somthing like.. -3 Hold where -3 is value of count and Hold is a string, both seperated with a single space.
Charlotte N.
@clnquacky
Apr 10 2016 01:10
I know what you mean..
bitgrower
@bitgrower
Apr 10 2016 01:11
@clnquacky -- you are to create a Bike "constructor", pretty much using the Car constructor as a "sort of" template ... the primary difference is exactly what the functions you write do, in comparison to what the functions (aka methods) of the Car Object
Chris Cullen
@123xylem
Apr 10 2016 01:11
Im using this after my cases... Any idea why it doesnt work? if (count >0) {return count +" Bet";}
else if (count <= 0) {return count +" Hold";}
hjernefrys
@hjernefrys
Apr 10 2016 01:11
 for(var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length; j++){
      var test = [j];
      var x = test * [j];
@arunkumrv thanks
CamperBot
@camperbot
Apr 10 2016 01:11
hjernefrys sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 436 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Charlotte N.
@clnquacky
Apr 10 2016 01:12
@bitgrower I tried that too.. ie... using for setGear .. to return gear - 1;
bitgrower
@bitgrower
Apr 10 2016 01:12
setGear simply takes a value passed in as a parameter and uses it to set the local variable gear to the value provided in the parameter ...
setGear doesn't need to return anything; getGear does, though ..
V Arun Kumar
@arunvkumr
Apr 10 2016 01:13
@123xylem paste you code again.. i just tried and it works :smile:
Ken Haduch
@khaduch
Apr 10 2016 01:13

@clnquacky - ok... let me look at your code. I think that the problem is that you are trying to do too much with the setGear and getGear functions. The intent of those functions is to provide a method to set the value of the gear variable within the object, and then get should return the current value of the gear variable. (These types of functions are known as "setters" and "getters", you might hear this term sometime...) So what should really happen is that the value that is passed into the setGear should just be stored unchanged in the "private" variable gear. And the getGear method should just return the current value. The tests indicate that setting the value to 4, and then getting the value should return "4". No changes, other than the internal value of the gear variable.

Let me know if you have further questions or problems?

Charlotte N.
@clnquacky
Apr 10 2016 01:14
so setGear should then make gear = (myBike.setgear) ?
bitgrower
@bitgrower
Apr 10 2016 01:14
what's the corresponding line in the Car constructor ?
Chris Cullen
@123xylem
Apr 10 2016 01:15
@arunkumrv Thanks!!! Im a genius just my cpu letting me down!
CamperBot
@camperbot
Apr 10 2016 01:15
123xylem sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 437 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 10 2016 01:15
@123xylem :+1: you're welcome
@hjernefrys is that product of elem in arrays?
hjernefrys
@hjernefrys
Apr 10 2016 01:17
yes, nested arrays e.g [[1,2,3], [1,2], [3,4]]
bitgrower
@bitgrower
Apr 10 2016 01:17

(the corresponding line for the Car Constructor is "accelerate" .. ;) it's not setting the speed, but it's using a parameter to alter the speed ..

so ... you want to write something like ...

this.setGear = function (newGear) { ...

Charlotte N.
@clnquacky
Apr 10 2016 01:18
hhmm... Let me try... Still not sure I am understanding..
Ken Haduch
@khaduch
Apr 10 2016 01:20

@clnquacky

so setGear should then make gear = (myBike.setgear) ?

That is not exactly making sense to me... Let me try another explanation...

There is a variable that you have declared var gear; It is a "private" variable, as they are trying to instruct you about. The only way to access this from outside the object is through these setGear and getGear methods. A call to the setGear method, as .setGear(5); should result in the value of the function argument, 5 in this case, being stored into the gear... so you shoudl have some code within the .setGear() method that look something like gear = function_argument_name;

It is very similar to any other function call and argument - within the function's argument list, you have access to the value that was passed in. You just use the argument name to perform the action, as described above...

@bitgrower - :car: :warning: ...
Andy Roush
@AndyRoush
Apr 10 2016 01:21
@khaduch Hey Ken, so I pushed the 6 in, and took the 1 out like it told me, but it wont let me pass. Did I still do something wrong?
function nextInLine(arr, item) {
  // Your code here
  arr.push(6);
  var nextInLine = arr.shift(1);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
bitgrower
@bitgrower
Apr 10 2016 01:22
lol ... yeah ... I think I know what you are saying ... @khaduch
@AndyRoush -- you are to use the value in item, not provide a literal value ...
Andy Roush
@AndyRoush
Apr 10 2016 01:23
see when you say the value IN item... isn't item just... item? @bitgrower
bitgrower
@bitgrower
Apr 10 2016 01:23
(and you'll need to do some other things, as well ... )
V Arun Kumar
@arunvkumr
Apr 10 2016 01:23
@hjernefrys alright.. so what you have to do is multiply all elems of arrays.. you loops are good.
  • Here are somethings you need to take case of.. create a variable outside the for loops so that they are global to for loops, in your code when you declare test and x they don't exist outside the for loop because they are in for loop scope..
  • To access the elems of array you use this syntax arrayName[index-value]. same goes for 2d-array. arrayName[subarray-index][subarray's-elem-index]..
    for example.. take this array arr = [[1,2],[3,4]].. here
    arr[0] is [1,2] and a[0][0] is 1. and arr[1] is [3,4] and arr[1][0] is 3.
bitgrower
@bitgrower
Apr 10 2016 01:23
item is a variable containing a number
Charlotte N.
@clnquacky
Apr 10 2016 01:25

var Bike = function() {

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

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(4);
myBike.setGear(3);
myBike.setGear(1);

ARG... I am still not understanding apparently :(
bitgrower
@bitgrower
Apr 10 2016 01:25

so when you do arr.push(item);

your array doesn't look like [1,2,3,4,5,item] it looks like

[1,2,3,4,5,6] // if item contains the number 6

Ken Haduch
@khaduch
Apr 10 2016 01:25
@AndyRoush - you missed the point about using the item function argument, which is the way that you have access to the number ("6" in this case). So instead of using "6" in your function code, you use "item", which makes the function reusable for other values besides "6"... And there is another problem...
you do not want to do this: var nextInLine = arr.shift(1); nextInLine is the name of your function. And you do not want to return item. you want to return the value that you shift out of the array. So something like return arr.shift();
Andy Roush
@AndyRoush
Apr 10 2016 01:25
I like flying through these lessons, and I also like doing these tests because it really shows me how much I actually dont know lol
V Arun Kumar
@arunvkumr
Apr 10 2016 01:25
@hjernefrys your for loop is used for sub-arrays and j loop is used for elems of that sub array.. you need to use the syntax like arrayName[index1][index2] index1 is for subarray and index 2 is for elems in that subarray.
bitgrower
@bitgrower
Apr 10 2016 01:25
you may want to review the challenges just previous to StandInLine, which go into the various array functions of push pop shift unshift ...
Ken Haduch
@khaduch
Apr 10 2016 01:26
:walking: is good for you.
hjernefrys
@hjernefrys
Apr 10 2016 01:26
thanks @arunkumrv I got it to work now!
CamperBot
@camperbot
Apr 10 2016 01:26
hjernefrys sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: hjernefrys already gave arunkumrv points
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:27

Hey i cant thing have the numbers. These are the requirements.
You should use the || operator once
You should only have one if statement
testLogicalOr(0) should return "Outside"
testLogicalOr(9) should return "Outside"
testLogicalOr(10) should return "Inside"
testLogicalOr(15) should return "Inside"
testLogicalOr(19) should return "Inside"
testLogicalOr(20) should return "Inside"
testLogicalOr(21) should return "Outside"
testLogicalOr(25) should return "Outside"

I cant get testLogicalOr(9) should return "Outside"

This is the javascript

function testLogicalOr(val) {
  // Only change code below this line

  if (val > 20 || val < 9) {
    return "Outside";
  }
  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
V Arun Kumar
@arunvkumr
Apr 10 2016 01:27
:+1:
ManBearPigg
@ManBearPigg
Apr 10 2016 01:27
I downloaded node-v4.4.2............tar.gz, I unpacked that, now I can't figure out how to install.
bitgrower
@bitgrower
Apr 10 2016 01:27
@AndyRoush -- then you'll know how to pass tests ... it's important to think about the actual problem...including how you might actually extend what the code odes, or how to make it a more general solution ... the tests are helpful, but far from comprehensive ...
aren't you supposed to do that on cloud9, @ManBearPigg ?
ManBearPigg
@ManBearPigg
Apr 10 2016 01:28
I can see node and npm in /bin and everything, but it's not installed
V Arun Kumar
@arunvkumr
Apr 10 2016 01:28
@ZctrapCoding reverse the conditions in if statement..
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:28
Let me try that hold on
Ken Haduch
@khaduch
Apr 10 2016 01:28

@clnquacky - this:

this.setGear = function(newGear) {
return newGear;

does not set the value of the gear variable, which is the only thing that it should do! setGear means to "set the value of gear to some value that is being passed in as the function argument"... so you have to say gear = .... (I just don't want to give the answer...)

ManBearPigg
@ManBearPigg
Apr 10 2016 01:29
@bitgrower I can't use c9 as a workspace I will just upload it wherever FCC says later
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:29
@arunkumrv Didnt work
bitgrower
@bitgrower
Apr 10 2016 01:30
what's the hurdle in using c9 ?
V Arun Kumar
@arunvkumr
Apr 10 2016 01:30
@ZctrapCoding val <= 9.. one of the test cases is testLogicalOr(9) should return "Outside".
ManBearPigg
@ManBearPigg
Apr 10 2016 01:30
@bitgrower that it sucks balls and I would much rather use atom and my own machine
Alexandre Peluchi
@alexandrepeluchi
Apr 10 2016 01:30
This message was deleted
CamperBot
@camperbot
Apr 10 2016 01:30
:bulb: to format code use backticks! ``` more info
Charlotte N.
@clnquacky
Apr 10 2016 01:31
@khaduch I will keep trying.. I definitely want to understand.. but don't want the answer just given.. Where is the understanding then.
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:31
i need all of them to work all it dosnt pass and if i do that then only that one would work
bitgrower
@bitgrower
Apr 10 2016 01:31
hmmm ... didn't think it sucked balls ...but, whatever ...
Andy Roush
@AndyRoush
Apr 10 2016 01:31
Thank you guys
V Arun Kumar
@arunvkumr
Apr 10 2016 01:32
@ZctrapCoding what's the challenge name?
bitgrower
@bitgrower
Apr 10 2016 01:32
problem is, when you use your own development environment, you'll limit yourself in the kind of help you can get because you've introduced a number of new variables into the process ...
Alexandre Peluchi
@alexandrepeluchi
Apr 10 2016 01:33
function largestOfFour(arr) {
  // You can do this!
  var maior;
  var arrMaior = [];
  for (var i = 0; i < arr.length; i++) {
    maior = arr[i][0];
    for (var j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > maior) {
        maior = arr[i][j];
        arrMaior[i] = maior;
      }  
    }
  }
  return arrMaior;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);
Why arrMaior return only [9, 35, 97] if the maior variable have 100000?
ManBearPigg
@ManBearPigg
Apr 10 2016 01:33
@bitgrower ill figure it out. C9 hurts my eyes lol
bitgrower
@bitgrower
Apr 10 2016 01:33
I'd also recommend seeing if there are folks in the backend room who can help you out ...
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:33
Comparisons with the Logical Or Operator
bitgrower
@bitgrower
Apr 10 2016 01:34
hmmm ... might try +/- in your browser window ?
I don't have great eyes myself ... but, again, there's a lot of differences in environments ... like screen resolution & things ...
V Arun Kumar
@arunvkumr
Apr 10 2016 01:34
@ZctrapCoding post you code again.. i tried your code. it works
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:35
@arunkumrv nope that 9 still isnt completed
V Arun Kumar
@arunvkumr
Apr 10 2016 01:37
@alexandrepeluchi move this statement arrMaior[i] = maior; outside for loop
Andy Roush
@AndyRoush
Apr 10 2016 01:38

Getting close. 3 out of 4 checks. Not sure what else is wrong. ```js
function nextInLine(arr, item) {
// Your code here
arr.push(1);
return arr.shift(10); // Change this line
}

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

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

V Arun Kumar
@arunvkumr
Apr 10 2016 01:38
this statement only works when there is a value which is larger than the first value.
@alexandrepeluchi
Andy Roush
@AndyRoush
Apr 10 2016 01:38
function nextInLine(arr, item) {
  // Your code here
  arr.push(1);
  return arr.shift(10);  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
After nextInLine(testArr, 10), testArr[4] should be 10
Charlotte N.
@clnquacky
Apr 10 2016 01:39
@khaduch Can a function be set to an object? function (myBike.setGear) ?
Andy Roush
@AndyRoush
Apr 10 2016 01:39
Not getting that one
But this is all checked
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
Ken Haduch
@khaduch
Apr 10 2016 01:39
@clnquacky - re-read the instructions for the challenge - it is pretty clear between those and the description of what is supposed to happen in the tests what the result should be. They mention a variable gear, and a method to setGear (meaning gear should get set to a value as provided in the function argument) and a method getGear should return the value that is stored in the gear variable...A Don't over-complicate those basic steps - and use the Car object as an example - the variable there is speed, and you can see what getSpeed does in the Car object.
V Arun Kumar
@arunvkumr
Apr 10 2016 01:39
@ZctrapCoding post your code..
Moisés Man
@moigithub
Apr 10 2016 01:39
.shift dont require any values (it will just ignore it ) @AndyRoush
and u need to push the item passed to the funciton
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:39
on here
?
V Arun Kumar
@arunvkumr
Apr 10 2016 01:39
yup.
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:40
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 20 || val < 9) {
    return "Outside";
  }
  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
Charlotte N.
@clnquacky
Apr 10 2016 01:40
@khaduch I think... (meaning gear should get set to a value as provided in the function argument) ... is what is not clicking in my brain tonight.
Ken Haduch
@khaduch
Apr 10 2016 01:40
@clnquacky - let me type in another example... hold on...
V Arun Kumar
@arunvkumr
Apr 10 2016 01:41
@ZctrapCoding val <=9 you tried this?
Andy Roush
@AndyRoush
Apr 10 2016 01:42
Ok @moigithub I pushed the 10, now this is the issue - nextInLine([], 1) should return 1
V Arun Kumar
@arunvkumr
Apr 10 2016 01:42
because one of the testcase is testLogicalOr(9) should return "Outside" which means val's value will be 9.
@ZctrapCoding
ZctrapCoding
@ZctrapCoding
Apr 10 2016 01:43
oh thanks @arunkumrv forgot about <= !
CamperBot
@camperbot
Apr 10 2016 01:43
zctrapcoding sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 438 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 10 2016 01:43
:+1:
Moisés Man
@moigithub
Apr 10 2016 01:44
@AndyRoush ur function accepts 2 arguments (arr, item) u need to work with those...
push the item on arr
do not push "hardcoded" values
use the variable
Andy Roush
@AndyRoush
Apr 10 2016 01:46
passed! damn that was the most ridiculous challenge ever. If I am struggling with this I dont even want to know what is coming up O.o
thanks @moigithub
CamperBot
@camperbot
Apr 10 2016 01:46
andyroush sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 856 | @moigithub | http://www.freecodecamp.com/moigithub
Ken Haduch
@khaduch
Apr 10 2016 01:46

@clnquacky - this is not exactly an object, but it is using a global variable myVariable, and I want to do something with a function to set the value of myVariable to a value, and then return it with another function:

var myVariable = null; // initialized to null

function setMyVariable( aValue ) {
    myVariable = aValue;
}

function getMyVariable () {
    return myVariable;
}

After doing this:

setMyVariable("apple");

The value of myVariable should be set to "apple". Then if I want to get the value,

var answer = getMyVariable();

the variable answer should contain the value "apple".

This is the concept that you are trying to implement in this object. They are just trying to get across the idea of "private" variables, which might not be too meaningful at this point... but setting the value of the variable and returning the value of the variable should be quite simple. Don't over-complicate it! :)

Alexandre Peluchi
@alexandrepeluchi
Apr 10 2016 01:48
@arunkumrv Thank you so much this works!
CamperBot
@camperbot
Apr 10 2016 01:48
alexandrepeluchi sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 439 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Maximilian Schlosser
@maxschlosser
Apr 10 2016 01:49

Hi, im currently stuck on the Arguments Optional Challenge (Advanced Algorithm Scripting)

I am trying to determine whether a variable passed to my function is a number or not. I tried using if(!isNaN(a))but that will also allow strings which only contain numbers (i. e. "2). Do you have any ideas?

V Arun Kumar
@arunvkumr
Apr 10 2016 01:49
:+1:
Ken Haduch
@khaduch
Apr 10 2016 01:49
@AndyRoush - :point_up: April 9, 2016 9:25 PM - that is what I was trying to tell you... I'm glad you got it running! "Reusable" functions do not have hardcoded values (for the most part.) Good luck as you move along!
@maxschlosser - have you tried the typeof operator? Check out the MDN documentation for that...
Maximilian Schlosser
@maxschlosser
Apr 10 2016 01:50
i tried. but what would i have to write here if(typeof(a) = ???) so it works (i don't want to use typeof(10) although it should work, just seems wrong)
Charlotte N.
@clnquacky
Apr 10 2016 01:51
So simple.. I was so close.. yet so far... The new variable is named in the function. then that value is passed to Gear... Then the getGear returns Gear... Thank you @khaduch
CamperBot
@camperbot
Apr 10 2016 01:51
clnquacky sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 904 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 10 2016 01:51
@maxschlosser - "read, search, ask" - search here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof look at the examples in that document...
Charlotte N.
@clnquacky
Apr 10 2016 01:51
I have it now.. I will have to review it and make sure I completely understand too.. and that it will stick
Maximilian Schlosser
@maxschlosser
Apr 10 2016 01:52
ah ok. i tried comparing it to number instead of "number" ^^'
thank you @khaduch
Ken Haduch
@khaduch
Apr 10 2016 01:53
@clnquacky - the key thing is to learn how to use the information that they give you in the text and in the tests. Most of these early challenges are set up with good examples of the concept, and come really close to giving you the answer. It does get more challenging as it goes along. Also, thanks to @bitgrower - thanks for helping on this one!
CamperBot
@camperbot
Apr 10 2016 01:53
khaduch sends brownie points to @clnquacky and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 973 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 243 | @clnquacky | http://www.freecodecamp.com/clnquacky
Ken Haduch
@khaduch
Apr 10 2016 01:54
@maxschlosser - oh, good! Learn to use the MDN docs - they are helpful in a lot of ways (you probably already know that, but just in case you haven't used them too much... ;) )
Charlotte N.
@clnquacky
Apr 10 2016 01:54
@khaduch I was putting the variables backwards, plus when I called them at the end, I had the syntax wrong.. The backwards variables were what I was struggling with.
Ken Haduch
@khaduch
Apr 10 2016 01:57
@clnquacky - as @bitgrower was trying to point out, the Car example object (even though they were doing mathematical operations on the variable) was a pretty good example of what you needed to do, especially the getSpeed() method. First thing is - don't panic! Really read the lesson, look at any helpful example code, study what the test code is telling you, search MDN if they put links to different methods - it all works together to help you along. But I definitely understand getting confused and having things snowball on you! So you have the chat room as a good resource... Good luck!
khaduch @khaduch - taking leave of the chat room... have a good night (or good day) everyone - happy coding*!!!
Norvin Burrus
@ndburrus
Apr 10 2016 02:13
js
/ Setup

var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[how do I get the value 16 here?];       // Change this Line
var player = testObj[16];   // Change this Line
I'm trying to get playerNumber to get the value 16 outputted (the text in the code may appear confusing)
is anyone else in this room?
Ken Haduch
@khaduch
Apr 10 2016 02:18
@ndburrus - hello there...
Norvin Burrus
@ndburrus
Apr 10 2016 02:18
@khaduch hi
hey, did u check out banas vids?
Ken Haduch
@khaduch
Apr 10 2016 02:20
@ndburrus - no, I didn't see the post. I was here for a long time helping on a few challenges.
which challenge is this? I just wanted to re-read the instructions. (The player number one.)
sekoku
@sekoku
Apr 10 2016 02:20

Okay, I have to be doing something wrong:

var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

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

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

};

var myCar = new Car();

var myBike = new Bike();

Gives nothing but a blank reply in regards to the testing of it, why would that be? Becaues Bike doesn't have a command argument? Even then, wouldn't setGear = 0 return 0 as the answer?

Norvin Burrus
@ndburrus
Apr 10 2016 02:23
@khaduch (sorry had a connection issue). This is from the Accessing Objects Properties with Variables {javascript} exercise.
Ken Haduch
@khaduch
Apr 10 2016 02:23
@sekoku - you need to have a function "getGear" that is similar to the example getSpeed() method in the Car example above your bike code. And the setGear method should set the gear variable.
rkDeason
@rkDeason
Apr 10 2016 02:25
@ndburrus try switching the order of your last two statements
Ken Haduch
@khaduch
Apr 10 2016 02:25
@ndburrus - okay, they just want you to use the playerNumber variable to hold the value 16, and that becomes the variable that you use inside the brackets in the object bracket notation. (It is kind of a dumb example, but they're just trying to get you used to the use of variables to access object properties and that you have to use bracket notation...) The key concept is to learn when you need to use bracket notation
Norvin Burrus
@ndburrus
Apr 10 2016 02:25
@rkDeason ok... moment
Ivan
@elementWebDev
Apr 10 2016 02:26
function nextInLine(arr, item) {
// Your code here

  return arr, item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 0)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
can someone help
Norvin Burrus
@ndburrus
Apr 10 2016 02:27
@khaduch ok. reading...
rkDeason
@rkDeason
Apr 10 2016 02:27
@ndburrus and modify the new last statement to: var player = testObj[playerNumber];
Ivan
@elementWebDev
Apr 10 2016 02:27
supposed to remove the first from the line
Ken Haduch
@khaduch
Apr 10 2016 02:28
@ndburrus - I forgot to say that it is important to look at the test code and results, that also gives hints about what the final result should be. It is often very helpful!
Ivan
@elementWebDev
Apr 10 2016 02:28
and move the queue up
Norvin Burrus
@ndburrus
Apr 10 2016 02:30
@khaduch ok, still reading/digesting. also - the use of the testing feature ("test code & results") doesn't appear to be very useful as it runs when one is finished - as if it is an afterthought (unless the entire is not correct)
entire answer*
MichaelTsang
@MichaelTsang
Apr 10 2016 02:31

@MichaelTsang

$(document).ready(function(){
    $("#change").on("click",function(){
        $.getJSON('quoteJSON.json', setQuote);
        function setQuote(data){
           for (var i = 0; i < data.rows.length; i++) {
               var randomRow = parseInt(Math.random()*data.rows.length); 
               var content = data.rows[randomRow].content ;
               var author = data.rows[randomRow].author;
              $('#quote').html('<p>' +randomRow+content + '</p>');
              $('#author').html('<p>' +randomRow+ author + '</p>');
           }

        function getQuote(){
                   alert(content);
           }
           return getQuote;
        }

});

why can't this closure work?
click button setQuote() work , but getQuote() do nothing

Norvin Burrus
@ndburrus
Apr 10 2016 02:31
i was thinking of installing sublime text to use for testing
rkDeason
@rkDeason
Apr 10 2016 02:32
var playerNumber=16;
var player = testObj[playerNumber];
Norvin Burrus
@ndburrus
Apr 10 2016 02:32
ST/sublime text to browser to see results
hmmm...
Ken Haduch
@khaduch
Apr 10 2016 02:33
@ndburrus - but look at this - it says "playerNumber" should be a number. And "You should use bracket notation to access testObj". So that tells you that you should have a number in the variable, and so on... that is what I mean. It gives "hints" - you can run it right away to see the descriptions of the tests. It can be helpful sometimes! :)
rkDeason
@rkDeason
Apr 10 2016 02:33
@ndburrus you just had them out of order; make the assignment first and remember testObj is an array so property you are accessing needs to be in brackets
Norvin Burrus
@ndburrus
Apr 10 2016 02:33
@rkDeason that solution works. thank you. I'm still looking at it - to see if that makes sense to me...
CamperBot
@camperbot
Apr 10 2016 02:33
ndburrus sends brownie points to @rkdeason :sparkles: :thumbsup: :sparkles:
:star: 229 | @rkdeason | http://www.freecodecamp.com/rkdeason
Ken Haduch
@khaduch
Apr 10 2016 02:34
@MichaelTsang = in the getQuote function, the "content" variable is no longer in scope. It is local to the setQuote function.
rkDeason
@rkDeason
Apr 10 2016 02:35
no prob; this javascript is kicking my butt
Norvin Burrus
@ndburrus
Apr 10 2016 02:36
@rkDeason it doesn't look like it. you got that one. i think i overcomplicated it.
MichaelTsang
@MichaelTsang
Apr 10 2016 02:36
@khaduch but i wanna use closure to get content in setQuote()
something like this
  function f1(){
    var n=999;
    function f2(){
      alert(n); 
    }
    return f2;
  }
  var result=f1();
  result(); // 999
rkDeason
@rkDeason
Apr 10 2016 02:36
yeah but I spend so much time on one challenge!
Norvin Burrus
@ndburrus
Apr 10 2016 02:37
@khaduch reviewing your comments. thank you.
CamperBot
@camperbot
Apr 10 2016 02:37
ndburrus sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 905 | @khaduch | http://www.freecodecamp.com/khaduch
Justin
@daemedeor
Apr 10 2016 02:37
@rkDeason don't compare yourself to how much time you spend on something or how other people are doing, just learn at a pace enjoyable to you. you will get less burned out on programming that way :D
Norvin Burrus
@ndburrus
Apr 10 2016 02:37
ill be back in a few minutes....
MichaelTsang
@MichaelTsang
Apr 10 2016 02:38
@khaduch i figure it out ! just use getQuote() without return ~~~
@khaduch thanks for help :S
CamperBot
@camperbot
Apr 10 2016 02:39
michaeltsang sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 906 | @khaduch | http://www.freecodecamp.com/khaduch
MichaelTsang
@MichaelTsang
Apr 10 2016 02:39
sry send wrong i mean :D @khaduch
Ken Haduch
@khaduch
Apr 10 2016 02:39
@MichaelTsang - can you please post the code again? I just want to see the final result?
thanks
MichaelTsang
@MichaelTsang
Apr 10 2016 02:40
$(document).ready(function(){
    $("#change").on("click",function(){
        $.getJSON('quoteJSON.json', setQuote);
        function setQuote(data){
           for (var i = 0; i < data.rows.length; i++) {
               var randomRow = parseInt(Math.random()*data.rows.length); 
               var content = data.rows[randomRow].content ;
               var author = data.rows[randomRow].author;
              $('#quote').html('<p>' +randomRow+content + '</p>');
              $('#author').html('<p>' +randomRow+ author + '</p>');
           }

        function getQuote(){
               alert(content);
         }      
         getQuote();
        }
});
and when i click the button , getQuote() works and alert sth
rkDeason
@rkDeason
Apr 10 2016 02:40
thanks @daemedeor I need all the encouragement I can get! :)
CamperBot
@camperbot
Apr 10 2016 02:40
rkdeason sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 289 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 10 2016 02:41
@rkDeason also don't worry about feeling frustrated when programming, EVERYONE gets frustrated when programming, thats what programmers enjoy overcoming that frustration
rkDeason
@rkDeason
Apr 10 2016 02:43
So, are there any really good resources that you've used for javascript? I'm about half way through Eloquent Javascript
Justin
@daemedeor
Apr 10 2016 02:43
@rkDeason none... i went to uni learning java/c before learning js so i never struggled when learning JS i also went to a bootcamp
javascript the good parts is a good book i've heard though
Ken Haduch
@khaduch
Apr 10 2016 02:44
@rkDeason "Eloquent Javascript" is pretty heavy duty for a beginner (if you're a beginner.)
it is a good book, though - really high level (in my opinion!)
rkDeason
@rkDeason
Apr 10 2016 02:44
I've had courses in Java and C++ but that was about 8 years ago
Justin
@daemedeor
Apr 10 2016 02:45
yea thats a bit long haha
rkDeason
@rkDeason
Apr 10 2016 02:45
yeah LOL
bitgrower
@bitgrower
Apr 10 2016 02:45
@rkDeason ...
help js resources
bitgrower
@bitgrower
Apr 10 2016 02:46
the Udemy course mentioned is very popular among some of us ... you can watch the first 3.5 hours on yt ... it was one of the first ancillary resources I picked up when learning js ...
rkDeason
@rkDeason
Apr 10 2016 02:46
thanks @bitgrower Javascript for Cats sounds fun
CamperBot
@camperbot
Apr 10 2016 02:46
rkdeason sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 974 | @bitgrower | http://www.freecodecamp.com/bitgrower
Justin
@daemedeor
Apr 10 2016 02:46
javascript for cats @.@
rkDeason
@rkDeason
Apr 10 2016 02:46
ugh I'm old school, would rather have a book, not a video
bitgrower
@bitgrower
Apr 10 2016 02:47
yeah .. the one on functional programming wasn't impressed with, there's a guy who has the funfunfunction (?) I think, channel on YouTube .. has some really nice videos ...
sekoku
@sekoku
Apr 10 2016 02:48
@khaduch Okay, that returns 0. Trying to make gear += setGear; seems to do nothing if I put a number where Bike() is. I guess to set the gear, I'd have to use MyBike.setGear() instead despite setGear being a public(?) function with a public variable?
bitgrower
@bitgrower
Apr 10 2016 02:48

I'm becoming less and less that way -- I like a combination -- the udemy course is nice because you can also interact with the instructor, ask questions, etc ... (I haven't needed to, but, nice to know it's there)...

YT videos MAY be cheaper ... LOL

the multi-sensory experience does allow for a different kind of repetition which I think helps with retention as well ...
I will say that if neither YT nor udemy allowed me to speed up the videos I might not like them as much ... :) But both do ... :)
Kevin Schwert
@kevinpschwert
Apr 10 2016 02:51

On the Gold Code level, I completed it and got the right solution but I was wondering if there was a more efficient or better way to right the code. Here is my code. function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1) {
return "Hole-in-one!";
}

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

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

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

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

else if (strokes - par == 2) {
return "Double Bogey";
} else {
return "Go Home!";
}

// Only change code above this line
}

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

ramses
@ozymandias1
Apr 10 2016 02:51

if anyone is not on codewars yet and doesn't mind helping me out with a referral, please go here! www.codewars.com/r/_zuy6Q

full disclaimer: you can signup without giving me referall credit here: codewars.com.

after you've made it there, please check out the kata i just published, and leave comments/suggestions to improve it! see if you can compelte the challenge: http://www.codewars.com/kata/noobcode-01-supersize-me-dot-dot-dot-or-rather-this-integer

Ken Haduch
@khaduch
Apr 10 2016 02:52
@sekoku - setGear() is going to be a function. It is going to have a function argument of something like "newGear". If you look at the tests that are run, you can see something like this: myBike.getGear() should return 4 after calling myBike.setGear(4). So if the 'getGear' function is very similar to the getSpeed function in the Car, then it should return the value of gear when it is called... what would it take to make a function setGear(newGear) that is going to *set the value of gear to 4 (as it says in the test) so that getGear will return 4. And remember - no hard-coding of the number 4 in the function! It has to work for all of those test cases that are run, with various numbers...
Dylan
@dhcodes
Apr 10 2016 02:54
@ozymandias1 I will require 98% of whatever kickback you are receiving. Do you accept?
lol j/k
Ivan
@elementWebDev
Apr 10 2016 02:54
```
function nextInLine(arr, item) {
// Your code here

  return arr, item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 0)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
please give me a hint
Dylan
@dhcodes
Apr 10 2016 02:55
@oghosting did you read the links about shift() and push()?
@oghosting you want to push item to the arr
then return the shift value of the arr
@oghosting go forth and conquer
Ivan
@elementWebDev
Apr 10 2016 02:56
@dhcodes yes, wasnt sure where
Kevin Schwert
@kevinpschwert
Apr 10 2016 02:56
@oghosting I spent about two hours last night trying to figure that one out. Went to bed and then this afternoon it took me five minutes after thinking about it and getting help last night.
Dylan
@dhcodes
Apr 10 2016 02:56
shift and push are array methods. so you do arr.push()
to push
Ivan
@elementWebDev
Apr 10 2016 02:56
@dhcodes thanks
CamperBot
@camperbot
Apr 10 2016 02:56
oghosting sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 584 | @dhcodes | http://www.freecodecamp.com/dhcodes
Ken Haduch
@khaduch
Apr 10 2016 02:57
@kevinpschwert - that's about the way i did it... straightforward. You could conceivably make up some kind of lookup object and a way to access it. I was thinking about trying it, but I'm burned out from typing "hopefully helpful hints" in this chatroom tonight already... :)
ZctrapCoding
@ZctrapCoding
Apr 10 2016 02:58
hi
sekoku
@sekoku
Apr 10 2016 02:58

@khaduch I think I broke it.

var Bike = function() {

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

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

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

};

var myBike = new Bike();

Test allows me to pass but it returns 0?

Dylan
@dhcodes
Apr 10 2016 02:58
How's it going @ZctrapCoding
ramses
@ozymandias1
Apr 10 2016 02:59
@dhcodes lol
sekoku
@sekoku
Apr 10 2016 02:59
Oh, because myBike.getGear(); isn't assigned. Doing what the test says functions. Okay.
Norvin Burrus
@ndburrus
Apr 10 2016 02:59
@khaduch ok. (completed reading ur comments). that makes sense. alright. i have another one i had to skip - because it didn't make sense to me. let me find it
ramses
@ozymandias1
Apr 10 2016 02:59
no kickbacks if you can't solve it
Ken Haduch
@khaduch
Apr 10 2016 02:59
@sekoku - I think that you are possibly having problems with naming your variable "setGear", which is also the name of a function. Just change that variable and all of the places where you are referencing it.
Norvin Burrus
@ndburrus
Apr 10 2016 03:01
@sekoku there is no getGear - should be setGear?
sekoku
@sekoku
Apr 10 2016 03:02
@khaduch Nah, replacing the variable still has it be 0 unless I specifically call it like the example code will do. (Which still says it's correct despite returning 0.)
Norvin Burrus
@ndburrus
Apr 10 2016 03:02
@sekoku - maybe i don't understand the exercise.
sekoku
@sekoku
Apr 10 2016 03:03
@ndburrus "Make objects Properties Private."
Norvin Burrus
@ndburrus
Apr 10 2016 03:03
@sekoku ok, ty... will take a look
Ken Haduch
@khaduch
Apr 10 2016 03:04
@sekoku - please post your code again? The instructions say Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGearto get and set that value.
So your private property should has to be named gear - nothing else! Then use that as the variable that you are setting / getting with the other functions...
sekoku
@sekoku
Apr 10 2016 03:04
@khaduch
var Bike = function() {

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

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

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

};
Even if I change var setGear = 0; and the return variable to "gear" it still returns 0 unless I specify myBike.setGear(n)
Ken Haduch
@khaduch
Apr 10 2016 03:05
@sekoku - please read the comment above your code... change the name of the variable! It should work!
sekoku
@sekoku
Apr 10 2016 03:06
where n is what it tests. But without that the code-check says it's completely right.
Ken Haduch
@khaduch
Apr 10 2016 03:07
do you still have (or did you put) var myBike = new Bike(); in the code? I forget what was in the initial setup...
sekoku
@sekoku
Apr 10 2016 03:07
yeah.
And changing it to:
var Bike = function() {

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

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

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

var myBike = new Bike();
Still has it return 0. So it isn't like naming the varaible and function the same thing is the problem.
I mean from the way I wrote it it should be straightforward. myBike is an object that copies Bike which has a function property called setGear which takes the function newGear, which gets assigned to the variable gear and then the function property .getGear returns the variable.
So if I made Bike(4); Bike.gear = 4; should be it.
But it returns 0 which is making me scratch my head.
ALMY91
@ALMY91
Apr 10 2016 03:11
hello all...
sekoku
@sekoku
Apr 10 2016 03:11
Unless I specifically call out the setGear property it doesn't seem like Bike will take an argument?
ALMY91
@ALMY91
Apr 10 2016 03:12
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
{for (var i = 0; i < contacts.length ; i++); {  
if((contacts[i].firstName === firstName)&&(contacts[i].hasOwnProperty(prop)) 
{return contacts[i][prop];} 

else            
{return "No such property";}

}
}
// Only change code above this line
else            {return "No such contact";} 
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Ken Haduch
@khaduch
Apr 10 2016 03:12

are the tests running successfully? I guess I don't know what you mean by "it is returning 0"? If the tests are running, then this should be fine. If the tests aren't running, then I don't know why?

There is no operation that you can do Bike(4); - that should do nothing?

Once you have myBike created, you should be able to do myBike.setGear(4); and then myBike.getGear(); should return 4 - it looks like your code is set up correctly.

ALMY91
@ALMY91
Apr 10 2016 03:12
whats wrong?
sekoku
@sekoku
Apr 10 2016 03:13
@khaduch The console on the left returns 0 as the value, but the code check says I'm correct and passes me.
Which is what is making me scratch my head because I'm not sure if I have that right.
Oh, okay. I guess the codecheck doesn't return the last test (4)'s value, which is what is throwing me and making me think my written code broke the test.
Ken Haduch
@khaduch
Apr 10 2016 03:14
@sekoku - the console on the left doesn't mean anything if the tests are passing, unless it has an error. I think that you have this running - if the tests are passing, you're done! Submit it and go on...
@ALMY91 - what result are you getting from this - the code formatting looks a little strange - perhaps some extra curly braces in there, which might be okay, but it is hard to read it...
@ALMY91 - yes, you are getting a syntax error because of improperly formed code, it would appear?
Aniruddh Agarwal
@anrddh
Apr 10 2016 03:20
@sekoku The ‘console’ displays the value that is returned after the execution of your code
Ken Haduch
@khaduch
Apr 10 2016 03:21

@ALMY91 - you have a semicolon immediately after the parenthesis that closes the for loop:

{for (var i = 0; i < contacts.length ; i++); {  <<<--- get rid of that semicolon!

Take away that semicolon! And there doesn't need to be an opening curly brace before the for, either. You should eliminate that, and then see if all of the other braces and parens are balanced...

sekoku
@sekoku
Apr 10 2016 03:22
@awesomeaniruddh So then why doesn't it return one of the test examples as a value, then? Because the console doesn't see that added after runtime?
ALMY91
@ALMY91
Apr 10 2016 03:23
@khaduch
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length ; i++) {  
if((contacts[i].firstName === firstName)&&(contacts[i].hasOwnProperty(prop)) 
{return contacts[i][prop]} 
   }      
else            {return "No such property";}



// Only change code above this line
else            {return "No such contact";} 
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@khaduch i caant figure out whats left wrong after checking through agagin..
Hitoshura
@Hitoshura
Apr 10 2016 03:26
It's a bit of a confidence booster to struggle with an algorithm challenge and finally get it, and check the wiki for the better solutions only to see that yours is pretty close to the best solution \o/
Ken Haduch
@khaduch
Apr 10 2016 03:28

@ALMY91 one other problem... at least I think that I see one problem with your code. You have that extra "else" below the comment that says "// only change code above this line".

That is bad - it doesn't have a matching 'if'. So there might be one other thing. The contacts array is an array of four entries. The function call is passing a name and a property. The for loop has to be able to look at all of the contacts, in case the match is not the first one - so you cannot return no such contact from within the for loop. Make sure that you have closed the for loop (with a curly brace) and put that return "No such contact"; outside of the for loop. So that if no contact is found, the for loop ends, and then you can return 'No such contact'. It would help if you used some clearer indenting in your coding style - it would make it easier to see the code structure...

Rujool Doshi
@rujool
Apr 10 2016 03:29

@cvdeby Getting no output at console
@AchiPapakon No I havent tried debugger, didnt occur to me, I tried using console log
@moigithub Yes its a recursive call, I was thinking whether the recursion is working properly... In my console for ```
function findLCM(a,b){
if(a === b){
return a;
}
else if(a>b){
A = a;
while(a <= A*b){
if(a%b === 0 && a%A === 0){
console.log("LCM of "+A+" and "+b+" is: "+a);
return a;
}
a+=a;
}
}

else{
B = b;
while(b <= B*a){
if(b%a === 0 && b%B ===0){
console.log("LCM of "+a+" and "+B+" is: "+b);
return b;
}
b+=b;
}
}
}
```
I am getting only LCM of 4 and 5 is 20, but then it should go back and have LCM(3,20) which is not happening..

@cvdeby Sorry getting not output at the result area
function findLCM(a,b){
if(a === b){
return a;
}
else if(a>b){
A = a;
while(a <= A*b){
if(a%b === 0 && a%A === 0){
console.log("LCM of "+A+" and "+b+" is: "+a);
return a;
}
a+=a;
}
}
else{
B = b;
while(b <= B*a){
if(b%a === 0 && b%B ===0){
console.log("LCM of "+a+" and "+B+" is: "+b);
return b;
}
b+=b;
}
}
}
Ken Haduch
@khaduch
Apr 10 2016 03:35

@ALMY91 - and as I further examine this. there is one other problem... Your test:

    if ((contacts[i].firstName === firstName) && (contacts[i].hasOwnProperty(prop)))
    {
      return contacts[i][prop];
    } 
    else
    {
      return 'No such property';
    }

Also means that if you do not get a match on the name and property, you immediately return "No such property". You have to change that, as well. It would be better to do something like this:

    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } 
      else
      {
        return 'No such property';
      }
    }

The difference in my second code snippetis that if you have a name match, then you check for either you have a property, which you return, or you don't have a property, so you return "no such property". Your current code is if you have BOTH a name match and a property, you return the property, otherwise you return "no such property". That means that if the name did not match, you immediately return "No such property".

I hope that helps?? I'm going
to have to shut myself down here soon...

Abhishek Gorti
@waco001
Apr 10 2016 03:36
Hi, does anyone have exp with cherrypy with client side routing?
sekoku
@sekoku
Apr 10 2016 03:36
var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal - currentVal;
}, 0);
What's the 0 in this example code? The current value?
Ken Haduch
@khaduch
Apr 10 2016 03:37
@sekoku - I think it is the initial value used by reduce... check the MDN docs to be sure.
bitgrower
@bitgrower
Apr 10 2016 03:38
yep, I think @khaduch is right ... it's clearly "a value being passed to reduce" ... what the meaning of the parameter is is something that MDN would be able to tell you ...
sekoku
@sekoku
Apr 10 2016 03:41
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce <--That's not matching the example code and their (callback[, initialValue]) is throwing me.
Callback being the array, new Array(?) with the initial value?
harpoon747
@harpoon747
Apr 10 2016 03:42
Can some one help with the Code for Challenge "Seek and Destroy".
function destroyer(arr) {
  // Remove all the values
  var filtered = arr.filter(function isFiltered(value){
    for(i=1;i < arguments.length; i++)
      {
        if(arguments[i] === value)
            continue;
        else
            return value;
      }
  });
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Norvin Burrus
@ndburrus
Apr 10 2016 03:43
@harpoon747 looks like ur missing a paren
sekoku
@sekoku
Apr 10 2016 03:43

Like if I change the test code to copy the example code, I get

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

Which returns -33 as the value with that 0. If I remove it it gives me -22 which makes sense if you subtract the array [4, 5, 6, 7, 8] like "singleVal is 0 - 4 = -4, -4 - 5 =..." until you get to -22.

So I'm not sure what is giving me -33 with that 0 being added?
bitgrower
@bitgrower
Apr 10 2016 03:44
@harpoon747 -- right off, you cannot use arguments object in the way you are trying ... the arguments object gets re-defined on the opening of each new scope (i.e., every function call ... )
Norvin Burrus
@ndburrus
Apr 10 2016 03:44
@harpoon747 no paren missing, sorry.
bitgrower
@bitgrower
Apr 10 2016 03:48

@sekoku you have 2 parameters being passed to array.reduce ... the function and the initial value ...

it looks a little confusing because you are actually defining the function within the array.reduce function call ... you are using what's called an immediately invoked Function Expression ("IIFE")

...that ENTIRE definition makes up the first parameter passed to array.reduce ...

you could actual pull out the IIFE and define it elsewhere, with a name, and do something like this ...

array.reduce(myFunction, 0);

I don't have an explanation for your example, though, @sekoku -- been kind of a long day here ...
sekoku
@sekoku
Apr 10 2016 03:49
wiki Condense arrays with reduce
CamperBot
@camperbot
Apr 10 2016 03:49

:point_right: challenge condense arrays with reduce [wiki]

Reduce can be useful for condensing an array of numbers into one value.

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;

});

:pencil: read more about challenge condense arrays with reduce on the FCC Wiki

sekoku
@sekoku
Apr 10 2016 03:50
wut, changing the return to + has the code check pass instead of - like the example code.
ALMY91
@ALMY91
Apr 10 2016 03:51
@khaduch
Ken Haduch
@khaduch
Apr 10 2016 03:51
@bitgrower @sekoku - it isn't really an IIFE... I hate to disagree. It is an anonymous function, which is the callback for the reduce method. If you want to find out about IIFE's - http://benalman.com/news/2010/11/immediately-invoked-function-expression/ - but since it has been a long day... save it for tomorrow. ;)
ALMY91
@ALMY91
Apr 10 2016 03:51
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length ; i++){  

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

   if(contacts[i].hasOwnProperty(prop) 

{return contacts[i][prop]} 
} 
}   
else {return "No such property";}
}




// Only change code above this line


// Change these values to test your function
lookUpProfile("Akira", "likes");
harpoon747
@harpoon747
Apr 10 2016 03:52
@bitgrower So how shud I then iterate through the arguments if they are more than 2 and compare them with the value?
ALMY91
@ALMY91
Apr 10 2016 03:52
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length ; i++){  

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

   if(contacts[i].hasOwnProperty(prop) 

{return contacts[i][prop]} 
} 
}   
else {return "No such property";}
}




// Only change code above this line


// Change these values to test your function
lookUpProfile("Akira", "likes");
bitgrower
@bitgrower
Apr 10 2016 03:52
okay ... thank you @khaduch ... I've been misled somewhere ... or misconstrued information I was learning ...
CamperBot
@camperbot
Apr 10 2016 03:52
bitgrower sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 907 | @khaduch | http://www.freecodecamp.com/khaduch
pnguyenduong
@pnguyenduong
Apr 10 2016 03:52
Hello World
CamperBot
@camperbot
Apr 10 2016 03:52

welcome to FreeCodeCamp @pnguyenduong!

sekoku
@sekoku
Apr 10 2016 03:53
@bitgrower @khaduch Uh... that's a bit over my head.
bitgrower
@bitgrower
Apr 10 2016 03:53
@harpoon747 -- you need to grab the contents of the arguments object before you open a new scope -- like put them into another variable ...
sekoku
@sekoku
Apr 10 2016 03:53
I'm just looking to get my mind around what the example code is doing and parsing it.
I absolutely hate these .whatever for arrays and functions. :/
Ken Haduch
@khaduch
Apr 10 2016 03:54
@sekoku - yeah, mine too... but that is what an Immediately Invoked Function Expression is... And I agree, I struggle with some of these array methods!!! :x:
@ALMY91 - I think that you still have something missing in your code.
sekoku
@sekoku
Apr 10 2016 03:55
I'm not even sure why the wiki's change of the return from - to + is giving me "30" instead of "-33" like before (beyond the fact single value = 0 then subtracting the array)
If the single value variable is 0, the initial value is 0, the current value would equate as 0 + 0 = 4, 4+5 = 9... until 30? So why do I have the second 0 for the initial value then?
ALMY91
@ALMY91
Apr 10 2016 03:57
@khaduch

``js
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length ; i++){

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

if(contacts[i].hasOwnProperty(prop)

{return contacts[i][prop]}
}
}
else {return "No such property";}
}
else {return "No such contact";}

// Only change code above this line

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

Ken Haduch
@khaduch
Apr 10 2016 03:57

@ALMY91 - you do not have that "else" for the "no such property" properly nested in the test for the firstname match. And you still don't have the "No such contact" return there...

I only have 5 more minutes then I have to shut down...

ALMY91
@ALMY91
Apr 10 2016 03:57
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length ; i++){  

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

   if(contacts[i].hasOwnProperty(prop) 

{return contacts[i][prop]} 
} 
}   
else {return "No such property";}
}
else {return "No such contact";}



// Only change code above this line


// Change these values to test your function
lookUpProfile("Akira", "likes");
Ken Haduch
@khaduch
Apr 10 2016 03:58
@ALMY91 - you posted new code. You still don't have your coding style properly nested. Let me try and format it and see what you have now.
sekoku
@sekoku
Apr 10 2016 03:58
@ALMY91 Uh that code seems to be a mess. You kinda want to indent if you're going to nest ifs
Ken Haduch
@khaduch
Apr 10 2016 03:59
@ALMY91 - here is the code - you can see the structure better:
function lookUpProfile(firstName, prop) {
  // Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)
      {
        return contacts[i][prop]
      }
    }
  } 
  else {
    return 'No such property';
  }
} 
else {
  return 'No such contact';
}
@ALMY91 - what you have still results in a syntax error, since I have to leave, I'm going to reformat and then post the code... You just have to get things in the right places!
bitgrower
@bitgrower
Apr 10 2016 04:00

I was about to say ... it's really hard to read your code, @ALMY91 with its current indentation ... @khaduch is showing you good style ...

I am not sure what you are attaching the "else" statements to ... it can be good practice to comment your closing bracket to make it clearer ...

Ken Haduch
@khaduch
Apr 10 2016 04:05

@ALMY91 - you just had too much kruft in there - the formatting is a really good thing to help see what you've got. THis is the corrected version, you were missing a closing parenthesis in one place, the nesting of the if .. else was incorrect, too many brackets, an else that was not paired with an if...

function lookUpProfile(firstName, prop) {
  // Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else {
        return 'No such property';
      }
    } // end of firstName match
  } // end of for loop
  return 'No such contact';
} // end of function lookUpProfile

I hate to just give the answer, but I don't want to leave you hanging, I need to get to sleep... I hope that helps, please study it, and understand what is going on in there! You need to be able to get through these types of problems and more to come!

Good luck, good night...

bitgrower
@bitgrower
Apr 10 2016 04:06
yup, signing off here as well ... g'nite everyone ... g'nite @khaduch ... happy coding ... remember, if it stops being fun ...it may be time to take a break, take a walk, listen to some music get your mind out of code for a while ...
Ken Haduch
@khaduch
Apr 10 2016 04:07
@bitgrower - good night to you, tooo..... see you around the chats! :full_moon_with_face:
khaduch @khaduch - going ... going ... g-o-n-e... :zzz:
Tiffany White
@twhite96
Apr 10 2016 04:10
Having a bit of trouble with the Switch/case part
ALMY91
@ALMY91
Apr 10 2016 04:10
@khaduch thanks! seeya ard
CamperBot
@camperbot
Apr 10 2016 04:10
almy91 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 908 | @khaduch | http://www.freecodecamp.com/khaduch
Tiffany White
@twhite96
Apr 10 2016 04:11
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";
            break;
    }

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

// Change this value to test
myTest(1);
Patrick Black
@Mortiferr
Apr 10 2016 04:11
Hi everyone
Paul Borawski
@iAmNawa
Apr 10 2016 04:11
@Mortiferr hello!
Patrick Black
@Mortiferr
Apr 10 2016 04:11

http://codepen.io/Mortiferr/pen/repRgX/

Can I get feedback on my design?

Tiffany White
@twhite96
Apr 10 2016 04:11
But it just throws back alpha and none of the tests pass
Im also working on that
having trouble with my twitter button..
Patrick Black
@Mortiferr
Apr 10 2016 04:12
Yeah, I have no idea
I haven't gotten to adding functionality yet
Jay Kleine
@JKleine
Apr 10 2016 04:13
Your design looks good to me
Patrick Black
@Mortiferr
Apr 10 2016 04:13
Thanks
I feel so dumb, it took me like 20 minutes of searching to figure out why my button was getting slightly bigger on hover
Jay Kleine
@JKleine
Apr 10 2016 04:13
maybe add another quotation icon on the other side of the quote?
Patrick Black
@Mortiferr
Apr 10 2016 04:13
You think? It would kinda even it out
Jay Kleine
@JKleine
Apr 10 2016 04:14
Yeah I think it'd look good
Your hover Js looks nice
Patrick Black
@Mortiferr
Apr 10 2016 04:14
Thanks
Jay Kleine
@JKleine
Apr 10 2016 04:14
I'm doing it the exact opposite lol.. doing functionality first then I'll make it look pretty
Patrick Black
@Mortiferr
Apr 10 2016 04:15
Yeah
Probably the best way really
sekoku
@sekoku
Apr 10 2016 04:15
@twhite96 Have you tried changing myTest(1) to a different value? myTest(2)?
CyrilSL
@CyrilSL
Apr 10 2016 04:15

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for(i=0;i<arr.length;i++)
{
  for(j=0;j<arr[i].length;j++)
    {
      product*=arr[i];
    }
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Im getting output null
Help me here guys.
CamperBot
@camperbot
Apr 10 2016 04:16
no wiki entry for: me here guys
Tiffany White
@twhite96
Apr 10 2016 04:16
@sekoku yep
Still not passing
sekoku
@sekoku
Apr 10 2016 04:17
What example are you doing?
Ken Haduch
@khaduch
Apr 10 2016 04:17
@twhite96 - the code looks good. Check the function names against the test information - FCC changed a lot of the function names and this might be the problem...
Tiffany White
@twhite96
Apr 10 2016 04:17
Okay
I will try that @khaduch
That was it @khaduch They changed it to caseInSwitch
Thanks. I was going crazy
Ken Haduch
@khaduch
Apr 10 2016 04:18
@twhite96 - yes, change myTest to caseInSwitch in both places that it is used... and watch out for that, because they changed a lot of them, and the old names still live in other places...
Jay Kleine
@JKleine
Apr 10 2016 04:19
Could anyone take a look at my Js for the twitter button my Quote app?
sekoku
@sekoku
Apr 10 2016 04:19
Ah, that one. Yeah the example code looked correct but I couldn't find the example to test it myself
Tiffany White
@twhite96
Apr 10 2016 04:19
Thanks @khaduch I’ll keep that in mind
CamperBot
@camperbot
Apr 10 2016 04:19
twhite96 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 909 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 10 2016 04:19
@twhite96 - one place to see it is in the tests that they run - you then compare the function name that they use in the tests to those in your code, and make sure they match up!!! Hopefully it will be fixed to give you a better hint about that sometime in the near future? Take care...
sekoku
@sekoku
Apr 10 2016 04:21
@khaduch Or they could stop changing things up while people are using the lessons. salty about them moving the portfolio stuff from after Basic Javascript to before
I can understand why they did, but still... the constant rug-pulling and not making sure everything aligns before pushing to production is a bit... ugh.
harpoon747
@harpoon747
Apr 10 2016 04:25
@bitgrower Struggling with how to use the arguments object properly still not getting the result
CyrilSL
@CyrilSL
Apr 10 2016 04:34
Hey guys, Im not getting the proper output for multiplying using 'Nesting for loops.'

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for(i=0;i<arr.length;i++)
{
  for(j=0;j<arr[i].length;j++)
    {
      product*=arr[j];
    }
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Ivan
@elementWebDev
Apr 10 2016 04:35
function nextInLine(arr, item) {
// Your code here

  return arr.push(), arr.shift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 0)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
what am I doing wrong?
Ken Haduch
@khaduch
Apr 10 2016 04:35
@CyrilMeow - since you have nested for loop, and nested arrays, you need to address the array with arr[i][j] or something like that...
@oghosting - you are not using the item variable, which is what you should be pushing onto the queue... and I don't know if you can do exactly what you're doing with the return? It might work with the two method calls on the 'return' line. I've been meaning to try that. But you definitely need item to be involved in your push..
CyrilSL
@CyrilSL
Apr 10 2016 04:38
Thanks @khaduch, that did it. Can't believe I overlooked it.
CamperBot
@camperbot
Apr 10 2016 04:38
cyrilmeow sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 910 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 10 2016 04:38
@CyrilMeow - you're welcome. And the comma-separated functions return the correct one, so I'll have to checkmark that one in my memory... :) thanks
CamperBot
@camperbot
Apr 10 2016 04:38
khaduch sends brownie points to @cyrilmeow :sparkles: :thumbsup: :sparkles:
:star: 225 | @cyrilmeow | http://www.freecodecamp.com/cyrilmeow
Ivan
@elementWebDev
Apr 10 2016 04:42
TypeError: item.push is not a function
@khaduch thank you!
CamperBot
@camperbot
Apr 10 2016 04:44
oghosting sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 911 | @khaduch | http://www.freecodecamp.com/khaduch
CyrilSL
@CyrilSL
Apr 10 2016 04:44
the value to be pushed to item must be within the ().
Sorry @oghosting I replied to @camperbot .
ALMY91
@ALMY91
Apr 10 2016 04:46
function randomFraction() {

  // Only change code below this line.

  Math.random() = value; 
  {return (value)}

  // Only change code above this line.
}
anyone able to help me out on this?
hello there?
Duncan T
@dtweedle
Apr 10 2016 04:50
@ALMY91 you don't need thos brackets around return value
@ALMY91 Just write it as return value
Judy Zaratan
@mochicat8
Apr 10 2016 04:51
```function sumAll(arr) {
var low = Math.min.apply(null, arr);
var high = Math.max.apply(null, arr);
var sum = 0;
for(var i = low; i <= high; i++) {
sum += i;
}
return sum;
}
Duncan T
@dtweedle
Apr 10 2016 04:51
@ALMY91 Similarly where is your variable declaration? var value = ??
Judy Zaratan
@mochicat8
Apr 10 2016 04:51
is there a more elegant solution to this sum All numbers in a range algorithm
ALMY91
@ALMY91
Apr 10 2016 04:51
@Isymm usually when we are asking for an action to be performed dont we have to put it in the brackets?
Duncan T
@dtweedle
Apr 10 2016 04:52
@ALMY91 When you call the function. yes. But when you define the function as you are doing you don't use them
Judy Zaratan
@mochicat8
Apr 10 2016 04:53
function sumAll(arr) {
  var low = Math.min.apply(null, arr);
  var high = Math.max.apply(null, arr);
  var sum = 0;
  for(var i = low; i <= high; i++) {
    sum += i;
  }
  return sum;
}
ALMY91
@ALMY91
Apr 10 2016 04:53
@Isymm okay what shd i equate var value to then?
Duncan T
@dtweedle
Apr 10 2016 04:53
function randomFraction() { return Math.random() ; } randomFraction();
Judy Zaratan
@mochicat8
Apr 10 2016 04:54
the hint section in sum all numbers in a range, suggests using Array.reduce(), but I am curious how this would be done if there are only two elements in an array, instead of the whole range.
Frank XC
@tenkdayz
Apr 10 2016 04:55
@mochicat8 you can use array.reduce()
Duncan T
@dtweedle
Apr 10 2016 04:55
@ALMY91 Math.random();
Frank XC
@tenkdayz
Apr 10 2016 04:56
and a callback with return a+b;
ALMY91
@ALMY91
Apr 10 2016 05:00
@Isymm
function randomFraction() {

  // Only change code below this line.
var value=Math.random();
  { return value ;}  randomFraction();
  // Only change code above this line.
}
Duncan T
@dtweedle
Apr 10 2016 05:04
@ALMY91 You need to figure out the difference between calling a function and defining one. You need to move the call outside the itself. Also get rid of the {} around return value..
ALMY91
@ALMY91
Apr 10 2016 05:05
@Isymm
Duncan T
@dtweedle
Apr 10 2016 05:05
function randomFraction() { // This defines the function

  // Only change code below this line.
  var value=Math.random();
  return value ; 
  // Only change code above this line.
}
randomFraction(); // This calls the function
ALMY91
@ALMY91
Apr 10 2016 05:06
@Isymm but they mentioned to change code only above tt line
function randomFraction() {

  // Only change code below this line.
var value=Math.random();
   return value ;}
{  randomFraction();
  // Only change code above this line.
}
@Isymm tried this but ain working
Duncan T
@dtweedle
Apr 10 2016 05:08

@ALMY91

function randomFraction() {

  // Only change code below this line.
  var value=Math.random();
  return value ;
  // Only change code above this line.
}

Look at my curly brackets

ALMY91
@ALMY91
Apr 10 2016 05:08
@Isymm still not working
Duncan T
@dtweedle
Apr 10 2016 05:11
@ALMY91 I'm just tyring to help you with your function construction I'm not going to give you the whole answer, you won't learn anything that way
Patrick Black
@Mortiferr
Apr 10 2016 05:13
I'm completely stumped on the quote machine challenge
I have no idea how to implement an api
I could just use an array but that's no fun at all
Duncan T
@dtweedle
Apr 10 2016 05:14
@Mortiferr What would you like to know about using an API
Patrick Black
@Mortiferr
Apr 10 2016 05:15
Well, all these apis I find talk about using curl and all these different methods
idk which one to choose
var url = "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=";
I have that so far
Robert Richey
@0x0936
Apr 10 2016 05:15
@Mortiferr check out Quotes on Design
ah, you already have :)
Patrick Black
@Mortiferr
Apr 10 2016 05:16
actually have that page up rn
Duncan T
@dtweedle
Apr 10 2016 05:16

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

This one is also a pretty good one I've seen a few people use

Patrick Black
@Mortiferr
Apr 10 2016 05:17
hm
Duncan T
@dtweedle
Apr 10 2016 05:18
@Mortiferr Do you know how to make an AJAX request?
Patrick Black
@Mortiferr
Apr 10 2016 05:19
no
It was probably in the api and json lessons
should i take a look at those again or just look it up on mozilla
I believe I use $.ajax right, @Isymm
Duncan T
@dtweedle
Apr 10 2016 05:20
@Mortiferr Just google a few examples, watch a video or two on how they work and wahts going on, get familiar with the different types of request header methods.. That's part of what the challenges are about, doing research and learning the stuff.
@Mortiferr Yes that certainly is one way of doing them and probably the most straightforward at this point.
Patrick Black
@Mortiferr
Apr 10 2016 05:21
okay thanks
Duncan T
@dtweedle
Apr 10 2016 05:21
@Mortiferr np and good luck.
Patrick Black
@Mortiferr
Apr 10 2016 05:21
thanks @Isymm
CamperBot
@camperbot
Apr 10 2016 05:21
mortiferr sends brownie points to @isymm :sparkles: :thumbsup: :sparkles:
:star: 294 | @isymm | http://www.freecodecamp.com/isymm
Rujool Doshi
@rujool
Apr 10 2016 05:22
@ALMY91 Are you having problems only with the function? Can you post the whole code?
Robert Richey
@0x0936
Apr 10 2016 05:23
@Mortiferr this covers the fetch API for native ajax
Patrick Black
@Mortiferr
Apr 10 2016 05:24
Thank you kindly
ALMY91
@ALMY91
Apr 10 2016 05:28
@rujool nope they mentioned that Math.random is not a function
@Isymm alright thanks
CamperBot
@camperbot
Apr 10 2016 05:28
almy91 sends brownie points to @isymm :sparkles: :thumbsup: :sparkles:
:star: 295 | @isymm | http://www.freecodecamp.com/isymm
Rujool Doshi
@rujool
Apr 10 2016 05:29
@ALMY91 So have you been able to figure it out?
goodm0urning
@goodm0urning
Apr 10 2016 05:31
Trying to figure out why my code isn't returning anything? Can anyone give me a hand?
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
Rujool Doshi
@rujool
Apr 10 2016 05:32
@goodm0urning You have assigned result="", but are you changing it anywhere?
goodm0urning
@goodm0urning
Apr 10 2016 05:33
@rujool it doesn't look like it, good call, but how do I do that with objects?
"result = lookUp" outside the object, before the return?
Rujool Doshi
@rujool
Apr 10 2016 05:35
@goodm0urning Read up on how to access Object values in Javascript, I wont tell you how...
No thats wrong, you have to do everything inside the function itself
goodm0urning
@goodm0urning
Apr 10 2016 05:37
@rujool I remember doing it, it's "lookup.val" is what I think I'm looking for?
Rujool Doshi
@rujool
Apr 10 2016 05:38
@goodm0urning You got it!!
Brian
@sludge256
Apr 10 2016 05:38
You're almost there.
goodm0urning
@goodm0urning
Apr 10 2016 05:38
I can feel it! I'm trying!
Paul Borawski
@iAmNawa
Apr 10 2016 05:39
Hey @sludge256 How do you start working for freecodecamp?
ALMY91
@ALMY91
Apr 10 2016 05:39
@rujool trying to
Paul Borawski
@iAmNawa
Apr 10 2016 05:40
or rather how did you get into it?
Rujool Doshi
@rujool
Apr 10 2016 05:40
@ALMY91 What is the error/output you are getting
ALMY91
@ALMY91
Apr 10 2016 05:40
@iAmNawa do u get paid to work for freecodecamp?
@rujool var value=Math.random();
return value ;
Paul Borawski
@iAmNawa
Apr 10 2016 05:41
@ALMY91 I think you volunteer
ALMY91
@ALMY91
Apr 10 2016 05:41
@rujool i meant Math.random is not a function
Brian
@sludge256
Apr 10 2016 05:41
Actively contributing. I'm not sure if they have a "process" for recruiting.
Aryan Singh
@AryanSingh
Apr 10 2016 05:43
does anyone know how to install robomongo on linux
google says there must be a ./configure file but i cannot find it
ALMY91
@ALMY91
Apr 10 2016 05:44
@iAmNawa cool but how do u know if they are part of the commitee of codecamp?
Paul Borawski
@iAmNawa
Apr 10 2016 05:45
@ALMY91 I can just tell
Brian
@sludge256
Apr 10 2016 05:45
You can check the People list on the FCC organization page.
ALMY91
@ALMY91
Apr 10 2016 05:46
@sludge256 hello there i rbred ur good haha
Paul Borawski
@iAmNawa
Apr 10 2016 05:46
@ALMY91 also if you look on the right you can see an activity list
sludge banned a bunch of people, so be nice to brian ok?
ALMY91
@ALMY91
Apr 10 2016 05:46
@sludge256
Brian
@sludge256
Apr 10 2016 05:46
rbred?
ALMY91
@ALMY91
Apr 10 2016 05:46
function randomFraction() {

  // Only change code below this line.
  var value=Math.random();
  return value ;
  // Only change code above this line.
}
@iAmNawa hahaha omg yeah i saw tt. how do u actually banned someone tho
Paul Borawski
@iAmNawa
Apr 10 2016 05:48
I was wondering what rbred was myself
ALMY91
@ALMY91
Apr 10 2016 05:48
@sludge256 remembered
@sludge256 the error msg states that Math.random isn a function
function randomFraction() {

  // Only change code below this line.
  var value=Math.random();
  return value ;
  // Only change code above this line.
}
@sludge256 not too sure how to go abt it
Brian
@sludge256
Apr 10 2016 05:49
That code passes for me.
ALMY91
@ALMY91
Apr 10 2016 05:50
@sludge256 thanks!
CamperBot
@camperbot
Apr 10 2016 05:50
almy91 sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 2153 | @sludge256 | http://www.freecodecamp.com/sludge256
ALMY91
@ALMY91
Apr 10 2016 05:51
@sludge256 im left w 6challenges to go... its taking way way way longer than 10hrs for sure
Paul Borawski
@iAmNawa
Apr 10 2016 05:51
@ALMY91 the javascript challenges?
ALMY91
@ALMY91
Apr 10 2016 05:51
@sludge256 i think the estimated time is meant for beginners who are doing it for the 2nd time not the first
@iAmNawa yeah
@sludge256 @iAmNawa hey guys i be back in 15min gonna take a short break
Paul Borawski
@iAmNawa
Apr 10 2016 05:55
@sludge256 freefoodcamp?
Brian
@sludge256
Apr 10 2016 05:55
Yes :+1:
Paul Borawski
@iAmNawa
Apr 10 2016 05:58
@sludge256 lol
Brian
@sludge256
Apr 10 2016 05:59
You'd think such a mistake would be impossible if the entire article is about programming.
I guess the author was hungry at the time.
Rujool Doshi
@rujool
Apr 10 2016 06:04
Can some1 pls help me with this code: (Smallest Common Multiple)
function smallestCommons(arr) {
  var min = Math.min(arr[0],arr[1]);
  var max = Math.max(arr[0],arr[1]);
  var sortedArr = [];
  for(var i = min; i <= max; i++){
    sortedArr.push(i);
  }
  return getLCM(sortedArr);
}
function getLCM(arr){
  if(arr.length === 2){
    console.log(arr[0]+" "+arr[1]);
    return findLCM(arr[0],arr[1]);
  }
  else{
    console.log(arr[0], arr.slice(1));
    return findLCM(arr[0],getLCM(arr.slice(1)));
  }
}  
function findLCM(a,b){
  if(a === b){
    return a;
  }
  else if(a>b){
    A = a;
    while(a <= A*b){
      if(a%b === 0 && a%A === 0){
        console.log("LCM of "+A+" and "+b+" is: "+a);
        return a;
      }
      a+=a;
    }
  }

  else{
    B = b;
    while(b <= B*a){
      if(b%a === 0 && b%B ===0){
        console.log("LCM of "+a+" and "+B+" is: "+b);
        return b;
      }
      b+=b;
    }
  }
}
smallestCommons([1, 5]);
goodm0urning
@goodm0urning
Apr 10 2016 06:04
Can someone PM me who's good with javascript objects? I don't want to spam the chat
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 10 2016 06:16
Hie all
I have problem regarding to logic of profile lookup problem in front-end certification
this is my code
for(i= 0; i < contacts.length; i++){
if(contacts[i].firstName === firstName){
if(contacts[i][prop] === undefined){
return "No such property";
}else{
return (contacts[i][prop]);
}
return (contacts[i][prop]);
}else if(contacts[i].firstName !== firstName){
console.log("No such contact");
}
}
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 10 2016 06:21
i have to return "No such contact " string if json don't have contacts[i].firstName;
with above logic
Rada
@Radascript
Apr 10 2016 06:28
@malangaveuday i think you have an extra return(contacts[i][prop]) in there? after the else statement
also you can use ``` and ctrl+enter to paste your code
@malangaveuday and you want to be returning "no contact" outside of your loop, so that it doesn't end the loop when it doesn't find it in the first argument
*first object, not argument
CyrilSL
@CyrilSL
Apr 10 2016 06:54
@malangaveuday for the third line use .hasOwnProperty() function.
Eldar Tinjić
@EldarT90
Apr 10 2016 06:57
how should one start working on weather app
we got no guidelines at all
Benjamin Gonzalez
@xasuma
Apr 10 2016 06:59
Hey people, I am trying to access a random string from my array with an on click event. However, I can only do it once, after that one time, nothing will happen. I though the "on" click made it that way. But its not working.
$(document).ready(function() {
  var quoteList = [
    "gorgoro", "I am a bunny", "starcraft", 
    "phone","hello"];

  var x = Math.floor(Math.random() * quoteList.length);

  //on click do..
  $("#gorgoro").on("click",function() {
     $("#quote").html(quoteList[x]);
  });
});
sakram07
@sakrma07
Apr 10 2016 06:59
help Chunky Monkey
CamperBot
@camperbot
Apr 10 2016 06:59

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

Eldar Tinjić
@EldarT90
Apr 10 2016 07:01
help weather app
CamperBot
@camperbot
Apr 10 2016 07:01
no wiki entry for: weather app
Eldar Tinjić
@EldarT90
Apr 10 2016 07:01
= (
Paul Borawski
@iAmNawa
Apr 10 2016 07:02
help camperbot
CamperBot
@camperbot
Apr 10 2016 07:02

:point_right: camperbot [wiki]

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Benjamin Gonzalez
@xasuma
Apr 10 2016 07:04
anyone knows about the on click event above ^
Aleksander Gębicki
@Takumar
Apr 10 2016 07:04
Hi @xasuma everything is okay. Your function is called every time you click, but you generate random number only once (before you declared your function) so every time you get the same text!
@xasuma change it for example like this:
//on click do..
  $("#gorgoro").on("click",function() {
    var x = Math.floor(Math.random() * quoteList.length);
     $("#quote").html(quoteList[x]);
  });
Benjamin Gonzalez
@xasuma
Apr 10 2016 07:07
ohh , I see! Thank you @Takumar . I was focused on the onclick so I didn't see my mistake.
CamperBot
@camperbot
Apr 10 2016 07:07
xasuma sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 3062 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Apr 10 2016 07:07
@xasuma yeah, that looked good on first sight :-)
Eldar Tinjić
@EldarT90
Apr 10 2016 07:11
any help/hint toward weather app ? I don't know how to start at all
how can i apply API on my codepen and make it work
Marc Vincent Ong
@marcvincentong
Apr 10 2016 07:14

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var plusThree = oldArray.map(function(val){
return val + 3;
});
var newArray = oldArray;

Anyone knows how to solve this?
Instruction is to add three to each value in the array
Aleksander Gębicki
@Takumar
Apr 10 2016 07:20
@marcvincentong are you sure you wanted to create variable: var plusThree, maybe you should use newArray for results?
newArray suggests that it is array, and plusThree I don't know what is, maybe it contains digit 3?
Marc Vincent Ong
@marcvincentong
Apr 10 2016 07:22
@Takumar got it, thanks buddy :)
CamperBot
@camperbot
Apr 10 2016 07:22
marcvincentong sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 3064 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Apr 10 2016 07:22
@marcvincentong var newArray = oldArray; is no useful, because now you have two variables pointing to the same array. What for?
@marcvincentong you are welcome. It is nice, that you wanted to declare descriptive name of variable, but in this challenge tests are made on newArray array variable, so you have to name it exactly: newArray :-)
Kurt Johnson
@pompan129
Apr 10 2016 07:24
@EldarT90 I'd start with http://api.jquery.com/jquery.getjson/. this will get the api info into your app. as far as an api, I used https://www.wunderground.com/weather/api/.
but there are a few choices
Eldar Tinjić
@EldarT90
Apr 10 2016 07:25
@pompan129 oke thanks, let me look into this
CamperBot
@camperbot
Apr 10 2016 07:25
eldart90 sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:star: 452 | @pompan129 | http://www.freecodecamp.com/pompan129
Neel Shah
@neelshah22
Apr 10 2016 07:27

Challenge Increment a Number with JavaScript has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

var myVar = 87;

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

don't know what is the problem?
Aleksander Gębicki
@Takumar
Apr 10 2016 07:28
@neelshah22 ++ operator modifies value in variable, so you don't have to assign it to the same variable: myVar++ is enough it will increment your variable's value, so it becomes 88
Neel Shah
@neelshah22
Apr 10 2016 07:30
oh ! yes.
thank you, sir
Aleksander Gębicki
@Takumar
Apr 10 2016 07:33
@neelshah22 you're welcome
Hussein Zaki
@Hussein90
Apr 10 2016 07:47

please help me at this

function update(id, prop, value) {
  if(value !== "" && (typeof collection[id][prop] !== "object")){
    console.log(typeof collection[id][prop]);
    collection[id][prop] = value;
  }
  if(prop === "tracks" && value !== ""){
    collection[id].tracks.push(value);
  } 
  if(value === ""){
    delete collection[id][prop];
  }
  return collection;
}

i entered this as answer for challenge record collection but i not submitted it as a answer when i run test

@/all
Hussein Zaki
@Hussein90
Apr 10 2016 07:53
please help
Frank XC
@tenkdayz
Apr 10 2016 07:54
@Hussein90 what's the problem?
Hussein Zaki
@Hussein90
Apr 10 2016 07:55
@tenkdayz i put this as answer for the challenge but when i run test nothing happen
@tenkdayz here the full challenge
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

  return collection;
}

// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");



  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
could you help me
Frank XC
@tenkdayz
Apr 10 2016 08:00
// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");
why's that inside the function?
Coy Sanders
@coymeetsworld
Apr 10 2016 08:01
think that last closing bracket at the end needs to go @Hussein90
Frank XC
@tenkdayz
Apr 10 2016 08:01
delete this
Hussein Zaki
@Hussein90
Apr 10 2016 08:01
@tenkdayz ok
Frank XC
@tenkdayz
Apr 10 2016 08:01
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Hussein Zaki
@Hussein90
Apr 10 2016 08:03
@Takumar it doesn't work
@coymeetsworld i need it
Frank XC
@tenkdayz
Apr 10 2016 08:04
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {

      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },

    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");
should look like this..
Hussein Zaki
@Hussein90
Apr 10 2016 08:04
@tenkdayz thanks very much
it works
CamperBot
@camperbot
Apr 10 2016 08:04
hussein90 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 362 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Coy Sanders
@coymeetsworld
Apr 10 2016 08:06
sorry @Hussein90, just looked like it was dangling due to the indentation
Frank XC
@tenkdayz
Apr 10 2016 08:06
np
Hussein Zaki
@Hussein90
Apr 10 2016 08:06
@coymeetsworld no problem
Eldar Tinjić
@EldarT90
Apr 10 2016 08:32
$(document).ready(function() {

    $("#testing").on("click", function(){

      $.getJSON("http://www.wonko.info/ipt/xfiles/interfaces/target.bmp", function(json) {
  $("#tester").html(JSON.stringify(json));
});
    });

  });
why is this not making img be shown after i click buton?
CyrilSL
@CyrilSL
Apr 10 2016 08:45
'''function trueOrFalse(wasThatTrue){
if(true)
{
return "That was true";
}
return "That was false";
}
trueOrFalse(true);
Frank XC
@tenkdayz
Apr 10 2016 08:45
@EldarT90 looks like you need to set a var to json.obj.someurl
CyrilSL
@CyrilSL
Apr 10 2016 08:46
Always returns "That was true" no matter what the args is.
Benjamin Gonzalez
@xasuma
Apr 10 2016 08:47
How would I concatenate this string with this line of code?
var text = "Hey..";
$("#quote").html(quoteList[x]);
that lin of code is also a string.
alpox
@alpox
Apr 10 2016 08:47
@CyrilMeow sure because you test if(true) where true is always true :-)
Frank XC
@tenkdayz
Apr 10 2016 08:48
var text = "Hey .." + quoteList[x];
alpox
@alpox
Apr 10 2016 08:48
@CyrilMeow The argument was stored in the variable wasThatTrue
CyrilSL
@CyrilSL
Apr 10 2016 08:49
@alpox Even if i put false in the function trueOrFalse() it still gives me "That was true"
Eldar Tinjić
@EldarT90
Apr 10 2016 08:50
@tenkdayz sec let me check
alpox
@alpox
Apr 10 2016 08:50
@EldarT90 $.getJSON is for loading JSON, not images :-)
@EldarT90 what @tenkdayz said was for @xasuma
Frank XC
@tenkdayz
Apr 10 2016 08:51
@EldarT90 that url is a img src..
Eldar Tinjić
@EldarT90
Apr 10 2016 08:51
@alpox good morning ^^
alpox
@alpox
Apr 10 2016 08:52
@EldarT90 If you want to show an image through the img tag, just change its src attribute
@EldarT90 And good morning, yup :D
alpox @alpox :wave: @EldarT90
Benjamin Gonzalez
@xasuma
Apr 10 2016 08:53
@tenkdayz but if I do that then my jquery doesn't work. and if I do this
text + $("#quote").html(quoteList[x]); nothing happens.
Frank XC
@tenkdayz
Apr 10 2016 08:54
@EldarT90 you could use
onclick... document.getElementsByTagName("img").setAttribute("src","myurl");
right?
Eldar Tinjić
@EldarT90
Apr 10 2016 08:55
@tenkdayz yes, but actually i was trying certain functions commands from JSON because i need this for weather app
@tenkdayz i need first to figure out how the heck it works at all, before being able to connect it with some weather api
Frank XC
@tenkdayz
Apr 10 2016 08:59
@xasuma maybe
var str = $('#quote').text();
text + str;
Eldar Tinjić
@EldarT90
Apr 10 2016 09:01
so, which subcode should i use through getjson to be able to target APIs ?
Benjamin Gonzalez
@xasuma
Apr 10 2016 09:02
didn't work eiither, this is the code maybe it will give you a better idea. @tenkdayz
$(document).ready(function() {

  var text= "dsads";

  var quoteList = [lots of strings called quote and author...]

  //on click do..
  $("#gorgoro").on("click",function() {
     var x = Math.floor(Math.random() * quoteList.length);
    //concat var text with line below
     $("#quote").html(quoteList[x].quote);
     $("#author").html(quoteList[x].author);
  });
});
Marc Vincent Ong
@marcvincentong
Apr 10 2016 09:05
Hey guys, how would you guys deal with this question?

function factorialize(num) {
return num!;
}

factorialize(5);

Can't get the function running
Frank XC
@tenkdayz
Apr 10 2016 09:06
so var text has to end up being something like "asdfa"+quoteList[x].quote+quoteList[x].author ?
Benjamin Gonzalez
@xasuma
Apr 10 2016 09:07
yes @tenkdayz
well no actually,only "asdfa" + $("#quote").html(quoteList[x].quote);
Frank XC
@tenkdayz
Apr 10 2016 09:07
have you tried text+=quoteL[x].quote;
Marc Vincent Ong
@marcvincentong
Apr 10 2016 09:08
.
ElvisTheStriker
@ElvisTheStriker
Apr 10 2016 09:18
hi @marcvincentong , you could try a for loop e.g for (var i =1; i<=num:i++){ y = y * i;} where y is a var
Marc Vincent Ong
@marcvincentong
Apr 10 2016 09:19
@ElvisTheStriker just got it, thanks :)
CamperBot
@camperbot
Apr 10 2016 09:19
marcvincentong sends brownie points to @elvisthestriker :sparkles: :thumbsup: :sparkles:
:star: 273 | @elvisthestriker | http://www.freecodecamp.com/elvisthestriker
d3spice
@Earth97
Apr 10 2016 09:25
Hello, I've a problem with my function: it works, but returns "null" when "NaN" is processed.
e.g. http://prntscr.com/aqez87 - returns [7, "ate", null, 9]. Any advice?
Frank XC
@tenkdayz
Apr 10 2016 09:27
@Earth97 what does it suppose to do?
d3spice
@Earth97
Apr 10 2016 09:27
It should remove all falsy values in the given array.
Frank XC
@tenkdayz
Apr 10 2016 09:30
arr.filter(function(val){ if(Boolean(val)){return true;}else{return false;}})
something like that?
Andrew McKeever
@andmckvr13
Apr 10 2016 09:30
help mutations
CamperBot
@camperbot
Apr 10 2016 09:30

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
Greg Duncan
@GregatGit
Apr 10 2016 09:30
@xasuma why would you want to join "sasds" or whatever to the quote?
Frank XC
@tenkdayz
Apr 10 2016 09:31
@GregatGit that was just a random string.
per se
d3spice
@Earth97
Apr 10 2016 09:31
@tenkdayz Yes, that's the function I'm using.
Greg Duncan
@GregatGit
Apr 10 2016 09:32
@tenkdayz and why would you need to join any random string to the quote
or any string
Frank XC
@tenkdayz
Apr 10 2016 09:32
@GregatGit it's like saying "somestring"
as example
@Earth97 oh so it should work
Greg Duncan
@GregatGit
Apr 10 2016 09:33
@tenkdayz but why would he need to join that or any string to a quote
d3spice
@Earth97
Apr 10 2016 09:34
case NaN should return false and make the function remove that NaN from the Array. However, it returns a "null" in the array. Could you test it? I'll write it here.

function bouncer(arr) {
// Don't show a false ID to this bouncer.
function filterF(val) {
switch (val) {
case NaN:
case undefined:
case false:
case null:
case 0:
case "":

  return false;

}

return true;

}
return arr.filter(filterF);
}

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

Frank XC
@tenkdayz
Apr 10 2016 09:35
@GregatGit it's for a project.. he had trouble joining a obj's property to a existing string.
@Earth97 get rid of the switch statement
Aung Myo Kyaw
@AungMyoKyaw
Apr 10 2016 09:38
var source={a:"a",b:"b"}
var amk = Object.keys(source);
  //console.log(amk);
  for (var i=0 ; i<amk.length ; i ++){
    console.log(source.amk[i]);
  }
i got this error message.
Uncaught TypeError: Cannot read property '0' of undefined
pls help me
d3spice
@Earth97
Apr 10 2016 09:39
@tenkdayz I got that, still I wonder: why doesn't it work for "NaN"?
Frank XC
@tenkdayz
Apr 10 2016 09:43
@Earth97 instead of returning true is should return val
Stephane
@overmelo
Apr 10 2016 09:43
var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split("\\s+");
can anyone tell me what is wrong here
Eldar Tinjić
@EldarT90
Apr 10 2016 09:43
@alpox tnx
CamperBot
@camperbot
Apr 10 2016 09:43
eldart90 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 505 | @alpox | http://www.freecodecamp.com/alpox
Greg Duncan
@GregatGit
Apr 10 2016 09:43
@AungMyoKyaw source does not have a property called amk
Vitor Lory
@vlory73
Apr 10 2016 09:44
@overmelo why not split with spaces?
Aung Myo Kyaw
@AungMyoKyaw
Apr 10 2016 09:45
@GregatGit amk[i]
Stephane
@overmelo
Apr 10 2016 09:45
@vlory73 thats what im trying to do but i don't know what to do
Andrew McKeever
@andmckvr13
Apr 10 2016 09:45
function mutation(arr) {
  var newArr = [];
  for (var i = 0; i < arr.length; i++) {
    newArr.push(arr[i].toLowerCase().split(''));
  }

  return newArr[1].indexOf(newArr[0]) !== -1;
 //boolean, case  and order ignored. .slice should be used somewhere
} 


mutation(["Hello", "Hey"]);
Vitor Lory
@vlory73
Apr 10 2016 09:45
`
d3spice
@Earth97
Apr 10 2016 09:45
@AungMyoKyaw
var source={a:"a",b:"b"}
var amk = Object.keys(source);
console.log(amk);
for (var i=0 ; i<amk.length ; i ++){
console.log(source[amk[i]]);
}
Vitor Lory
@vlory73
Apr 10 2016 09:45
" " @overmelo
d3spice
@Earth97
Apr 10 2016 09:46
@AungMyoKyaw replace that source.amk[i] with source[amk[i]]
Aung Myo Kyaw
@AungMyoKyaw
Apr 10 2016 09:46
@Earth97 thanks bro . i got it.
CamperBot
@camperbot
Apr 10 2016 09:46
aungmyokyaw sends brownie points to @earth97 :sparkles: :thumbsup: :sparkles:
Stephane
@overmelo
Apr 10 2016 09:46
@vlory73 nice one, i did it
CamperBot
@camperbot
Apr 10 2016 09:46
:star: 266 | @earth97 | http://www.freecodecamp.com/earth97
Andrew McKeever
@andmckvr13
Apr 10 2016 09:46
I'm stuck why this code isnt working for mutations
Greg Duncan
@GregatGit
Apr 10 2016 09:47
@andmckvr13
var source={a:"a",b:"b"};
var amk = Object.keys(source);
  console.log(amk);
  //console.log(source.amk[0]);
  for (var i = 0 ; i < amk.length ; i ++){
    console.log(amk[i]);
  }
Frank XC
@tenkdayz
Apr 10 2016 09:48
@andmckvr13 you have to check every single letter .. not the string.
Aung Myo Kyaw
@AungMyoKyaw
Apr 10 2016 09:48
i confuse about . notation and bracket notation.
i think . is only used for object.
Son
@sntruong12
Apr 10 2016 09:48

helpppp! I'm in the "Escape Sequence in Strings" lesson.
Instructions:
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr

var myStr = "\\ \t \t \r \n";

why isn't my code working?

negyvenketto
@negyvenketto
Apr 10 2016 09:50
@sntruong12 i just checked, my solution was the exact same, so it should work...
Son
@sntruong12
Apr 10 2016 09:51
...hmm maybe it's being buggy?
@negyvenketto ^^
Islam Ibakaev
@dagman
Apr 10 2016 09:51
@GregatGit you can use Object.values
negyvenketto
@negyvenketto
Apr 10 2016 09:52
@sntruong12 might be. try reloading the page?
d3spice
@Earth97
Apr 10 2016 09:53
@tenkdayz Why val and not true? If the function returns true, val is put into the Array. What happens when val is returned?
Greg Duncan
@GregatGit
Apr 10 2016 09:54
@AungMyoKyaw I would recomend changing the value when playing testing so when you get 'a' you know which 'a' it is so var source={A:"a" ,B:"b"};
Islam Ibakaev
@dagman
Apr 10 2016 09:55
i saw some people build tictactoe game using canvas? Is it prefferable to build it in canvas?
Son
@sntruong12
Apr 10 2016 09:55
@negyvenketto i tried this. i reloaded the page. no luck.
Any suggestions?
negyvenketto
@negyvenketto
Apr 10 2016 09:57
@sntruong12 copy your code, reset the challenge and paste your code? or maybe link it here and i'll see if it passes for me
Son
@sntruong12
Apr 10 2016 09:58
@negyvenketto just did that. thank you kinfolk.
CamperBot
@camperbot
Apr 10 2016 09:58
sntruong12 sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 343 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
negyvenketto
@negyvenketto
Apr 10 2016 09:59
@sntruong12 it worked?
Son
@sntruong12
Apr 10 2016 10:00
@negyvenketto yes! I reset the code and input my same code. worked just fine. Thanks again.
CamperBot
@camperbot
Apr 10 2016 10:00
sntruong12 sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:warning: sntruong12 already gave negyvenketto points
negyvenketto
@negyvenketto
Apr 10 2016 10:00
@sntruong12 yaaay :D
Son
@sntruong12
Apr 10 2016 10:02
freeCodeCamp being buggy tonight or errr this morning.
negyvenketto
@negyvenketto
Apr 10 2016 10:05
yeah. or this afternoon :D
Frank XC
@tenkdayz
Apr 10 2016 10:06
@Earth97 .filter expects a value to be returned.
d3spice
@Earth97
Apr 10 2016 10:09
@tenkdayz filter() calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a true value or a value that coerces to true.
Aung Myo Kyaw
@AungMyoKyaw
Apr 10 2016 10:11
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var amk = Object.keys(source);
  //console.log(amk);
  for (var i=0 ; i<amk.length ; i ++){
    //console.log(source[amk[i]]);
    for(var j=0 ; j<collection.length ; j++){

      if(collection[j].hasOwnProperty(amk[i]) && collection[j][amk[i]]===source[amk[i]]){
        arr.push(collection[j]);
        //console.log(arr);
      }
    }
  }
  // Only change code above this line
  console.log(arr);
  return arr;
}
i fail the following tests.
whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 }) 
whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 })
d3spice
@Earth97
Apr 10 2016 10:12
my callback is filterF (switch inside this function). That switch returns true for any value and false for "case" values. "NaN" is one of those case values, but "null" is inserted in the final Array instead of nothing.
can't judge where I am going worng
pls help
?
can anybody help?
Aniruddh Agarwal
@anrddh
Apr 10 2016 10:17
@shivamarora13 Show me what you have rn!
Frank XC
@tenkdayz
Apr 10 2016 10:18

@Earth97

arr.filter(function(num){
    return num<10;
});

here if num == 11 the statement is false .. return false. if num ==5 statement is true .. return num.. that how it works as far as I know.

Elbert Cortez
@trip16661
Apr 10 2016 10:19
$(document).ready(function() {
  var wikiApi = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts%7Cinfo&generator=search&exchars=500&exlimit=20&exintro=1&inprop=url&gsrsearch="

  var searchInp;
  // Links needed for the api

  $("#delete").hide();
  $("#search").on("submit", function() {
    searchInp = $("#searchInp").val();
    var finalApi = wikiApi + searchInp + "&callback=?";
    $.getJSON(finalApi, function (data) {
        shortCut = data.query.pages
        $.each(shortCut, function (i, ids) {
          $("wikiQuery").html("<h4 href="+ids.fullurl+">"+ ids.title +  "</h4>" + "<br>" )  
        })

    });


  })

})
mby im doing something wrong ?
alpox
@alpox
Apr 10 2016 10:23
@trip16661 try it with a return false atet he end of your submit function (after $.getJSON)
@trip16661 Or remove the form around your submit button or make your button not of type submit
Sidharth Kriplani
@sidkrip
Apr 10 2016 10:23
Hey @alpox ! how are you?
alpox
@alpox
Apr 10 2016 10:24
@sidkrip Hi there :-) I'm good and you?
Sidharth Kriplani
@sidkrip
Apr 10 2016 10:24
Terrific as usual :D
have you done the intermediate projects though?
ALMY91
@ALMY91
Apr 10 2016 10:26
my 15min break bcam a 3hr break zzz
looks like i'd be pulling an all nighter today
alpox
@alpox
Apr 10 2016 10:26
This message was deleted
ALMY91
@ALMY91
Apr 10 2016 10:26
and i still hv to be at work by 9am ...
alpox
@alpox
Apr 10 2016 10:26
@sidkrip Wait projects... let me see :D
Sidharth Kriplani
@sidkrip
Apr 10 2016 10:27
@alpox awesome! I need help. A lot of it :D
alpox
@alpox
Apr 10 2016 10:27
@sidkrip Yup i did :D
d3spice
@Earth97
Apr 10 2016 10:28
@tenkdayz filter() takes num from the array and gives it to callback. If callback returns true (or num), num is put into a new array. If callback returns false, num will be omitted.
"return true" and "return num" should produce the same Array.
return num (as you suggested) works, return true works for every value except for "NaN". I can't understand the reason why this happens. At any rate, thank you for your help.
CamperBot
@camperbot
Apr 10 2016 10:28
earth97 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 363 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Andrew McKeever
@andmckvr13
Apr 10 2016 10:38
wiki falsy bouncer
CamperBot
@camperbot
Apr 10 2016 10:38

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

cliffeo
@cliffeo
Apr 10 2016 10:38
I'm having trouble with challenge 179, I've added
var loc = "myVar";
And then removed the second "console.log(myVar);"
Anyone have any idea?
Brendan Kinahan
@BKinahan
Apr 10 2016 10:39
@cliffeo the variable should be called myVar not loc
and it doesn't need an assigned value
Eldar Tinjić
@EldarT90
Apr 10 2016 10:40
@alpox tnx
CamperBot
@camperbot
Apr 10 2016 10:40