These are chat archives for FreeCodeCamp/HelpJavaScript

31st
Jan 2016
kiel barry
@kielbarry
Jan 31 2016 00:02
function lookUp(firstName, prop){
// Only change code below this line
  for (var i = 0; i<contacts.length;i++){
    if (firstName === contacts[i]["firstName"] && contacts.hasOwnProperty(prop)){
      return contacts[i][prop];
    }
    else {return "No such property";}
  }
// Only change code above this line
}
looking up objects within objects
objects within an array actually
Marek Slabicki
@thaniri
Jan 31 2016 00:17
is there some sort of trick to passing the Local Scope and Functions challenge?
i have a correct answer
rphares
@rphares
Jan 31 2016 00:17
@thaniri , possibly--
can you paste what you have?
Marek Slabicki
@thaniri
Jan 31 2016 00:17
function myFunction() {
  myVar = 1;
  console.log(myVar);
}
myFunction();

// run and check the console 
// myVar is not defined outside of myFunction

// now remove the console log line to pass the test
rphares
@rphares
Jan 31 2016 00:17
(there are three steps to that one...)
okay cool--
refresh and run tests again :)
Marek Slabicki
@thaniri
Jan 31 2016 00:17
i have copy pasted answers from other people who have passed the challenge
and refreshed multiple times
rphares
@rphares
Jan 31 2016 00:18
refreshing should do it--
you can clear your.... cache is it?
Marek Slabicki
@thaniri
Jan 31 2016 00:18
will do
Robert Saunders
@SirUncleCid
Jan 31 2016 00:18
does reset do anything?
rphares
@rphares
Jan 31 2016 00:18
im not good at computers in general, but when you fail the first time, you create an error,
@SirUncleCid , yes
usually refreshing is enough
to get rid of the maximum call stack that running it the firs time creates
dunno why his is bad, but saw some one tell them to clear cache and re-run and that worked for them,
so thats my next guess shrug
opening in another browser will also do it, supposedly
dsousadev
@dsousadev
Jan 31 2016 00:20
"Check if a string (first argument) ends with the given target string (second argument)."
function end(str, target) {

  return str.substring(str[str.length+1]) == target;

}
Marek Slabicki
@thaniri
Jan 31 2016 00:20
clearing cache didnt do anything >>
dsousadev
@dsousadev
Jan 31 2016 00:20
any tips on this one^
Marek Slabicki
@thaniri
Jan 31 2016 00:20
try a regular expression
rphares
@rphares
Jan 31 2016 00:21
@thaniri , try another browser? :point_up: January 31, 2016 7:18 AM
Marek Slabicki
@thaniri
Jan 31 2016 00:21
/anyWord/g should find "anyWord"
rphares
@rphares
Jan 31 2016 00:22
oh
@thaniri , yours isn't right,
you should be using the var keyword in that function...
Brett
@BLayman
Jan 31 2016 00:23

I'm having a really strange issue on the "Chunky Monkey" problem. My for loop pushes every array it makes except when i = 4 and size = 6. I don't get it. Here's my code:

function chunk(arr, size) {
  // Break it up.
 var slicedArray = [];
  var completeArray = [];

for (i=0; i <= arr.length; i += size, size += size){
  if (size > arr.length + 1){
    size = arr.length + 1;
  }
  slicedArray = arr.slice(i,size);
completeArray.push(slicedArray); 
  }
  return completeArray;
}

chunk([0, 1, 2, 3, 4, 5, 6], 2);

I'm not sure if the "if" conditional is necessary. I put it in there to try to solve this issue, and it didn't help. The resulting array is [[0,1],[2,3],[6]].

Marek Slabicki
@thaniri
Jan 31 2016 00:23
still doesn't work
it thinks that a global variable exists still
rphares
@rphares
Jan 31 2016 00:23
can you paste it with the var keyword, refresh, and run tests again?
Marek Slabicki
@thaniri
Jan 31 2016 00:23
function myFunction() {
   var myVar = 1;


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

// run and check the console 
// myVar is not defined outside of myFunction

// now remove the console log line to pass the test
rphares
@rphares
Jan 31 2016 00:23
( is ee the level you are helping at, I'm not insulting your ability...)
Marek Slabicki
@thaniri
Jan 31 2016 00:24
thanks @rphares
CamperBot
@camperbot
Jan 31 2016 00:24
thaniri sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2221 | @rphares | http://www.freecodecamp.com/rphares
Marek Slabicki
@thaniri
Jan 31 2016 00:24
i'd love to know what the hell was going wrong
rphares
@rphares
Jan 31 2016 00:24
hmm, you can try resetting the code and pasting again?
Marek Slabicki
@thaniri
Jan 31 2016 00:24
it works now, but that was dumb
rphares
@rphares
Jan 31 2016 00:24
ah, phew--
yeah, it wants the var keyword, thats part of the test,
and then it wants you to delete it,
but, unfortunately, once you run it with the global guy,
you create that error,
so you have to get rid of it,
the steps have to go in order,
glad you passed and happy coding!
Marek Slabicki
@thaniri
Jan 31 2016 00:25
happy coding to you too
rphares
@rphares
Jan 31 2016 00:26
(btw, there are a few more that maximum call stack will crop up on... refresh, refresh, refresh :) )
kiel barry
@kielbarry
Jan 31 2016 00:26
any help on profile lookup?
Karweck
@Karweck
Jan 31 2016 00:28
I am having trouble getting the array.filter method to work in the falsy bouncer challange, how does it even work? The documentation doe a poor job explaining it...
dsousadev
@dsousadev
Jan 31 2016 00:35
@Karweck paste your code
@declanPaz Also paste your code
Matt McCarley
@mdmccarley89
Jan 31 2016 00:35
any help with Generate Random Fractions with JavaScript?

function myFunction() {

// Only change code below this line.

return Math.random();

// Only change code above this line.
}

dsousadev
@dsousadev
Jan 31 2016 00:36
@mdmccarley89 what is the prompt asking you to do for that one?
Matt McCarley
@mdmccarley89
Jan 31 2016 00:36
Change myFunction to return a random number instead of returning 0.
rphares
@rphares
Jan 31 2016 00:38
@mdmccarley89 , did you change anything below the line?
Matt McCarley
@mdmccarley89
Jan 31 2016 00:38
nope
dsousadev
@dsousadev
Jan 31 2016 00:38
hmm your code seems right then.
@mdmccarley89 the only thing i can think of is that math.random also includes 0
rphares
@rphares
Jan 31 2016 00:38
refresh/reset and try again?
Matt McCarley
@mdmccarley89
Jan 31 2016 00:39
That's what I thought but it only returns a zero and I can't figure out why. I looked at other camper's solutions and they did put code below the line but I don't understand their reasoning so it didn't help much. I've reset multiple times and still won't work.
rphares
@rphares
Jan 31 2016 00:39
i mean, maybe I'm missing something but...
function myFunction() {

  // Only change code below this line.

  return Math.random();

  // Only change code above this line.
}

(function(){return myFunction();})();
dsousadev
@dsousadev
Jan 31 2016 00:39
@mdmccarley89 yeah sounds like an issue with your browser. try restarting it and then run the code again
rphares
@rphares
Jan 31 2016 00:39
( i don't usually paste answers, but.... i am not seeing the difference...)
(beyond the bottom line, obs)
(but I'm assuming you still have that)
dsousadev
@dsousadev
Jan 31 2016 00:40
@rphares have you done the "confirm the ending" challenge?
rphares
@rphares
Jan 31 2016 00:41
@dsousadev , yes, but its another one of those that i can't explain concepts on, only point out things that are different in our code..
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:41
could I get some help, I am not sure why myArray is not adding the two numbers?
dsousadev
@dsousadev
Jan 31 2016 00:41
function end(str, target) {

  return str.substring(str[str.length+1]) == target;

}
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:41
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myArray=[0][0];
myArray=[2][4];
rphares
@rphares
Jan 31 2016 00:42
@dsousadev , i used an if /else, so we are way different
@TheKingIsHere , you aren't trying to add number in that one, if i recall--
are you on accessing multidimiensional arrays?
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:42
@rphares yes
Skye
@cieloskye
Jan 31 2016 00:43

Can someone please help me with the JavaScript "Return Early Pattern for Functions"? I'm getting an error that negative numbers are not returning as "undefined", however they are outputting as "undefined" when I run my code. ```js
// Setup
function abTest(a, b) {
// Only change code below this line
if (a<0)
return "undefined";
if (b<0)
return "undefined";
// Only change code above this line

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

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

rphares
@rphares
Jan 31 2016 00:43
@TheKingIsHere , so you are trying to FIND 8
@cieloskye , two things,
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:43
@rphares correct
rphares
@rphares
Jan 31 2016 00:43
you can use one conditional,
dsousadev
@dsousadev
Jan 31 2016 00:43
@rphares is your if statement comparison similar to if(str.substring(str.length+1) == target
Guzman Monne
@guzmonne
Jan 31 2016 00:43
@TheKingIsHere It is one big array at first, then you have to start getting into it.
rphares
@rphares
Jan 31 2016 00:43
if (a is less than zero OR if b is less than zero) @cieloskye
and, undefined is a special value, @cieloskye
"undefined" is just a string
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:43
@rphares so would i need to insert the corresponding number for 8?
rphares
@rphares
Jan 31 2016 00:44
@TheKingIsHere , sometimes it is easier to look like this,
[[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]];
@TheKingIsHere
so-- which set is it in, [0], [1], or [2]? @TheKingIsHere
(remember indexing starts at 0...)
Guzman Monne
@guzmonne
Jan 31 2016 00:45
@TheKingIsHere and you are lookin for the second element, of the third element, of the main array; so to speak...
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:45
@rphares 2
rphares
@rphares
Jan 31 2016 00:45
yep,
then, which number in [7,8,9],is it, [0], [1], or [2]? @TheKingIsHere
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:46
@rphares 1
rphares
@rphares
Jan 31 2016 00:46
yep! so you can just chain them together,
example of getting through two layers of arrayBob:
arrayBob[4][1];
Andrew Charlebois
@andrewchar
Jan 31 2016 00:47
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  myObj.hasOwnProperty("gift");
  myObj.hasOwnProperty("pet");
  myObj.hasOwnProperty("house");
 return myObj;
}


// Test your code by modifying these values
checkObj("gift");
What have I done wrong?
Bartek
@dyczol
Jan 31 2016 00:47

hey everyone. SPOILER ALERT to "word blanks". so I passed this challenge with the following code, but I don't understand why this code passes this requirement : "wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib)." ```js
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = " " + myAdjective +" "+ myNoun + " " + myVerb + " " + myAdverb + " " + " ";
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
```

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

result = " " + myAdjective +" "+ myNoun + " " + myVerb + " " + myAdverb + " " + " ";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
rphares
@rphares
Jan 31 2016 00:47
we use this kind of multidimensional indexing a lot :) its useful to break it down, for me at least, @TheKingIsHere :blushL:
Skye
@cieloskye
Jan 31 2016 00:48

@rphares Like this?: // Setup
function abTest(a, b) {
// Only change code below this line
if ((a<0) OR (b<0))
return undefined;

// Only change code above this line

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

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

rphares
@rphares
Jan 31 2016 00:48
@dyczol , you have the right idea
Skye
@cieloskye
Jan 31 2016 00:48
I'm missing something...
rphares
@rphares
Jan 31 2016 00:48
i think it won't like the spaces at the beginning or the end, though @dyczol
@cieloskye , close, but i was giving you pseudo
you want to use the || in that conditional,
Micky
@MickyD94
Jan 31 2016 00:49
Hey does anyone know anything about the NaN variable? I can't seem to get my function to work for the Falsy Bouncer exercise
function bouncer(arr) {

  var myArray = arr.filter(function(val) {
             return val !== false;
             });

  var arrA = myArray.filter(function(val){
    return val !== null;
  });

  var arrB = arrA.filter(function(val){
    return val !== 0;
  });

  var arrC = arrB.filter(function(val){
    return val !== "";
  });

  var arrD = arrC.filter(function(val){
    return val !== undefined;
  });

  var arrE = arrD.filter(function(val){
    return val !== isNaN;
  });

  // Don't show a false ID to this bouncer.
  return arrE;
}


bouncer([false, null, 0, NaN, undefined, ""]);
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:49
@rphares link the number together and it is still not working
rphares
@rphares
Jan 31 2016 00:49
if (a is less than zero || if b is less than zero) @cieloskye
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:49
````
Bartek
@dyczol
Jan 31 2016 00:49
@rphares so i passed the challenge but I don't know how does it satisfy these words: "cat", "little", "hit", "slowly"
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:49
// Only change code below this line.
var myArray=[0][0];
myArray=[2] [1];
rphares
@rphares
Jan 31 2016 00:49
@TheKingIsHere , did you put it all in myData?
Skye
@cieloskye
Jan 31 2016 00:49
@rphares Got it! Thank you for your help!
CamperBot
@camperbot
Jan 31 2016 00:49
cieloskye sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2222 | @rphares | http://www.freecodecamp.com/rphares
anthonygallina1
@anthonygallina1
Jan 31 2016 00:49
@andrewchar your function has to actuallt checkProp
actually
rphares
@rphares
Jan 31 2016 00:50
ah-- @TheKingIsHere , you need to set myData =
you don't need the first line, and the second line should be
var myData = nameOfArray[firstIndex][secondIndex]
@TheKingIsHere
no spaces,
using the indexes we just talked about and the correct name of your array you are using :)
anthonygallina1
@anthonygallina1
Jan 31 2016 00:51
@andrewchar and maybe a if and else would help
rphares
@rphares
Jan 31 2016 00:51
@dyczol , so, you put in those parameters, right?
and, then, the tests calls them,
TheKingIsHere
@TheKingIsHere
Jan 31 2016 00:51
@rphares thanks
CamperBot
@camperbot
Jan 31 2016 00:51
thekingishere sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2223 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 31 2016 00:52
so, basically, any words that are called for myNoun, myAdjective, etc will take those places... @dyczol
Micky
@MickyD94
Jan 31 2016 00:52
Can anyone explain why my code isn't returning an empty array? :/
function bouncer(arr) {

  var myArray = arr.filter(function(val) {
             return val !== false;
             });

  var arrA = myArray.filter(function(val){
    return val !== null;
  });

  var arrB = arrA.filter(function(val){
    return val !== 0;
  });

  var arrC = arrB.filter(function(val){
    return val !== "";
  });

  var arrD = arrC.filter(function(val){
    return val !== undefined;
  });

  var arrE = arrD.filter(function(val){
    return val !== isNaN;
  });

  // Don't show a false ID to this bouncer.
  return arrE;
}


bouncer([false, null, 0, NaN, undefined, ""]);
rphares
@rphares
Jan 31 2016 00:52
so if you put in dog and big for myNoun and myAdjective, @dyczol , then your output would changed--
the point of building that function is that it is reusable with whatever you call :)
@cieloskye , @TheKingIsHere , anytime! :)
Brett
@BLayman
Jan 31 2016 00:54

Anyone else have thoughts on this? I'm having an issue on the "Chunky Monkey" problem. My for loop pushes every array it makes except when i = 4 and size = 6. I don't get it. Here's my code:

function chunk(arr, size) {
  // Break it up.
 var slicedArray = [];
  var completeArray = [];

for (i=0; i <= arr.length; i += size, size += size){
  if (size > arr.length + 1){
    size = arr.length + 1;
  }
  slicedArray = arr.slice(i,size);
completeArray.push(slicedArray); 
  }
  return completeArray;
}

chunk([0, 1, 2, 3, 4, 5, 6], 2);

I'm not sure if the "if" conditional is necessary. I put it in there to try to solve this issue, and it didn't help. The resulting array is [[0,1],[2,3],[6]].

Bartek
@dyczol
Jan 31 2016 00:54
@rphares gotcha, because rather then var result being specified it is var result = ""
rphares
@rphares
Jan 31 2016 00:56
at the beginning, it was blank, yep. and then you set it to your :smile:
result = " " + myAdjective +" "+ myNoun + " " + myVerb + " " + myAdverb + " " + " ";
so now that can take anything you want for those words :)
Brett
@BLayman
Jan 31 2016 00:56
At least in this case it's when i = 4 and size = 6. It might depend on the array.
Bartek
@dyczol
Jan 31 2016 00:58
@rphares thanks ! got it. just wanted to make sure I knew what I did :D
CamperBot
@camperbot
Jan 31 2016 00:58
dyczol sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2225 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 31 2016 00:59
anytime!
Evan
@CodeDraken
Jan 31 2016 00:59
I'm completely lost on javascript 181 stand in line any help?
rphares
@rphares
Jan 31 2016 00:59
@evan153 , i can't help much on that-- but reviewing push and shift may be useful ;)
anthonygallina1
@anthonygallina1
Jan 31 2016 00:59
@evan153 show us your code
Brett
@BLayman
Jan 31 2016 01:00
I think the issue occurs when size === array.length.
Evan
@CodeDraken
Jan 31 2016 01:00

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

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

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

dont even know what its asking to do
rphares
@rphares
Jan 31 2016 01:01
well, if you are gonna return item... you might wanna set that second line...
Guzman Monne
@guzmonne
Jan 31 2016 01:02
@evan153 It is asking you to build a function that pushes an object to the last of an array, while poping the first one from it, and returns it at the same time.
anthonygallina1
@anthonygallina1
Jan 31 2016 01:02
@evan153 return arr.shift(); // Change this line
Guzman Monne
@guzmonne
Jan 31 2016 01:02
@evan153 Have a look at the unshift() method for this.
@evan153 Check what it does and what it outputs.
anthonygallina1
@anthonygallina1
Jan 31 2016 01:02
@rphares thats true
JuanFer253
@juanfer25
Jan 31 2016 01:03
necesito saber como cambiar un if por un switch alguien me ayuda ??
rphares
@rphares
Jan 31 2016 01:03
(lol, i did it pretty much the same way he's trying, even though i have now seen simpler, heh @anthonygallina1 )
anthonygallina1
@anthonygallina1
Jan 31 2016 01:03
@evan153 I would move my globlal var to the top also
rphares @rphares steps out for a few
rphares
@rphares
Jan 31 2016 01:04
(ditto! @anthonygallina1 )
Guzman Monne
@guzmonne
Jan 31 2016 01:04
@juanfer25 Imagina que cada case equivale a una prueba de condición de un if.
JuanFer253
@juanfer25
Jan 31 2016 01:04
thanks @guzmonne
CamperBot
@camperbot
Jan 31 2016 01:04
juanfer25 sends brownie points to @guzmonne :sparkles: :thumbsup: :sparkles:
Pedro Paredes
@mesmerismo
Jan 31 2016 01:04
can someone help me with bonefire no-repeats-please ?
CamperBot
@camperbot
Jan 31 2016 01:04
:star: 227 | @guzmonne | http://www.freecodecamp.com/guzmonne
Pedro Paredes
@mesmerismo
Jan 31 2016 01:05
well.. challenge no-repeats-please
JuanFer253
@juanfer25
Jan 31 2016 01:07
gracias @Francozt01
anthonygallina1
@anthonygallina1
Jan 31 2016 01:08
@rphares did the new ones 3 days after they were out. Alone.
Micky
@MickyD94
Jan 31 2016 01:08
Could anyone give me a hand with the Seek and Destroy challenge please? :)
function destroyer(arr) {
  // Remove all the values
  var myArray = arr;
  for (var i = 0; i < arguments.length; i++){
   myArray = myArray.filter(arguments[i]);

}
      return myArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Evhen
@JaksonFire
Jan 31 2016 01:09
This message was deleted
Franco Zapata
@Francozt01
Jan 31 2016 01:10
@juanfer25 np
kiel barry
@kielbarry
Jan 31 2016 01:11
function reverseString(str) {
  var array = [];
  var len = str.length;
  for (var i = 0; i<len;i++){
    array.push(str.charAt(i));
  }
  array.reverse();
  array.join();
  return array.toString();
}

reverseString("hello");

is returning function reverseString(str) {
var array = [];
var len = str.length;
for (var i = 0; i<len;i++){
array.push(str.charAt(i));
}
array.reverse();
array.join();
return array.toString();
}

reverseString("hello");

Matt McCarley
@mdmccarley89
Jan 31 2016 01:12
Can anyone help with this?
kiel barry
@kielbarry
Jan 31 2016 01:12
is returning * o,l,l,e,h
Matt McCarley
@mdmccarley89
Jan 31 2016 01:13
Make Object Properties Private
anthonygallina1
@anthonygallina1
Jan 31 2016 01:13
so they want it inside the function then?
Matt McCarley
@mdmccarley89
Jan 31 2016 01:14

var Bike = function() {

// Only change code below this line.

var gear = val,; // private

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

};

var myCar = new Car();

var myBike = new Bike();

Evan
@CodeDraken
Jan 31 2016 01:14
I think there's a bug on the javascript tutorial [181]
anthonygallina1
@anthonygallina1
Jan 31 2016 01:14
the reverse?
Micky
@MickyD94
Jan 31 2016 01:14
Can anyone help with my Seek and Destroy problem above? :/
Evan
@CodeDraken
Jan 31 2016 01:14

```function queue(arr, item) {
// Your code here
arr.push(item);
var removed = arr.shift();
return removed; // Change this line
}

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

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

Matt McCarley
@mdmccarley89
Jan 31 2016 01:15
how are people pasting in the nice colored code as is seen on the actual challenge? Sorry, total newb
Evan
@CodeDraken
Jan 31 2016 01:15
lol I also want to know :x:
Micky
@MickyD94
Jan 31 2016 01:15
@mdmccarley89
` ```
Oops
Three of those icons above and below your lines of code
kiel barry
@kielbarry
Jan 31 2016 01:16
function reverseString(str) {
  var array = [];
  var len = str.length;
  for (var i = 0; i<len;i++){
    array.push(str.charAt(i));
  }
  array.reverse();
  array.join("");
  return array.toString();
}

reverseString("hello");
Evan
@CodeDraken
Jan 31 2016 01:16
function queue(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Kept changing code nothing was working so I googled solution tried that and it still just errors.
souphan
@souphan
Jan 31 2016 01:17
@evan153 'm in the same boat as you
Guzman Monne
@guzmonne
Jan 31 2016 01:17
@evan153 you should use the unshift() method instead.
souphan
@souphan
Jan 31 2016 01:17
unshift just adds to the array
Matt McCarley
@mdmccarley89
Jan 31 2016 01:17
var Bike = function() {

  // Only change code below this line.

  var gear = ""; // private


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

};

var myCar = new Car();

var myBike = new Bike();
anthonygallina1
@anthonygallina1
Jan 31 2016 01:17
@evan153 interesting what does that return?
JuanFer253
@juanfer25
Jan 31 2016 01:17
what is my fail??
kiel barry
@kielbarry
Jan 31 2016 01:17
@mdmccarley89 read the instructions more carefully
JuanFer253
@juanfer25
Jan 31 2016 01:17
switch (val){
case 1: (val === 42)
answer = "The Answer";
break;
case 2: (val === 1)
answer = "There is no #1";
break;
case 3: (val === 99)
answer = "Missed me by this much!";
break;
case 4: (val === 7)
answer = "Ate Nine";
break;
}
cual es mi fallo??
kiel barry
@kielbarry
Jan 31 2016 01:18
there is instructions for what set gear and get gear should do
Evan
@CodeDraken
Jan 31 2016 01:18
@anthonygallina1 RangeError : Maximum call stack size exceeded
Guzman Monne
@guzmonne
Jan 31 2016 01:18
@juanfer25 no tenes que poner val === 42 solo 42. Y asi con los demás.
@souphan You are rigth. The correct answer is whith shift. My mistake.
Evan
@CodeDraken
Jan 31 2016 01:19
@guzmonne Tried unshift, didn't work. The tutorial also says to add it to the end of the array specifically.
JuanFer253
@juanfer25
Jan 31 2016 01:19
ya
pero no paso
anthonygallina1
@anthonygallina1
Jan 31 2016 01:19
@evan153 try moving your global var to the top
JuanFer253
@juanfer25
Jan 31 2016 01:20
@guzmonne ayudame es asi switch (val)
case 1: (42)
answer = "The Answer";
break;
case 2: (1)
answer = "There is no #1";
break;
case 3: (99)
answer = "Missed me by this much!";
break;
case 4: (7)
answer = "Ate Nine";
break;?'??
Guzman Monne
@guzmonne
Jan 31 2016 01:20
@juanfer25 si pones case 2: en realidad vas a probar si val es igual a 2.
Evan
@CodeDraken
Jan 31 2016 01:20
@anthonygallina1 Same error this is weird :worried:
Joanna M. Rives
@jm-rives
Jan 31 2016 01:21
@mdmccarley89 Highlight the code snippet you wish to share, right click and you should see a prompt that ask is you would like to copy the snippet as "pretty code". Click pretty code and paste it as you like.
JuanFer253
@juanfer25
Jan 31 2016 01:21
@guzmonne como asi ??
matthew3454
@matthew3454
Jan 31 2016 01:21
Can someone please help me with the waypoint Profile Lookup?
Guzman Monne
@guzmonne
Jan 31 2016 01:21
@juanfer25 tienes que poner case 42: answer = "The Answer"; break; y asi con las demás.
JuanFer253
@juanfer25
Jan 31 2016 01:21
ya
rphares
@rphares
Jan 31 2016 01:21
@juanfer25 , you don't want to change the case names,
anthonygallina1
@anthonygallina1
Jan 31 2016 01:22
@evan153 need to push then shift also
rphares
@rphares
Jan 31 2016 01:22
i believe the were funny, something like "bob"and 99 @juanfer25
JuanFer253
@juanfer25
Jan 31 2016 01:22
@guzmonne switch (val)
case 42:
answer = "The Answer";
break;
case 1:
answer = "There is no #1";
break;
case 7: (99)
answer = "Missed me by this much!";
break;
case 156: (7)
answer = "Ate Nine";
break;
yap o no ??
souphan
@souphan
Jan 31 2016 01:23
This is what the code expects to return : function queue([5,6,7,8,9], 1) should return 5
so that arr should shift out 5 and return it
anthonygallina1
@anthonygallina1
Jan 31 2016 01:23
yes
souphan
@souphan
Jan 31 2016 01:23
add 1 to the end of the array
Guzman Monne
@guzmonne
Jan 31 2016 01:23
@juanfer25 no entiendo los parentesis que pones despues del case? No va ninguno de ellos.
KyleFolk
@KyleFolk
Jan 31 2016 01:24

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

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

return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
Not sure what's wrong with my code?

Ben Haack
@skyhy
Jan 31 2016 01:24
@evan153 @souphan this is mine, it doesn't work properly for me either:
function queue(arr, item) {
testArr.push(item);
arr = testArr.shift();
  return arr;
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
queue([5,6,7,8,9], 1) should return 5 is my error
everything else works
Guzman Monne
@guzmonne
Jan 31 2016 01:25
@skyhy try using arr.push(item) and returning arr.shift()
Barack
@mishmishilicous1
Jan 31 2016 01:25
Hey, I'm kinda stuck in "Generate Random Fractions with JavaScript".. Why can't I just do
return Math.random();
Is it bc I'm not invoking the function?
Ben Haack
@skyhy
Jan 31 2016 01:26
@guzmonne nope, that makes it worse
Guzman Monne
@guzmonne
Jan 31 2016 01:26
@skyhy you are re-defining arr, which is not necessary. Also testArr is undefined inside your function and will fail unless there is a global with the same name.
Evan
@CodeDraken
Jan 31 2016 01:26
function queue(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}

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

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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
None of these methods work nor skyhy's method.
anthonygallina1
@anthonygallina1
Jan 31 2016 01:26
@skyhy return the shift
Bartek
@dyczol
Jan 31 2016 01:26
does "range error: maximum call stack size exceeded" means that I have to clean my browser's cache ?
rphares
@rphares
Jan 31 2016 01:26
@dyczol , refreshing often works
Guzman Monne
@guzmonne
Jan 31 2016 01:26
@evan153 If the first one does not work, reload the browser and try again.
rphares
@rphares
Jan 31 2016 01:26
if it doesn't, you can try cleaning cache...
Ben Haack
@skyhy
Jan 31 2016 01:26
@anthonygallina1 " The queue function should then return the element that was removed."
Bartek
@dyczol
Jan 31 2016 01:26
ok
rphares
@rphares
Jan 31 2016 01:27
@mishmishilicous1 , can we see?
you may just need to refresh...
matthew3454
@matthew3454
Jan 31 2016 01:27
What is wrong with my for-loop?
Evan
@CodeDraken
Jan 31 2016 01:27
@guzmonne ctrl + f5 refresh worked..was much more confusing then it should have been lol
matthew3454
@matthew3454
Jan 31 2016 01:27
//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 lookUp(firstName, prop){
// Only change code below this line
 for (var i = 0; i <= contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      return "No such contact";
      // we found that guy! Here you should return the right value
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Barack
@mishmishilicous1
Jan 31 2016 01:28
@rphares yip... refresh did the trick. why is that?
Guzman Monne
@guzmonne
Jan 31 2016 01:28
@evan153 Glad to help.
rphares
@rphares
Jan 31 2016 01:28
@mishmishilicous1 , not certain-- did you try something before that?
Barack
@mishmishilicous1
Jan 31 2016 01:28
yeah
rphares
@rphares
Jan 31 2016 01:28
sometimes we create errors and then need to get rid of them...
JuanFer253
@juanfer25
Jan 31 2016 01:29
@guzmonne grscias por la ayuda ya lo pase
anthonygallina1
@anthonygallina1
Jan 31 2016 01:29
@rphares does it refresh the memory stack ?
Guzman Monne
@guzmonne
Jan 31 2016 01:29
@juanfer25 de nada.
anthonygallina1
@anthonygallina1
Jan 31 2016 01:29
@rphares maybe?
rphares
@rphares
Jan 31 2016 01:30
i think so, based on my limited understanding of call stack, lol @anthonygallina1
anthonygallina1
@anthonygallina1
Jan 31 2016 01:30
@rphares mine too my friend and I am a Tech.
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:30
could I get some help, not sure why myFunction is not defined
rphares
@rphares
Jan 31 2016 01:31
@TheKingIsHere , what challenge?
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:31
// Only change code below this line

function myFunction() {
  console.log("Hi World");
}

myfunction();
Joanna M. Rives
@jm-rives
Jan 31 2016 01:31
This message was deleted
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:31
reusable javascipt with function
Guzman Monne
@guzmonne
Jan 31 2016 01:31
@TheKingIsHere typo on 'F'
rphares
@rphares
Jan 31 2016 01:32
oh, good catch @guzmonne , didn't even need to open it, lol
Franco Zapata
@Francozt01
Jan 31 2016 01:32
Hello Universe
anthonygallina1
@anthonygallina1
Jan 31 2016 01:32
@guzmonne yes!
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:33
@guzmonne thanks
CamperBot
@camperbot
Jan 31 2016 01:33
thekingishere sends brownie points to @guzmonne :sparkles: :thumbsup: :sparkles:
:star: 243 | @guzmonne | http://www.freecodecamp.com/guzmonne
Franco Zapata
@Francozt01
Jan 31 2016 01:33
@anthonygallina1 hey Anthony-hen :D
rphares
@rphares
Jan 31 2016 01:33
WB, @Francozt01 ~
Guzman Monne
@guzmonne
Jan 31 2016 01:33
:D
javathehubb
@javathehubb
Jan 31 2016 01:33
Hi guys, this is my first time using the chat, so not sure exactly how it works. But, I'm having trouble with the Counting Cards function..has anyone done that one?
Marnie Cannon
@roundelay
Jan 31 2016 01:33
I have a question on the Profile Lookup checkpoint (in the Javascript section). I understand that I'm running the for loop to cycle through the "firstName" in each object of the "contacts" array. However, the wiki indicates to place the final return (e.g. return 'No such contact';) outside of the for loop, so that if no matches are found when the for loop runs, the string 'No such contact' returns instead. My question is - when the 'firstName' parameter DOES match a firstName within the contacts array and therefore returns the property value, what in the code is keeping the string 'No such contact' from ALSO returning? I guess the way I read the solution, it seems like you could easily have a match which results in the property value getting returned, and then the last 'No such contact' also gets returned specifically because it exists outside of the for loop. Does that make sense?
JuanFer253
@juanfer25
Jan 31 2016 01:34
@guzmonne necesito ayuda
Franco Zapata
@Francozt01
Jan 31 2016 01:34
@rphares was joking :D
JuanFer253
@juanfer25
Jan 31 2016 01:34
function isLess(a,b) {
  // Fix this code
  return a === b;
}

// Change these values to test
isLess(10, 15);
rphares
@rphares
Jan 31 2016 01:34
@javathehubb ,quite a few i think,
JuanFer253
@juanfer25
Jan 31 2016 01:34
isLess(10,15) should return true
porque no se cumple esa instruccion ??
Franco Zapata
@Francozt01
Jan 31 2016 01:34
@juanfer25 a < b menor q b
rphares
@rphares
Jan 31 2016 01:34
for this room and others, its easiest to state the name of the challenge and paste your code :)
javathehubb
@javathehubb
Jan 31 2016 01:35
thanks, @rphares !
CamperBot
@camperbot
Jan 31 2016 01:35
javathehubb sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2227 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 31 2016 01:35
if people know how to help, they will chime in :blush:
sure thing!
Guzman Monne
@guzmonne
Jan 31 2016 01:35
@juanfer25 Estas evaluando igualdad pero te pide que pruebes que a es menor que b...
Munish Tayal
@munishtayal
Jan 31 2016 01:35
help roman numeral converter
CamperBot
@camperbot
Jan 31 2016 01:35

:point_right: bonfire roman numeral converter [wiki]

Problem Explanation:

  • You will create a program that converts an integer to a roman numeral.
:pencil: read more about bonfire roman numeral converter on the FCC Wiki
JuanFer253
@juanfer25
Jan 31 2016 01:35
@Francozt01 @guzmonne thanks
CamperBot
@camperbot
Jan 31 2016 01:35
juanfer25 sends brownie points to @francozt01 and @guzmonne :sparkles: :thumbsup: :sparkles:
:warning: juanfer25 already gave guzmonne points
:star: 510 | @francozt01 | http://www.freecodecamp.com/francozt01
anthonygallina1
@anthonygallina1
Jan 31 2016 01:35
@Francozt01 Nice part of Americanization my grand parents came from italy and apon entry that is the closest the could get to translation So yes anthony-hen
Franco Zapata
@Francozt01
Jan 31 2016 01:35
@juanfer25 no hay de q
javathehubb
@javathehubb
Jan 31 2016 01:36
Counting Cards:
Franco Zapata
@Francozt01
Jan 31 2016 01:36
@anthonygallina1 i know u told couple days ago :D
anthonygallina1
@anthonygallina1
Jan 31 2016 01:36
@Francozt01 Imagrants
rphares
@rphares
Jan 31 2016 01:36
explain format
CamperBot
@camperbot
Jan 31 2016 01:36

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Franco Zapata
@Francozt01
Jan 31 2016 01:37
@anthonygallina1 there are a lot of funny lastnames when u translate english to spanish
how are u doing btw
Dan
@dee-one
Jan 31 2016 01:38
need help with making madlib in javascript
rphares
@rphares
Jan 31 2016 01:38
sure thing, @dee-one
souphan
@souphan
Jan 31 2016 01:38
Thanks guys. I will try to refresh and try again. Right now I'm still getting "RangeError: Maximum call stack size exceeded" message
Dan
@dee-one
Jan 31 2016 01:38
result = "my" + myAdjective + myNoun + myVerb + "very" + myAdverb;
souphan
@souphan
Jan 31 2016 01:38
I logged off and back in as well
javathehubb
@javathehubb
Jan 31 2016 01:38
Also...super noob question, but how do you paste the colorful, nicely formatted version?
rphares
@rphares
Jan 31 2016 01:38
oh, you are close, @dee-one
Guzman Monne
@guzmonne
Jan 31 2016 01:38
@dee-one Missing spaces?
souphan
@souphan
Jan 31 2016 01:38
cleared browser cache and everything. Hmm I'll keep playing with it
rphares
@rphares
Jan 31 2016 01:38
you just need to add spaces :)
explain format
CamperBot
@camperbot
Jan 31 2016 01:38

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Franco Zapata
@Francozt01
Jan 31 2016 01:38
@dee-one u need to concat all the parameters given + words in between of then to give some sense to the phrase
rphares
@rphares
Jan 31 2016 01:39
@javathehubb :point_up: or copy as pretty code :point_up: January 31, 2016 8:38 AM
javathehubb
@javathehubb
Jan 31 2016 01:39
I tried copy as pretty code and it doesn't work
matthew3454
@matthew3454
Jan 31 2016 01:40
I'm completely lost on the Profile Lookup exercise. Here is my code if someone wants to help:
JuanFer253
@juanfer25
Jan 31 2016 01:40
no entiendo esto
Return Early Pattern for Functions
rphares
@rphares
Jan 31 2016 01:40
then go for format :) @javathehubb :point_up: January 31, 2016 8:38 AM
matthew3454
@matthew3454
Jan 31 2016 01:40
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i <= contacts.length; i++) {
if (contacts[i].firstName === firstName) {
return "No such contact";
Franco Zapata
@Francozt01
Jan 31 2016 01:40
@rphares i have to use copy as pretty cuz my keyboard language doesn't allow to use Ctrl+ Enter xd
JuanFer253
@juanfer25
Jan 31 2016 01:40
// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
matthew3454
@matthew3454
Jan 31 2016 01:40
function lookUp(firstName, prop){
// Only change code below this line
 for (var i = 0; i <= contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      return "No such contact";
JuanFer253
@juanfer25
Jan 31 2016 01:40
Instrucciones ??
abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
mm
rphares
@rphares
Jan 31 2016 01:40
@juanfer25 , you just need to make an if statement,
if (a is less than zero OR if b is less than zero) return undefined...
good chance to use ||
JuanFer253
@juanfer25
Jan 31 2016 01:41
thanks @rphares
CamperBot
@camperbot
Jan 31 2016 01:41
juanfer25 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2228 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 31 2016 01:41
anytime :)
javathehubb
@javathehubb
Jan 31 2016 01:41
```js
var count = 0;

function cc(card) {
  // Only change code below this line

  if (card>=2 && card<7){
    currentCount= count + 1;
  } 
  if (card >=7 && card <10){
    currentCount =currentCount + 0;
  } 
  if (card ===10 || card ==='J' || card==='Q' || card==='K' || card==='A') {
    currentCount= currentCount -1;
  }
  if (currentCount>0){
    return currentCount + "Bet";
  } else if (currentCount < 0){
    return currentCount + " Hold";
  }
```
JuanFer253
@juanfer25
Jan 31 2016 01:41
how use that ||
??
rphares
@rphares
Jan 31 2016 01:42
its or
javathehubb
@javathehubb
Jan 31 2016 01:42
Thanks @rphares !!!
CamperBot
@camperbot
Jan 31 2016 01:42
javathehubb sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: javathehubb already gave rphares points
rphares
@rphares
Jan 31 2016 01:42
so in between the two conditions :) @juanfer25
anytime, @javathehubb !
Dan
@dee-one
Jan 31 2016 01:42
@rphares ok i added " " between the variables and it worked!
javathehubb
@javathehubb
Jan 31 2016 01:42
So, if anyone can help me with the code I just sent, that would be great!!
JuanFer253
@juanfer25
Jan 31 2016 01:42
ok ok
rphares
@rphares
Jan 31 2016 01:42
yay!! congrats, @dee-one !
Dan
@dee-one
Jan 31 2016 01:42
thanks
rphares
@rphares
Jan 31 2016 01:43
cool cool-- let us know if you get stuck there are two mistakes many people often make with that one, @juanfer25 , but i think you can do it :blush:
CamperBot
@camperbot
Jan 31 2016 01:43
holler back!
anthonygallina1
@anthonygallina1
Jan 31 2016 01:44
@Francozt01 doing ok was afk
rphares
@rphares
Jan 31 2016 01:45
@javathehubb , yours is way diff than mine, I'm not gonna be able to help much, but i dont see a space in "Bet", i know that will cause an issue...
Franco Zapata
@Francozt01
Jan 31 2016 01:45
@anthonygallina1 nice :+1:
anthonygallina1
@anthonygallina1
Jan 31 2016 01:45
@Francozt01 having a hard time keeping up with multiple conv But trying to help
Franco Zapata
@Francozt01
Jan 31 2016 01:46
@anthonygallina1 do u work as developer?
javathehubb
@javathehubb
Jan 31 2016 01:46
Ah, thanks for noticing that!
anthonygallina1
@anthonygallina1
Jan 31 2016 01:46
yup dont we all?
Franco Zapata
@Francozt01
Jan 31 2016 01:47
@javathehubb tag his name with an @ is better :+1:
@anthonygallina1 i ask cuz almost 80% of campers are learning :D
rphares
@rphares
Jan 31 2016 01:47
lol, @anthonygallina1 , not all of us :blush:
Bill
@kirah1314
Jan 31 2016 01:47
@javathehubb use some else if instead of 4 if's
anthonygallina1
@anthonygallina1
Jan 31 2016 01:48
@Francozt01 I think FCC is real world. So we all are developing.
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:48
// Only change code below this line.

function myFunction(a,b) {
  console.log(1+2); console.log(7+9);
}

myFunction(1,2);
myFunction(7,9);
Not sure why myFunction(1,2) does not display an output of 3
yoni chanowitz
@yonichanowitz
Jan 31 2016 01:48
Does anyone know where you would use an else after an if, and when it's wrong to?
javathehubb
@javathehubb
Jan 31 2016 01:49
Thanks, @kirah1314 !
CamperBot
@camperbot
Jan 31 2016 01:49
javathehubb sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 906 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Franco Zapata
@Francozt01
Jan 31 2016 01:49
@anthonygallina1 good perspective :+1:
Bill
@kirah1314
Jan 31 2016 01:49
@TheKingIsHere use return instead of console.log and you should be using the function parameters a, b instead of hard coding the numbers
javathehubb
@javathehubb
Jan 31 2016 01:50
I'm just having trouble because the tests are running card sequences i.e. 2,3,4,5,6 but the function only calls one card
anthonygallina1
@anthonygallina1
Jan 31 2016 01:50
@Francozt01 i also work at fullstackwebdesign.net
Franco Zapata
@Francozt01
Jan 31 2016 01:50
@yonichanowitz when u have a default case after 1 statement
javathehubb
@javathehubb
Jan 31 2016 01:50
Using else if didn't fix the problem
Franco Zapata
@Francozt01
Jan 31 2016 01:50
@anthonygallina1 cool :D
rphares
@rphares
Jan 31 2016 01:50
@javathehubb , can you paste what you are trying now?
javathehubb
@javathehubb
Jan 31 2016 01:51
var count = 0;

function cc(card) {
  // Only change code below this line

  if (card>=2 && card<7){
    currentCount= count + 1;
  } 
  else if (card >=7 && card <10){
    currentCount =currentCount + 0;
  } 
  else if (card ===10 || card ==='J' || card==='Q' || card==='K' || card==='A') {
    currentCount= currentCount -1;
  }
  if (currentCount>0){
    return currentCount + " Bet";
  } else if (currentCount < 0){
    return currentCount + " Hold";
  }








  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
And these are the tests: Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
JuanFer253
@juanfer25
Jan 31 2016 01:53
i need help o necesito ayuda en este ejercicio
rphares
@rphares
Jan 31 2016 01:53
its it += and -= if you are adding them that way, @javathehubb ? you don't want to lose the updates you already made to your count...
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:53
@kirah1314 using return vs console.log my output displays 5
rphares
@rphares
Jan 31 2016 01:53
@juanfer25 , two things,
you want it all in one conditional,
so
if (a is less than zero || b is less than zero)
Bill
@kirah1314
Jan 31 2016 01:54
@javathehubb by the way, you can keep track of count instead of making a new variable
javathehubb
@javathehubb
Jan 31 2016 01:54
yeah, that's definitely the biggest problem I'm having @rphares ...trying to figure out how to keep the updates to my counts
Bill
@kirah1314
Jan 31 2016 01:54
@TheKingIsHere post your new codes?
rphares
@rphares
Jan 31 2016 01:54
and, you still need to return, @juanfer25
javathehubb
@javathehubb
Jan 31 2016 01:54
@kirah1314 , how do I keep track of the count?
rphares
@rphares
Jan 31 2016 01:54
you want undefined, which is a special value, @juanfer25
javathehubb
@javathehubb
Jan 31 2016 01:54
That's what I'm having trouble figuring out
TheKingIsHere
@TheKingIsHere
Jan 31 2016 01:54
/ Only change code below this line.

function myFunction(a,b) {
  return(1+2); 
  return(7+9);
}

myFunction(1,2);
myFunction(7,9);
rphares
@rphares
Jan 31 2016 01:55
so be sure to return undefined and not return "undefined" @juanfer25
Marnie Cannon
@roundelay
Jan 31 2016 01:55
@matthew3454 , if your contacts[i].firstName === firstName then you don't want to return "no such contact". You then want to check if the 'prop' parameter is a valid property in the object, and if it is, you would return the value of that property. You'd only return "no such contact" if the firstName was NOT equal to any of the firstNames within the contacts array.
rphares
@rphares
Jan 31 2016 01:55
@TheKingIsHere , don't use numbers in your function, please
use the a and b
JuanFer253
@juanfer25
Jan 31 2016 01:55
@rphares thanks you are amazing
CamperBot
@camperbot
Jan 31 2016 01:55
juanfer25 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: juanfer25 already gave rphares points
rphares
@rphares
Jan 31 2016 01:55
you call them at the bottom
@TheKingIsHere
javathehubb
@javathehubb
Jan 31 2016 01:55
@juanfer25, I had the exact same problem earlier!!
rphares
@rphares
Jan 31 2016 01:55
anytime, @juanfer25 !
rphares
@rphares
Jan 31 2016 01:55
(sorry i can't speak spanish :pensive: )
JuanFer253
@juanfer25
Jan 31 2016 01:55
no hay problema
javathehubb
@javathehubb
Jan 31 2016 01:56
aaaahhh thank you, @kirah1314 !
CamperBot
@camperbot
Jan 31 2016 01:56
javathehubb sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:warning: javathehubb already gave kirah1314 points
rphares
@rphares
Jan 31 2016 01:56
@javathehubb , i didn't do any currentCount =, i just count++; or count +=1;`
javathehubb
@javathehubb
Jan 31 2016 01:56
yes! that's exactly what @kirah1314 just suggested, @rphares ...thanks guys!!!
CamperBot
@camperbot
Jan 31 2016 01:56
javathehubb sends brownie points to @kirah1314 and @rphares :sparkles: :thumbsup: :sparkles:
:warning: javathehubb already gave kirah1314 points
:warning: javathehubb already gave rphares points
rphares
@rphares
Jan 31 2016 01:57
anytime~
Bill
@kirah1314
Jan 31 2016 01:57

@TheKingIsHere when you use this, you're hard-coding the answer:

  return(1+2);

but you should use the function parameters instead like return a + b

JuanFer253
@juanfer25
Jan 31 2016 01:58
thanks @COANelmejor
CamperBot
@camperbot
Jan 31 2016 01:58
juanfer25 sends brownie points to @coanelmejor :sparkles: :thumbsup: :sparkles:
:star: 308 | @coanelmejor | http://www.freecodecamp.com/coanelmejor
James Thomas
@Grizzlr
Jan 31 2016 01:58
Having a bit of trouble with "Make Object Properties Private". Not sure why its not working.
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

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

};

var myCar = new Car();

var myBike = new Bike();
rphares
@rphares
Jan 31 2016 01:58
@Grizzlr , you want to set that gear,
matthew3454
@matthew3454
Jan 31 2016 01:58
@roundelay okay thanks
Bill
@kirah1314
Jan 31 2016 01:58
@javathehubb glad to help, you're almost there :thumbsup:
rphares
@rphares
Jan 31 2016 01:59
not += , i think...
matthew3454
@matthew3454
Jan 31 2016 01:59
@roundelay Thanks
CamperBot
@camperbot
Jan 31 2016 01:59
matthew3454 sends brownie points to @roundelay :sparkles: :thumbsup: :sparkles:
:star: 229 | @roundelay | http://www.freecodecamp.com/roundelay
Franco Zapata
@Francozt01
Jan 31 2016 01:59
@anthonygallina1 what do u think about Codecademy
James Thomas
@Grizzlr
Jan 31 2016 02:00
@rphares I've tried changing it in the private variable and the parameter when calling new Bike(); is there something I'm missing?
Bartek
@dyczol
Jan 31 2016 02:00
hey, I'm stuck on "Stand in Line" challenge. I understand I have to use .push and .shift , but I'm not sure about the code ran by the function. help please ! :)
function queue(arr, item) {
  // Your code here
  arr.push();
  arr.shift();
  return queue;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
rphares
@rphares
Jan 31 2016 02:00
you have them a bit backwards, i think, @Grizzlr
try setting the gear first, with just a =, and using your function(change)
anthonygallina1
@anthonygallina1
Jan 31 2016 02:01
@Francozt01 Let me answer that in a more general way. It is like software. some programs do things better that other programs. So utilize the strengths and dont become brand specific.
rphares
@rphares
Jan 31 2016 02:01
err-- shift, you did shift...
and, then, try getting the gear-- getting the gear should just be returning, setting it should be setting :) @Grizzlr
Franco Zapata
@Francozt01
Jan 31 2016 02:02
@anthonygallina1 ok :D :clap:
anthonygallina1
@anthonygallina1
Jan 31 2016 02:03
@Francozt01 works with computer systems also.
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:04
@Grizzlr line 24 you need a
rerturn gear += shift;
matthew3454
@matthew3454
Jan 31 2016 02:05
@roundelay Does this look better:

function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i <= contacts.length; i++) {
if (contacts[i].firstName === firstName) {
return prop;
// we found that guy! Here you should return the right value

}

else
{
return "No such context";
}

}
// Only change code above this line
}

function lookUp(firstName, prop){
// Only change code below this line
 for (var i = 0; i <= contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      return prop;
      // we found that guy! Here you should return the right value

    }
   else
     {
       return  "No such context";
     }



  }
// Only change code above this line
}
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:05
@Grizzlr sorry is
var Bike = function() {

  var gear = 0;
  this.getGear = function(shift){
    return gear += shift; //Here is the problem
  };
  this.setGear = function(){
    return gear;
  };

};
javathehubb
@javathehubb
Jan 31 2016 02:05
Got it finally!!!!! Thanks everyone for your help!!!!!!
rphares
@rphares
Jan 31 2016 02:06
congrats, @javathehubb !
Bartek
@dyczol
Jan 31 2016 02:07
any tips on "Stand in Line" I mentioned at 20:00 ??
TheKingIsHere
@TheKingIsHere
Jan 31 2016 02:08
@kirah1314 I'm still not getting the right output for(1,2) my screen displays 5
function myFunction(a,b) {

  return a+b;
}

myFunction(1,2);
rphares
@rphares
Jan 31 2016 02:08
try refreshing, that shouldnt give you five,,,
Bill
@kirah1314
Jan 31 2016 02:08
@TheKingIsHere can you post the whole codes?
rphares
@rphares
Jan 31 2016 02:08
oh, good call, lol
matthew3454
@matthew3454
Jan 31 2016 02:09
@rphares Can you have two return statements in a row?
TheKingIsHere
@TheKingIsHere
Jan 31 2016 02:09
// Example
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // Outputs 5

// Only change code below this line.

function myFunction(a,b) {

  return a+b;
}

myFunction(1,2);
Darrel Adams
@dadams-510
Jan 31 2016 02:09
Can anyone help me figure out the golf exercise?
rphares
@rphares
Jan 31 2016 02:09
@dadams-510 , what have you got so far?
Darrel Adams
@dadams-510
Jan 31 2016 02:10
nowhere haha
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:10
@dadams-510 you need to use a lot of if statement
Bill
@kirah1314
Jan 31 2016 02:10
@TheKingIsHere ok reset and redo it, I believe the challenge wants you to use console.log instead of return
Darrel Adams
@dadams-510
Jan 31 2016 02:10
I don't know a thing about golf and don't understand the game.
rphares
@rphares
Jan 31 2016 02:10
@matthew3454 , what do you mean, and-- ask the room, not just me, I'm not good at explaining rules...
anthonygallina1
@anthonygallina1
Jan 31 2016 02:10
@dyczol what happens if you return arr.shift(); // Change this line
rphares
@rphares
Jan 31 2016 02:10
ah, @dadams-510 -- okay, you don't need to think about he rules, so much,
Bill
@kirah1314
Jan 31 2016 02:10
@TheKingIsHere just have to make sure you use a, b in there instead of using the actual numbers
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:10
@dadams-510 Do you have some code to show?
Darrel Adams
@dadams-510
Jan 31 2016 02:11
yeah I do but it's completely wrong. That I know for sure.
rphares
@rphares
Jan 31 2016 02:11
@dadams-510 , basically, write a way to use strokes and what you want to return--
example--
oh!
paste what you have, we can work with that :)
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:11
@dadams-510 paste it :D
rphares
@rphares
Jan 31 2016 02:12
explain format
CamperBot
@camperbot
Jan 31 2016 02:12

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:12
good @rphares
Bartek
@dyczol
Jan 31 2016 02:12
@anthonygallina1 " before [1,2,3,4,5] 2 after [3,4,5]
James Thomas
@Grizzlr
Jan 31 2016 02:12
thanks @COANelmejor
CamperBot
@camperbot
Jan 31 2016 02:12
grizzlr sends brownie points to @coanelmejor :sparkles: :thumbsup: :sparkles:
:star: 309 | @coanelmejor | http://www.freecodecamp.com/coanelmejor
Benjamin Brown
@BenBrown03
Jan 31 2016 02:12

'''js
function convert(celsius) {
// Only change code below this line
var fahrenheit = ('celsius'+32)*(9/5);

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

CamperBot
@camperbot
Jan 31 2016 02:12
:bulb: to format code use backticks! ``` more info
TheKingIsHere
@TheKingIsHere
Jan 31 2016 02:12
@kirah1314 thanks for the help
rphares
@rphares
Jan 31 2016 02:12
hahaha, doesn't always help the first time, but worth a shot :blush: getting format down is tricky for lots of people :)
CamperBot
@camperbot
Jan 31 2016 02:12
thekingishere sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 907 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Benjamin Brown
@BenBrown03
Jan 31 2016 02:13

'''js
function convert(celsius) {
// Only change code below this line
var fahrenheit = ('celsius'+32)*(9/5);

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(-30);
'''

CamperBot
@camperbot
Jan 31 2016 02:13
:bulb: to format code use backticks! ``` more info
rphares
@rphares
Jan 31 2016 02:13
@BenBrown03 , close, but
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:13
@Grizzlr you're wellcome
rphares
@rphares
Jan 31 2016 02:13
remember the order--
@BenBrown03 ,
anthonygallina1
@anthonygallina1
Jan 31 2016 02:13
@dyczol instead of this return queue; // Change this line
Darrel Adams
@dadams-510
Jan 31 2016 02:13
function golfScore(par, strokes) {
  // Only change code below this line

  if(par && strokes === 1) {
   return "Hole-in=one!";
  }

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


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

// Change these values to test
golfScore(5, 4);
rphares
@rphares
Jan 31 2016 02:13
you want celsius time 9/5 plus 32, @BenBrown03
Darrel Adams
@dadams-510
Jan 31 2016 02:13
That's all I have.
sherrardsd
@sherrardsd
Jan 31 2016 02:13
Hello everyone! I am stuck on the "profile lookup" challenge, and I can't quite figure out why my code isn't working
Bill
@kirah1314
Jan 31 2016 02:13
@TheKingIsHere :thumbsup: what happened there was FCC kept returning the last console.log expression which is on the top but if you use a new console.log then it will return the new one
Benjamin Brown
@BenBrown03
Jan 31 2016 02:14
haha thanks
matthew3454
@matthew3454
Jan 31 2016 02:14
@rphares okay sorry. well on the profile lookup exercise the instructions want you to: return "No such contact" when firstName does not correspond to any contacts and return "No such property"when propdoes not correspond to any valid properties
rphares
@rphares
Jan 31 2016 02:14
@dadams-510 , its a bit longer than that... but the idea is going somewhere...
Marouane Rassili
@marouanerassili
Jan 31 2016 02:14
please help I'm stuck with the Stand in line challenge
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:14
@BenBrown03 the correct way is
var fahrenheit = (celsius * (9/5)) + 32;
rphares
@rphares
Jan 31 2016 02:14
@dadams-510 , you will need many specific conditions,
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:14
@dadams-510 "Hole in one" only need the strokes argument
rphares
@rphares
Jan 31 2016 02:15
for example, the first one-- it isn't if par AND strokes === 1
 if (strokes == 1){
   return "Hole-in-one!";
 }
Darrel Adams
@dadams-510
Jan 31 2016 02:15
Does the function pass both parameters?
rphares
@rphares
Jan 31 2016 02:15
from there, look at every condition and what you want to return
anthonygallina1
@anthonygallina1
Jan 31 2016 02:15
@dyczol so that you are returning the pushed and shifted value In stead of the que
@dyczol program flow.
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:16
@rphares @dadams-510 exact!
sherrardsd
@sherrardsd
Jan 31 2016 02:16

function lookUp(firstName, prop){
// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (contactsi === 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

matthew3454
@matthew3454
Jan 31 2016 02:16
on the profile lookup exercise the instructions want you to: return "No such contact" when firstName does not correspond to any contacts and return "No such property"when propdoes not correspond to any valid properties. I forgot how to write two if statements together.
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:17
@dadams-510 do ifs for each type of strokes
Benjamin Brown
@BenBrown03
Jan 31 2016 02:17
thanks @COANelmejor
CamperBot
@camperbot
Jan 31 2016 02:17
benbrown03 sends brownie points to @coanelmejor :sparkles: :thumbsup: :sparkles:
:star: 310 | @coanelmejor | http://www.freecodecamp.com/coanelmejor
Marouane Rassili
@marouanerassili
Jan 31 2016 02:17
Hey guys please I need help with the Stand in line challenge
cannelflow
@cannelflow
Jan 31 2016 02:18
@marouanerassili tried anything?
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:18
@BenBrown03 You're Wellcome
rphares
@rphares
Jan 31 2016 02:18
@marouanerassili , please paste you code and if people can, they'll help :blush:
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:18
:D
Marouane Rassili
@marouanerassili
Jan 31 2016 02:18
@cannelflow yes I'm stuck
rphares
@rphares
Jan 31 2016 02:18
@cannelflow !! :) WB!
cannelflow
@cannelflow
Jan 31 2016 02:18
@rphares GM :smile: show your code @marouanerassili
Marouane Rassili
@marouanerassili
Jan 31 2016 02:19
@rphares how to send code ?
rphares
@rphares
Jan 31 2016 02:19
explain format
CamperBot
@camperbot
Jan 31 2016 02:19

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

rphares
@rphares
Jan 31 2016 02:19
@marouanerassili :point_up:
JuanFer253
@juanfer25
Jan 31 2016 02:20
alguien que me ayude con el conteo de cartas
el ejercicio conteo de cartas
Bartek
@dyczol
Jan 31 2016 02:20
@anthonygallina1 then return.arr but what is missing ?
rphares
@rphares
Jan 31 2016 02:20
hmm, i understand que....
conteo de cartas... counting cards?
JuanFer253
@juanfer25
Jan 31 2016 02:21
aja
counting cards
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:21
LOL @juanfer25 @rphares yes it is
solo que yo si hablo español :D
rphares
@rphares
Jan 31 2016 02:21
lol, sorry, can't help but eavesdrop... ;)
JuanFer253
@juanfer25
Jan 31 2016 02:21
me cuesta entenderte @COANelmejor
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:22
ya te puse un ejemplo :shipit:
rphares
@rphares
Jan 31 2016 02:22
ask me in japanese or mandarin and ill try and answer. @COANelmejor :blush:
JuanFer253
@juanfer25
Jan 31 2016 02:22
no s epero casi ni te comprendo
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:22
ontoni! おんとに!
@rphares
JuanFer253
@juanfer25
Jan 31 2016 02:22
me rindo
hahahaha
esta como el de golf no entiendo hahaha
rphares
@rphares
Jan 31 2016 02:22
hontou~
Marouane Rassili
@marouanerassili
Jan 31 2016 02:23
<function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 8)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));>
rphares
@rphares
Jan 31 2016 02:23
thats a decent start, @marouanerassili !!
but, if you are going to return item,
you may wanna set that second line...
sherrardsd
@sherrardsd
Jan 31 2016 02:24
js<function lookUp(firstName, prop){
// Only change code below this line

 for (var i = 0; i < contacts.length; i++) { 
   if (contacts[i][0] === 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
>
Marouane Rassili
@marouanerassili
Jan 31 2016 02:24
@rphares do I have to post the original code ?
rphares
@rphares
Jan 31 2016 02:24
@marouanerassili , no-- what you sent is perfect
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:24
@rphares anata wa watshi no tomodachi あんたわ私のともだち
rphares
@rphares
Jan 31 2016 02:25
if you provide a name of a challenge and what you have written, its much easier to get help :) you did great, @marouanerassili :)
Marouane Rassili
@marouanerassili
Jan 31 2016 02:27
Stand in line - challenge
<function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 8)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));>
rphares
@rphares
Jan 31 2016 02:27
よろしくお願いします @COANelmejor
(sorry, don't know how to set my language input, had to find a site to copy and paste, lol)
Darrel Adams
@dadams-510
Jan 31 2016 02:27
function golfScore(par, strokes) {
  // Only change code below this line

  //hole-in-one
  if(strokes === 1 && par === 1) {
   return "Hole-in-one!";
  }
  //Eagle
  else if (strokes <= (par -2)){
    return "Eagle";
  }
  else if (strokes === (par - 1)) {
    return "Birdie";
  }

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

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

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

  }

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

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
rphares
@rphares
Jan 31 2016 02:27
@marouanerassili -- you are close, but
check the second line,
you are returning item in your code,
Darrel Adams
@dadams-510
Jan 31 2016 02:27
I'm close but running into a couple of bumps.
rphares
@rphares
Jan 31 2016 02:28
so you want to set item= with that second line, @marouanerassili
@dadams-510 , the first one, just (strokes == 1)
par should be capitalized when you return it, @dadams-510
Marouane Rassili
@marouanerassili
Jan 31 2016 02:29
@rphares "return item" this is the expression by default I have to change it but no idea
Darrel Adams
@dadams-510
Jan 31 2016 02:29
That's it! thanks @rphares
CamperBot
@camperbot
Jan 31 2016 02:29
dadams-510 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2230 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 31 2016 02:30
right-- you don't need to change the return, @marouanerassili ,
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:30
@dadams-510 for this excersice is only necesary == no ===
rphares
@rphares
Jan 31 2016 02:30
but you want to return the item you are shifting, @marouanerassili
so, you need to put it in item before you return, @marouanerassili
Marouane Rassili
@marouanerassili
Jan 31 2016 02:30
@rphares yes
rphares
@rphares
Jan 31 2016 02:30
item =
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:30
@dadams-510 and the par part you only need one comparation
rphares
@rphares
Jan 31 2016 02:31
( @dadams-510 , @COANelmejor is correct, hadn't gotten there, but you only need == for this one :) )
Marouane Rassili
@marouanerassili
Jan 31 2016 02:31
@rphares how to put it (to call it)
Darrel Adams
@dadams-510
Jan 31 2016 02:31
@COANelmejor why would someone not want to use "===" in this case?
rphares
@rphares
Jan 31 2016 02:31
item = ??? @marouanerassili
that line,
all you need is to set item = what you are shifting
you wrote the shift code,
just put it in item = :)
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:32
@dadams-510 when you have a 2 is a number with value 2 | "2" is a string with the letter 2
@dadams-510 when you compare "2" == 2i will retrun true, but "2" === 2 return false, because they are diferent type of value with the same number
@dadams-510 that can be a problem in some cases....
Marouane Rassili
@marouanerassili
Jan 31 2016 02:35
@rphares do I need to put testArr0 ?
rphares
@rphares
Jan 31 2016 02:35
no,
can you paste again? you may have both testArr and arr...
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:36
@rphares no problem with paste a google translate, i can repaste to understand
kelly
@kwhms
Jan 31 2016 02:36
Hi All -- I'm trying to understand the javascript syntax for drilling down through html. Can someone point me to a reference or otherwise explain? E.g. if I have a body tag with 2 section tags inside and each section has a ul, how could I drill down?
Marouane Rassili
@marouanerassili
Jan 31 2016 02:37
<function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 8)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));>
rphares
@rphares
Jan 31 2016 02:37
hahaha, then you will understand-- but i will be embarrassed for writing poor japanese if i just use translate :blush:
@marouanerassili , the first thing is,
rushi
@rush86999
Jan 31 2016 02:37
where do i belong challenge help
rphares
@rphares
Jan 31 2016 02:37
oh!
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:37
@rphares what OS do you have?
rphares
@rphares
Jan 31 2016 02:37
you want to change that line?
rushi
@rush86999
Jan 31 2016 02:37
function where(arr, num) {
  // Find my place in this sorted array.
  var newArr = [];

  arr.sort(function(a, b) {

    return a-b;
});

  if(arr[arr.length] < num) {
    return arr.length;
  }

  for (i = 0; i < arr.length; i++) {

    if (num < arr[i]) {
      newArr[i] = num;
      break;
    }
    newArr[i] = arr[i];
  }


  return newArr.indexOf(num);
}

where([40, 60], 50);
only the last one doesn't work can't figure out what's wrong...
rphares
@rphares
Jan 31 2016 02:38
then, how else can you return the item you shift, @marouanerassili ?
Astha Sharma
@asthas
Jan 31 2016 02:38
@kwhms
rphares
@rphares
Jan 31 2016 02:38
Sorry, didn't realize you wanted to change your return :)
@COANelmejor , macbook
Marouane Rassili
@marouanerassili
Jan 31 2016 02:38
@rphares yes don't know to what
Astha Sharma
@asthas
Jan 31 2016 02:38
getElementById('elementID')
returns the element with the id elementID as an object.
getElementsByTagName('tag')
returns all elements with the name tag as an array.
rphares
@rphares
Jan 31 2016 02:39
well, you are trying to return the thing you shift....
Astha Sharma
@asthas
Jan 31 2016 02:39
Similarly you can access elements using class name @rphares
Marouane Rassili
@marouanerassili
Jan 31 2016 02:39
@rphares yes..
kelly
@kwhms
Jan 31 2016 02:39
@asthas do I have to use ids? is there some syntax like body.section.ul?
rphares
@rphares
Jan 31 2016 02:39
huh, @asthas ? err- mistag, perhaps? :blush:
Astha Sharma
@asthas
Jan 31 2016 02:40
@rphares oops
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:40
@rphares http://redcocoon.org/cab/mysoft.html
if want to change to jap intput or language :D
Astha Sharma
@asthas
Jan 31 2016 02:40
@kwhms Not at all
rushi
@rush86999
Jan 31 2016 02:40
never mind i figured it out thanks!!!
Kevin Myrick
@aphextwin234
Jan 31 2016 02:40
is anyone good with using scripts that cycle through images.
rphares
@rphares
Jan 31 2016 02:40
@marouanerassili , so normally, we can return things by
return X
or return arr.push()
or, in your case....?
Astha Sharma
@asthas
Jan 31 2016 02:40
@kwhms HTML structures it body elements in a tree like hierarchy
rphares
@rphares
Jan 31 2016 02:41
(not the push part, thats an example... you want what you shifted, so...)
Astha Sharma
@asthas
Jan 31 2016 02:41
@kwhms But in Javascript you can access elements with id, tag, class names
rphares
@rphares
Jan 31 2016 02:42
I'm sorry, i have to pop out for a sec-- can someone else take over with stand in line for @marouanerassili ??
kelly
@kwhms
Jan 31 2016 02:42
so $("body #home").addClass works but $("body.section #home).addClass doesn't. How come?
sherrardsd
@sherrardsd
Jan 31 2016 02:42
can someone help me with profile lookup please?
so far I have...

function lookUp(firstName, prop){
// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (contactsi === 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

function lookUp(firstName, prop){
```
// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (contactsi === 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

function lookUp(firstName, prop){
// Only change code below this line

 for (var i = 0; i < contacts.length; i++) { 
   if (contacts[i][0] === 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
Astha Sharma
@asthas
Jan 31 2016 02:44
@kwhms DOM elementas have a tree like hierachy and Javascript is used to manipulate DOm elements and provide behaviour to them. So Javascript treats each tree node as an element and using the id or classname of that element it changes the behaviour of that element.
Marouane Rassili
@marouanerassili
Jan 31 2016 02:44
@rphares <return arr.shift()> that's what it say RangeError: Maximum call stack size exceeded>
James Thomas
@Grizzlr
Jan 31 2016 02:45
Still not getting this to work
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() {

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

};

var myCar = new Car();

var myBike = new Bike();
Bartek
@dyczol
Jan 31 2016 02:45
@anthonygallina1 thanks for your help bud !
CamperBot
@camperbot
Jan 31 2016 02:45
dyczol sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:star: 696 | @anthonygallina1 | http://www.freecodecamp.com/anthonygallina1
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:46
@Grizzlr i'll give you my code privately
Astha Sharma
@asthas
Jan 31 2016 02:46
@kwhms . notation is not used in Java to access the object of a particular class but Java and Javascript are totally different. You have to get accustomed with Javascript syntax
cannelflow
@cannelflow
Jan 31 2016 02:47
@Grizzlr which exercise are you doing?
Astha Sharma
@asthas
Jan 31 2016 02:47
@kwhms Do you come from a Java background?
kelly
@kwhms
Jan 31 2016 02:47
no, embedded C
@asthas no, embedded C
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 02:47
@Grizzlr our codes only have a diferience un the line 23 and 24
Marouane Rassili
@marouanerassili
Jan 31 2016 02:48
Stand in line challenge // I need help
function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return arr.push();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 8)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
cannelflow
@cannelflow
Jan 31 2016 02:48
@marouanerassili you have to return what is removed
not pushed
Astha Sharma
@asthas
Jan 31 2016 02:49
@kwhms Javascript is a functional programming language and things happen differently in Js quite unlike procedural and object oriented programming language
@kwhms To best understand about Javascript use MDN documentation and always remember that in Javascript each element is treated independently
kelly
@kwhms
Jan 31 2016 02:51
@asthas Thanks. Out of curiosity, why MDN?
CamperBot
@camperbot
Jan 31 2016 02:51
kwhms sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:star: 304 | @asthas | http://www.freecodecamp.com/asthas
Marouane Rassili
@marouanerassili
Jan 31 2016 02:51
@cannelflow when I put return arr.shift() that's what they say RangeError: Maximum call stack size exceeded
cannelflow
@cannelflow
Jan 31 2016 02:51
@marouanerassili can you show your whole code now
Marouane Rassili
@marouanerassili
Jan 31 2016 02:51
@cannelflow
function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 8)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
anthonygallina1
@anthonygallina1
Jan 31 2016 02:52
@marouanerassili this one seems to need a browser refresh
Astha Sharma
@asthas
Jan 31 2016 02:52
@kwhms Mozilla developers network gives the best insight of Javascript . Though documentations are considered a little verbose and bombastic but if you read MDN thoroughly your Javascript concepts will be very clear
cannelflow
@cannelflow
Jan 31 2016 02:52
@marouanerassili remove arr.shift(); cuz if you write arr.shift(); and return arr.shift(); i think you are removing two value maybe but first refresh tha page and try
Astha Sharma
@asthas
Jan 31 2016 02:54
@marouanerassili shift() function always returns an element , you should store the value returned by arr.shift() and then only use that value.
Conor Mack
@ConorMack
Jan 31 2016 02:54

I am having problems with c being undefined. I am sure this is super basic but not seeing whats wrong. anyone have an idea? ```js
// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

a = 6;
b = 15;
c = "I am a";

```

LamontX
@Islandersfan2016
Jan 31 2016 02:54
Need help with this challenge. Trying to retrieve the "pine" using JSON dot, bracket notation. I'm having problems with
cannelflow
@cannelflow
Jan 31 2016 02:55
@marouanerassili as per exercise asked you can't write two shift
LamontX
@Islandersfan2016
Jan 31 2016 02:55
lol accidently hit ent er too soon
Marouane Rassili
@marouanerassili
Jan 31 2016 02:55
@cannelflow it outputs Before: [1,2,3,4,5] 2 After: [3,4,5,8] with 8 as test value
cannelflow
@cannelflow
Jan 31 2016 02:55
@marouanerassili you are using two shift
Conor Mack
@ConorMack
Jan 31 2016 02:56
no ideas on why my var c is undefined?
cannelflow
@cannelflow
Jan 31 2016 02:56
and it is asked return what is removed
@marouanerassili
Marouane Rassili
@marouanerassili
Jan 31 2016 02:56
@cannelflow yes it's solved, thank you! :smile:
CamperBot
@camperbot
Jan 31 2016 02:56
marouanerassili sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 666 | @cannelflow | http://www.freecodecamp.com/cannelflow
cannelflow
@cannelflow
Jan 31 2016 02:56
@marouanerassili :+1:
Astha Sharma
@asthas
Jan 31 2016 02:56
@ConorMack var c = "";
sherrardsd
@sherrardsd
Jan 31 2016 02:56
@ConorMack var c = ""
Conor Mack
@ConorMack
Jan 31 2016 02:57
@sherrardsd hmmm, is that different then what i had?
Astha Sharma
@asthas
Jan 31 2016 02:57
@ConorMack For storing strings initial the variable must be initialised toa n empty string
sherrardsd
@sherrardsd
Jan 31 2016 02:57
@ConorMack Yes. Because you can't add c + a string when C is undefined. that is why it is returning as undefined. If you initialize C to "" then it can concatenate the string
Astha Sharma
@asthas
Jan 31 2016 02:58
@ConorMack You haven't done that
cannelflow
@cannelflow
Jan 31 2016 02:58
@Islandersfan2016 ?
Conor Mack
@ConorMack
Jan 31 2016 02:58
Oh i see! Thank you @asthas and @sherrardsd
CamperBot
@camperbot
Jan 31 2016 02:58
conormack sends brownie points to @asthas and @sherrardsd :sparkles: :thumbsup: :sparkles:
:star: 225 | @sherrardsd | http://www.freecodecamp.com/sherrardsd
:star: 305 | @asthas | http://www.freecodecamp.com/asthas
Andrew
@gskll
Jan 31 2016 03:00
Does anyone know how to chain different terms in regular expressions together? Say if I want to get rid of non-alphanumeric characters and underscores?
rmtc3
@rmtc3
Jan 31 2016 03:00
for accessing nested arrays in Json.. I really dont understand why my solution works.. anybody care to explain?
JuanFer253
@juanfer25
Jan 31 2016 03:00
i need help with this js var playerNumber = 16; var playerNuber = { 16: 16 } testObj[16];
var playerNumber = 16; 
var playerNuber = {
  16: 16
}
testObj[16];
You should use bracket notation to access testObj
rmtc3
@rmtc3
Jan 31 2016 03:01
wait one second.. reading a stack overflow will let you know if i get it.
JuanFer253
@juanfer25
Jan 31 2016 03:01
what is my fail??
sherrardsd
@sherrardsd
Jan 31 2016 03:01
@rmtc3 what is your solution?
LamontX
@Islandersfan2016
Jan 31 2016 03:01
@rmtc3 I'm actually working on the same challenge. Not too sure how it works either.
rmtc3
@rmtc3
Jan 31 2016 03:02
var secondTree = myPlants1.list1;
sherrardsd
@sherrardsd
Jan 31 2016 03:02
With no [] ?
rmtc3
@rmtc3
Jan 31 2016 03:03
var secondTree = myPlants[1].list[1]
there we go.. thats the solution i came up with
sherrardsd
@sherrardsd
Jan 31 2016 03:03
Okay, that works
JuanFer253
@juanfer25
Jan 31 2016 03:03
help i need help
CamperBot
@camperbot
Jan 31 2016 03:03
no wiki entry for: i need help
rmtc3
@rmtc3
Jan 31 2016 03:03
i was expecting js var secondTree = myPlants.type[1].list[1];
sherrardsd
@sherrardsd
Jan 31 2016 03:04
Ohhh you mean why it works without a semi colon. I'm not sure why that is passing in that case
@rmtc3 what is the challenge name again/?
rmtc3
@rmtc3
Jan 31 2016 03:05
@sherrardsd no I was wondering why i didnt have to use
var secondTree = myPlants.type.list[1]
sherrardsd
@sherrardsd
Jan 31 2016 03:05
ok gotcha
rmtc3
@rmtc3
Jan 31 2016 03:06
@sherrardsd sorry its Accessing Nested Arrays in JSON and i was wondering why this doesnt work
var secondTree = myPlants.type[1].list[1];
Christian Obed Arana navas
@COANelmejor
Jan 31 2016 03:08
@Grizzlr i fixed the code.... and send id privately
sherrardsd
@sherrardsd
Jan 31 2016 03:09

myPlants.type doesn't exist I don't think. myPlants1 gives you the array that contains [type and list] and list is another array.

So once you access that with myPlants1 then you can use .list to access the list or ["list"] to access list. and then go another level deeper and get the 2nd spot of list 1

is that anymore clear? I can try to explain it a different way if not
rmtc3
@rmtc3
Jan 31 2016 03:10
@sherrardsd nope that's very understandable.
Brian
@sludge256
Jan 31 2016 03:10
make sure to escape the brackets if you're not using code formatting
otherwise gitter tries to format them as links
sherrardsd
@sherrardsd
Jan 31 2016 03:11
@sludge256 thanks!
CamperBot
@camperbot
Jan 31 2016 03:11
sherrardsd sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1158 | @sludge256 | http://www.freecodecamp.com/sludge256
sherrardsd
@sherrardsd
Jan 31 2016 03:12
Can anyone help me with profile lookup?? Im totally stuck
function lookUp(firstName, prop){
// Only change code below this line

 for (var i = 0; i < contacts.length; i++) { 
   if (contacts[i][0] === 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
rmtc3
@rmtc3
Jan 31 2016 03:13
thanks @sherrardsd
CamperBot
@camperbot
Jan 31 2016 03:13
rmtc3 sends brownie points to @sherrardsd :sparkles: :thumbsup: :sparkles:
:star: 226 | @sherrardsd | http://www.freecodecamp.com/sherrardsd
Brian
@sludge256
Jan 31 2016 03:18
@sherrardsd Would you be able to determine that the contact does not exist without first looking through the entire contacts array?
Matthew Schultz
@vexleir
Jan 31 2016 03:18
Hey everyone. Is there somewhere we can go to see how other people solved challenges to compare out results?
Brian
@sludge256
Jan 31 2016 03:18
@vexleir there are some solutions on the wiki
you can also just visit people's profiles
Matthew Schultz
@vexleir
Jan 31 2016 03:18
I just solved the falsy bouncer challenge, but not sure mine was the cleanest approach ever
Brian
@sludge256
Jan 31 2016 03:18
to browse their solutions
Matthew Schultz
@vexleir
Jan 31 2016 03:19
oh ok, cool. Thanks!
Brian
@sludge256
Jan 31 2016 03:19
We also have a code review room
it's not always very active though
Matthew Schultz
@vexleir
Jan 31 2016 03:19
I see it on Gitter now. Thanks @sludge256
CamperBot
@camperbot
Jan 31 2016 03:19
vexleir sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1160 | @sludge256 | http://www.freecodecamp.com/sludge256
rushi
@rush86999
Jan 31 2016 03:22
function rot13(str) { // LBH QVQ VG!

  var newStr = '';
  var charCode = [];
  var newStr1 = '';

  for (i = 0; i < str.length; i++) {

    if(!str.charCodeAt(i)) {
      charCode[i] = " ";
    }

    charCode[i] = str.charCodeAt(i);

  }

  for (i = 0; i < charCode.length; i++) {

    newStr[i] = charCode[i] + ", ";
  }

  newStr1 = String.fromCharCode(newStr);
  return newStr1;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
guys i am lost on caesars cipher
floydd
@floydd
Jan 31 2016 03:23
Hi guys. Is Return Early Pattern for Functions bugged?
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a <= 0 || b <= 0); {
    return undefined;
  }


  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Been at this one for 10 minutes
sherrardsd
@sherrardsd
Jan 31 2016 03:24
@sludge256 Do you mean just checking for equality with the 4 names that we know are in the contacts object?
Brian
@sludge256
Jan 31 2016 03:24
@CodeVandal the instructions just say less than 0
not less than or equal
@sherrardsd No I'm asking, is it possible to say that the contact you are looking for is not in the array without looking through the whole array?
floydd
@floydd
Jan 31 2016 03:26
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0); {
    return undefined;
  }


  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
still giving me an error =/
Brian
@sludge256
Jan 31 2016 03:27
@CodeVandal your semicolon
floydd
@floydd
Jan 31 2016 03:28
-_- wow lol. Thanks @sludge256!
CamperBot
@camperbot
Jan 31 2016 03:28
codevandal sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1161 | @sludge256 | http://www.freecodecamp.com/sludge256
sherrardsd
@sherrardsd
Jan 31 2016 03:28
@sludge256 not that I can think of. If you are given a random contact and you don't know which names are in the contact, you would have to check through each contact to see if the name matches. Am I missing something?
Andrew Charlebois
@andrewchar
Jan 31 2016 03:28
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

}

// Test your code by modifying these values
checkObj("house");
this is my code for Testing Objects for Properties. it accepted this code as correct but i was only able to write this after like an hour of googling how to do this.. Is this the way the exercise intended me to do this or is it way off?
Brian
@sludge256
Jan 31 2016 03:29
@sherrardsd so the problem is within your loop you have this
   else {
     return "No such contact";
   }
it will execute in your first loop
if the first contact you check does not have a matching name
Gordon Davidescu
@gordondavidescu
Jan 31 2016 03:29
I'm in the Inventory Update -- for some reason indexOf is returning -1 on everything
sherrardsd
@sherrardsd
Jan 31 2016 03:31
@sludge256 ahhh!!! yes okay
Gordon Davidescu
@gordondavidescu
Jan 31 2016 03:31
I feel like it should be returning actual indexes
Brian
@sludge256
Jan 31 2016 03:31
@andrewchar your else if is the same as your if
Andrew Charlebois
@andrewchar
Jan 31 2016 03:32
i just noticed
i fixed it
function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return myObj [checkProp];
  }  else {
    return "Not Found";
  }

}
Gordon Davidescu
@gordondavidescu
Jan 31 2016 03:32
that looks good
Andrew Charlebois
@andrewchar
Jan 31 2016 03:32
this one totally messed me up
Gordon Davidescu
@gordondavidescu
Jan 31 2016 03:32
unlike my usual spagehetti code
Andrew Charlebois
@andrewchar
Jan 31 2016 03:33
my code looks nothing like the example
i had to google for literally an hour
reading about it
before getting it right
Brian
@sludge256
Jan 31 2016 03:33
the example is barebones
Andrew Charlebois
@andrewchar
Jan 31 2016 03:33
the examples throw me off because it doesnt show you how to write it
Brian
@sludge256
Jan 31 2016 03:34
I think the intention is to hopefully have you remember past concepts
Andrew Charlebois
@andrewchar
Jan 31 2016 03:34
which is fine, i just search some good old google and find out. if that how fcc intends for us to learn?
Brian
@sludge256
Jan 31 2016 03:34
without outright telling you which one to use
Gordon Davidescu
@gordondavidescu
Jan 31 2016 03:34
well they do tell us to google to find solutions when necessary
Brian
@sludge256
Jan 31 2016 03:35
It becomes a bit too easy if all the examples can be copy and pasted
and modified into a passing solution
Andrew Charlebois
@andrewchar
Jan 31 2016 03:35
i have no problem with it being hard mind you. I will remember that time it took me an hour to find the answer as opposed to a time it took me 30 seconds to copy paste from example lol
Gordon Davidescu
@gordondavidescu
Jan 31 2016 03:35
if you know what you're pasting, it's significant
Andrew Charlebois
@andrewchar
Jan 31 2016 03:35
"if you know" :P
i get what you're saying though
Brian
@sludge256
Jan 31 2016 03:36
There are probably instances where the examples could be beefed up a bit
Andrew Charlebois
@andrewchar
Jan 31 2016 03:36
but dear lord this one threw me for a loop
Brian
@sludge256
Jan 31 2016 03:36
sometimes people get too focused on the examples
and don't pay attention to what their code is really doing
Andrew Charlebois
@andrewchar
Jan 31 2016 03:37
the example showed me this myObj.hasOwnProperty("top"); // true
myObj.hasOwnProperty("middle"); // false
pretty different from my code. which is what made me think... "did i over think this and write way to much"
i do have a question about my code thou
my return statement... return myObj [checkProp]; does this make it an array?
or is it not only arrays that can have []
Brian
@sludge256
Jan 31 2016 03:38
there is a lesson on accessing objects with bracket notation
Andrew Charlebois
@andrewchar
Jan 31 2016 03:39
oh right
bracket or dot notation
Brian
@sludge256
Jan 31 2016 03:39
yep
Andrew Charlebois
@andrewchar
Jan 31 2016 03:39
so i could write it either way then
Brian
@sludge256
Jan 31 2016 03:39
in this case since you are using a variable
you should use bracket notation
if you were to use dot notation
it would look up the name of the variable literally
not the value of the variable
sherrardsd
@sherrardsd
Jan 31 2016 03:40

@sludge256 okay so I changed it to this but I'm having the same problem...

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

Andrew Charlebois
@andrewchar
Jan 31 2016 03:40
gotcha
thanks a lot for clarity @sludge256
CamperBot
@camperbot
Jan 31 2016 03:40
andrewchar sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1162 | @sludge256 | http://www.freecodecamp.com/sludge256
sherrardsd
@sherrardsd
Jan 31 2016 03:40
function lookUp(firstName, prop){
// Only change code below this line
var contact = false;
 for (var i = 0; i < contacts.length && !contact; i++) { 
   if (contacts[i][0] === firstName) {
       contact = true;
       if (contacts[i].hasOwnProperty(prop)) {
         return contacts[i][prop];
       }
       else {
         return "No such property";
       }
   }
 }
  if (!contact) {
    return "No such contact";
  }
}
Andrew Charlebois
@andrewchar
Jan 31 2016 03:40
on to the next one!!
@sludge256 how long have you been doing this?
Syed Isam Hashmi
@prosdkr
Jan 31 2016 03:43
@sherrardsd
if (contacts[i][0] === firstName) {

//should be

if (contacts[i].firstName === firstName) {
Brian
@sludge256
Jan 31 2016 03:43
I guess ~2months but I've been taking a break
sherrardsd
@sherrardsd
Jan 31 2016 03:43
@prosdkr isn't it the same thing in this case?
Brian
@sludge256
Jan 31 2016 03:43
@prosdkr :+1:
Andrew Charlebois
@andrewchar
Jan 31 2016 03:43
@sludge256 just doing it for fun?
sherrardsd
@sherrardsd
Jan 31 2016 03:44
@prosdkr that did fix it. thank you!
CamperBot
@camperbot
Jan 31 2016 03:44
sherrardsd sends brownie points to @prosdkr :sparkles: :thumbsup: :sparkles:
:star: 318 | @prosdkr | http://www.freecodecamp.com/prosdkr
Syed Isam Hashmi
@prosdkr
Jan 31 2016 03:44
@sherrardsd nope, you are accessing a property, not an array :)
@sherrardsd or a key, so to say :P
and good job :)
Brian
@sludge256
Jan 31 2016 03:44
and while setting a flag is a good idea
Kevin Myrick
@aphextwin234
Jan 31 2016 03:44
does anyone know the easiest way to import images into Expression I need a sanity check. I am going to make a form that cycles through the images with a script.
Brian
@sludge256
Jan 31 2016 03:45
you can just simply return no such contact after the loop has ended
since the statements in the for loop will terminate the function once a contact is found
sherrardsd
@sherrardsd
Jan 31 2016 03:45
@sludge256 right! thank you
CamperBot
@camperbot
Jan 31 2016 03:45
sherrardsd sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: sherrardsd already gave sludge256 points
Brian
@sludge256
Jan 31 2016 03:45
so it won't ever reach the no such contact unless necessary
sherrardsd
@sherrardsd
Jan 31 2016 03:47
so @prosdkr I can't access properties in the same way that I would access an array? So for instance, even though firstName is in the first slot, I would have to use .firstName or ["firstName"] instead of 0??
Leonel Tejeda
@devbuilt
Jan 31 2016 03:48
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  // Your code above this line
  return wordBlanks;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Syed Isam Hashmi
@prosdkr
Jan 31 2016 03:48
@sherrardsd yep :)
you have to provide the name of it directly :)
Leonel Tejeda
@devbuilt
Jan 31 2016 03:48
help
CamperBot
@camperbot
Jan 31 2016 03:48

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
  • bonfire BONFIRENAME info on a bonfire

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Leonel Tejeda
@devbuilt
Jan 31 2016 03:48
im lost
Syed Isam Hashmi
@prosdkr
Jan 31 2016 03:48
@devbuilt what do you need? :)
Leonel Tejeda
@devbuilt
Jan 31 2016 03:48
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  // Your code above this line
  return wordBlanks;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
i dont understand what its asking realy
dsousadev
@dsousadev
Jan 31 2016 03:49
@devbuilt what does the prompt ask for
Syed Isam Hashmi
@prosdkr
Jan 31 2016 03:49
@dsousadev <-- this
what's it say? lol
or the name of the challenge
sherrardsd
@sherrardsd
Jan 31 2016 03:49
It wants the strings to be concatenated
Leonel Tejeda
@devbuilt
Jan 31 2016 03:49
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
dsousadev
@dsousadev
Jan 31 2016 03:49
no whats the task required like what output
Leonel Tejeda
@devbuilt
Jan 31 2016 03:50
oh ok
got it
dsousadev
@dsousadev
Jan 31 2016 03:50
@devbuilt thats the madlib one right?
@devbuilt so you are going to take the string result and add those words in, and dont forget to add your spaces
Leonel Tejeda
@devbuilt
Jan 31 2016 03:50
yes @dsousadev
dsousadev
@dsousadev
Jan 31 2016 03:51
@devbuilt + operator for concatenating strings
tridling
@tridling
Jan 31 2016 03:52
I am missing something on Assignment with a Returned Value. "You should assign process to processed"
processed = process(2);
Andrew Charlebois
@andrewchar
Jan 31 2016 03:53
should the (2) be there?
dsousadev
@dsousadev
Jan 31 2016 03:53
@tridling can you pasted in the whole code
*paste