These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Feb 2016
greg
@wearenotgroot
Feb 08 2016 00:00 UTC
@Savrov also doing .prop === null, .prop<----------will give you values and if that value is not null then it will return true
Milan
@tomasovic
Feb 08 2016 00:00 UTC
@zackgus nope.. maybe some issue with safari... its driving me crazy, now more when i am sure i have don't it right...
* done it right....
Pavel
@Savrov
Feb 08 2016 00:01 UTC
@wearenotgroot wait, [prop] gives me values, no?
Ryan Thomas
@Placid7
Feb 08 2016 00:01 UTC

http://www.freecodecamp.com/challenges/title-case-a-sentence

function titleCase(str) {
var arr = str.split();{
  for(var i = 1; i < arr.length; i++){
    arr[i] = arr[i].charAt(0).toUpperCase();
  return arr;
}
}
}
titleCase("I'm a little tea pot");

suppose to return the string with the first letter of each word capitilized. It's returning nothing.

greg
@wearenotgroot
Feb 08 2016 00:01 UTC
@Savrov yes the value of prop
@Savrov that is why you use contacts[i].firstName <-------------will give you the value of the property firstName
@Savrov same as this contacts[i]['firstName'] <-----------------will give you the value
EHunt13
@EHunt13
Feb 08 2016 00:02 UTC
@wearenotgroot why do you need a nested conditional instead of using &&?
Pavel
@Savrov
Feb 08 2016 00:03 UTC
@wearenotgroot OK, thanks, now im trying to use your advice like that: contacts[i].hasOwnProperty(prop)
CamperBot
@camperbot
Feb 08 2016 00:03 UTC
savrov sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 670 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 00:03 UTC
@EHunt13 for readability and to avoid redundant testing
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:03 UTC
hello
Pavel
@Savrov
Feb 08 2016 00:04 UTC
@wearenotgroot , finally finished it. Thanks man!
CamperBot
@camperbot
Feb 08 2016 00:04 UTC
savrov sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: savrov already gave wearenotgroot points
greg
@wearenotgroot
Feb 08 2016 00:04 UTC
@Savrov YW
Milan
@tomasovic
Feb 08 2016 00:04 UTC
@zackgus hmmm... funny it swows
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:04 UTC
can some body assist me i need clarification
EHunt13
@EHunt13
Feb 08 2016 00:04 UTC
function lookUp(firstName, prop){
// Only change code below this line
for(var i =0; i<contacts.length; i++)
  if(firstName === contacts[i].firstName){
    if (contacts[i].prop!==null){
      return contacts[i].prop;
    }
  }
  else if (contacts[i].hasOwnProperty(prop)===false){
    return "No such property";
    }
  else if (contacts[i].firstName !== firstName) {
    return "No such contact";
  }




// Only change code above this line
}
still lost
Milan
@tomasovic
Feb 08 2016 00:04 UTC
@zackgus it shows i have done a challenge, but it still gives me an error....
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:05 UTC
how do u post the code in console
Zackarias Gustavsson
@hackarias
Feb 08 2016 00:05 UTC
@tomasovic missing semicolon somewhere perhaps?
EHunt13
@EHunt13
Feb 08 2016 00:05 UTC
3 backslashes, shift-enter, copy paste
Ryan Thomas
@Placid7
Feb 08 2016 00:05 UTC
This message was deleted
EHunt13
@EHunt13
Feb 08 2016 00:05 UTC
@CrazyboOoy123
Ryan Thomas
@Placid7
Feb 08 2016 00:05 UTC
camperbot format
Milan
@tomasovic
Feb 08 2016 00:06 UTC

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

// Only change code below this line.

var newArray = oldArray.filter (function (val) {
return val <= 5;
});

greg
@wearenotgroot
Feb 08 2016 00:06 UTC

@EHunt13

```
function lookUp(firstName, prop){
// Only change code below this line
for(var i =0; i<contacts.length; i++)
  if(firstName === contacts[i].firstName){
    if (contacts[i].prop!==null){<------------------------------------------use .hasOwnProperty(prop) instead
      return contacts[i].prop;
    }
  }
  else if (contacts[i].hasOwnProperty(prop)===false){
    return "No such property";
    }
  else if (contacts[i].firstName !== firstName) {<----------------------------this breaks the loop and stop the search too early
    return "No such contact";           <-------------------------move it somewehere so it wont break the loop
  }




// Only change code above this line
}

```

Milan
@tomasovic
Feb 08 2016 00:06 UTC
@zackgus as i can see, no...
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:06 UTC

///
function titleCase(str) {
var word;
str.toLowerCase();// lowercase;
str.split(' ');//split string to arrays by space;

for (var i = 0 ; i < str.length; i++){// for loop ;
str.toUpperCase();//uppercase;

}

return str;// return str;

}

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

ok any way so i have this issue
Ryan Thomas
@Placid7
Feb 08 2016 00:07 UTC
@CrazyboOoy123 I'm on the same one
EHunt13
@EHunt13
Feb 08 2016 00:07 UTC
sorry @CrazyboOoy123 use 3 of these "```"
greg
@wearenotgroot
Feb 08 2016 00:07 UTC
wiki format
CamperBot
@camperbot
Feb 08 2016 00:07 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Milan
@tomasovic
Feb 08 2016 00:07 UTC
@zackgus thanks man... i will try to reload the challenge in another browser, to try again.... ah
CamperBot
@camperbot
Feb 08 2016 00:07 UTC
tomasovic sends brownie points to @zackgus :sparkles: :thumbsup: :sparkles:
:star: 271 | @zackgus | http://www.freecodecamp.com/zackgus
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:07 UTC
@Placid7 cool have you done it?
EHunt13
@EHunt13
Feb 08 2016 00:07 UTC
thanks @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 00:07 UTC
ehunt13 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: ehunt13 already gave wearenotgroot points
Ryan Thomas
@Placid7
Feb 08 2016 00:08 UTC

@CrazyboOoy123

function titleCase(str) {
var arr = str.split();{
  for(var i = 1; i < arr.length; i++){
    arr[i] = arr[i].charAt(0).toUpperCase();
  return arr;
}
}
}
titleCase("I'm a little tea pot");

ours are slightly different, but mine doesn't pass either.

greg
@wearenotgroot
Feb 08 2016 00:09 UTC
@EHunt13 hint! move the return "No such contact" somewhere that is not inside the loop :smile: think outside the box
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:09 UTC
@Placid7 u have to lowercase first i guess since thats whats showing in the results
Aleksander Gębicki
@Takumar
Feb 08 2016 00:09 UTC
@Placid7 if you want to have single words in your array, use split(' ') with single space as argument.
Your loop should start from i=0; because arrays are indexed starting from 0.
Zackarias Gustavsson
@hackarias
Feb 08 2016 00:09 UTC
@tomasovic ok, I hope that solves it. let us know if it doesn’t
Ryan Thomas
@Placid7
Feb 08 2016 00:10 UTC
@CrazyboOoy123 @Takumar great points. finally understanding the tools. now I just have to remember when to use them.
Aleksander Gębicki
@Takumar
Feb 08 2016 00:10 UTC
@Placid7 when it comes to arr[i] = arr[i].charAt(0).toUpperCase(); you cannot change single letter like that, now you put to your array instead of entire word, only single big letter, think how to add rest of your word here.
@CrazyboOoy123 the same with your code, you have to find the way how to make first letter of yours word uppercase, and add rest of word (key is concatenation of strings :-) )
Ryan Thomas
@Placid7
Feb 08 2016 00:12 UTC
@Takumar do I understand that I need to change each word into an array then make the first item in the array .toUpperCase
greg
@wearenotgroot
Feb 08 2016 00:12 UTC
@Placid7 remember .charAt(0) only gives you the character at index 0 so if you set that equal to arr[i] then you replace the entire word with just 1 letter
Aleksander Gębicki
@Takumar
Feb 08 2016 00:12 UTC
@Placid7 You have to make first letter in every word big:
from this is example you achieve This Is Example
Alex Tze
@Tze14
Feb 08 2016 00:13 UTC
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
   console.log(arr[i]);
}
"Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1." <<---- I simply do not understand a thing of what this means. How is the last index of the array -1? I just simply cannot understand.
*length -1 (sorry)
Aleksander Gębicki
@Takumar
Feb 08 2016 00:14 UTC

@Tze14 think about shorter example, array: [4, 9], it has length of 2, right?
But indexes of this array are only 0 and 1

arr[0] === 4
arr[1] === 9

so you see that last element in your array is arr[arr.length-1]

CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:14 UTC
function titleCase(str) {
  var word;
    str.toLowerCase();//  lowercase;
    str.split(' ');//split string to arrays by space;

  for (var i = 0 ; i < str.length; i++){//  for loop ; 
      str.toUpperCase();//uppercase;

  }



  return str;//  return str;



}

titleCase("I'm a little tea pot");
so how do i assign the values to return ?
greg
@wearenotgroot
Feb 08 2016 00:15 UTC
@Placid7 store the charAt(0) in a temp variable make it uppercase then use slice to get the rest of the word then put it back together again
Zackarias Gustavsson
@hackarias
Feb 08 2016 00:15 UTC
or just split each word into an array, make each first letter capital, then join the array back to a string
Aleksander Gębicki
@Takumar
Feb 08 2016 00:16 UTC

@CrazyboOoy123 strings are immutable, you cannot make entire string lowercase in that way: str.toLowerCase();, you have to make an assignment:

str = str.toLowerCase();

The same here:
str.split(' ');//split string to arrays by space;
you have to store your single words in an array:

var words = str.split(' ');
Alex Tze
@Tze14
Feb 08 2016 00:16 UTC
@Takumar I'll take some time to reflect over what you just said and will come back
Aleksander Gębicki
@Takumar
Feb 08 2016 00:17 UTC
@Tze14 yes, think about it :-) Good luck!
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 00:17 UTC
@Takumar so each method should have a variable ?
i mean should be assigned to a variable
Alex Tze
@Tze14
Feb 08 2016 00:18 UTC
@Takumar for a split second I understood now I have to explain it to myself again, thank you
CamperBot
@camperbot
Feb 08 2016 00:18 UTC
tze14 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2194 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Feb 08 2016 00:19 UTC

@CrazyboOoy123 not each, but that which works on strings yes (I cannot say that every, because I don't know every method ;-) )
Methods working on arrays, don't always need an assignment, for example:

array.reverse();

this method reverses elements of array, and this array is modified.

Cooper Reck
@cooperreck
Feb 08 2016 00:20 UTC
Hey can anyone explain the exercise "Quoting Strings with Single Quotes?" I'm not sure what it's saying
greg
@wearenotgroot
Feb 08 2016 00:20 UTC
@cooperreck ""<---------double quotes ------------------------- ''<-----------single quotes
Alex Tze
@Tze14
Feb 08 2016 00:22 UTC
var arr = [17,25,78,92,14]
arr[0] === 17;
arr[1] === 25;
.
.
.
arr[4] === 14;

arr.length === 5;  <-- is this right?
arr[4] === (arr.length -1); <-- is this right?
@Takumar ??
Aleksander Gębicki
@Takumar
Feb 08 2016 00:22 UTC
@cooperreck it is saying that, when you create string using single quotes, you can freely use double quotes inside this string:
var strWithQuotes = 'Here I can use as many "double" quotation """" marks as I like " do you understand?';
greg
@wearenotgroot
Feb 08 2016 00:22 UTC
@Tze14 assingment operator is =
@Tze14 while comparison operator == or ===
Aleksander Gębicki
@Takumar
Feb 08 2016 00:23 UTC
@Tze14 very good :-)
Cooper Reck
@cooperreck
Feb 08 2016 00:23 UTC
@wearenotgroot @Takumar AHH thank you!!\
Alex Tze
@Tze14
Feb 08 2016 00:23 UTC
@Takumar I get it now
CamperBot
@camperbot
Feb 08 2016 00:23 UTC
cooperreck sends brownie points to @wearenotgroot and @takumar :sparkles: :thumbsup: :sparkles:
:star: 2195 | @takumar | http://www.freecodecamp.com/takumar
:star: 671 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Alex Tze
@Tze14
Feb 08 2016 00:23 UTC
@Takumar just to make sure, I was correct in using the comparison sign?
Aleksander Gębicki
@Takumar
Feb 08 2016 00:24 UTC
@Tze14 yes, arr[4] === 14 means that value of element with index 4 is strictly equal to 14.
greg
@wearenotgroot
Feb 08 2016 00:25 UTC
@Tze14 double equal == compares value while tripple equals === compares value and type
Aleksander Gębicki
@Takumar
Feb 08 2016 00:25 UTC
@Tze14 you could try some pseudo code: arr[0] => 17, arr[1] => 25
It is important that you understand what it means, and how it works.
Alex Tze
@Tze14
Feb 08 2016 00:26 UTC
@Takumar @wearenotgroot I get it , I was suppose to use ==
@Takumar thats why I take the time on this cause it got the best of me for the last 30 minutes
greg
@wearenotgroot
Feb 08 2016 00:27 UTC
@Tze14 :+1:
Aleksander Gębicki
@Takumar
Feb 08 2016 00:27 UTC
@Tze14 it is safer to use ===, you are sure that you are not comparing string containing number with number:
"14" ==  14  // this is true
15 === 15  // this is true
"15" !== 15  // this is true
"15" === 15  // this is false
Alex Tze
@Tze14
Feb 08 2016 00:31 UTC
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var total = 0;

for (var i = 0; i < myArr.length; i++) {
  -> how do I represent here the sum of all the indexes? <-
}
@Takumar I dont understand how the sum should be represented
@Takumar I want total = 2+3+4+5+6
what I get is that it should be total += myArr[i];
Aleksander Gębicki
@Takumar
Feb 08 2016 00:33 UTC
@Tze14 you don't want to sum indexes, but values from array at given indexes
greg
@wearenotgroot
Feb 08 2016 00:34 UTC
@Tze14 it is the same as total = total + myArr[i]
Aleksander Gębicki
@Takumar
Feb 08 2016 00:34 UTC
@Tze14 and that total += myArr[i]; is totally good. You add every element from your array to total variable.
Alex Tze
@Tze14
Feb 08 2016 00:35 UTC
I dont know why it feels strange to use total +=... for some reason :)
Aleksander Gębicki
@Takumar
Feb 08 2016 00:36 UTC
@Tze14 it is just shorter, you will get used to it :-)
Zackarias Gustavsson
@hackarias
Feb 08 2016 00:36 UTC
on Seek and Destroy, what’s up with the Arguments object? I can see that it returns things for me but I don’t understand why it does it, or what tells it what to return. does anyone know?
Alex Tze
@Tze14
Feb 08 2016 00:36 UTC
@Takumar its not the notation itself but the simple fact that it adds all the indexes that come out
Aleksander Gębicki
@Takumar
Feb 08 2016 00:38 UTC
@Tze14 all indexes are created in your loop:
for (var i = 0; i < myArr.length; i++) {
}
greg
@wearenotgroot
Feb 08 2016 00:38 UTC
@zackgus every functions is assigned an object that contains all the possible arguments it can have. even if you dont name a parameter to hold the value
Zackarias Gustavsson
@hackarias
Feb 08 2016 00:39 UTC
that makes sense! thanks @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 00:39 UTC
zackgus sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 672 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 00:39 UTC
@zackgus YW
Alex Tze
@Tze14
Feb 08 2016 00:39 UTC
@Takumar so .. 0 = 0+1 + 0 = 0+2 + 0 = 0+3 this is what I have in my mind
where .. var total = 0
greg
@wearenotgroot
Feb 08 2016 00:40 UTC
@Tze14 if you start at 0 yes
@Tze14 but the total increase each step on the loop
Alex Tze
@Tze14
Feb 08 2016 00:41 UTC
@wearenotgroot got it, just wanna give an image to my brain cause I cant just take it like it is
@wearenotgroot thanks
CamperBot
@camperbot
Feb 08 2016 00:41 UTC
tze14 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 673 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Salman Shahid
@salman-shahid
Feb 08 2016 00:41 UTC
var lh = $("quote-btns").css("height");
$("#quote-twitter").css("line-height", lh.value);
I am trying to retrieve the height of a div and set it to the line-height property for another element. I am following: http://api.jquery.com/css/ Any ideas on why it's not working?
greg
@wearenotgroot
Feb 08 2016 00:42 UTC
@mynameissal is quote-btns a class?
@mynameissal or id?
@mynameissal if it is a class then .quote-btns
@mynameissal if id then #qoute-btns
Salman Shahid
@salman-shahid
Feb 08 2016 00:43 UTC
id
bitgrower
@bitgrower
Feb 08 2016 00:43 UTC
bonfire smallest common multiple
CamperBot
@camperbot
Feb 08 2016 00:43 UTC

:fire:Bonfire: Smallest Common Multiple :link:

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

Find the smallest number that is evenly divisible by all numbers in the provided range.

more info:  bf details | bf links | hint

bitgrower
@bitgrower
Feb 08 2016 00:43 UTC
hint
CamperBot
@camperbot
Feb 08 2016 00:43 UTC
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Salman Shahid
@salman-shahid
Feb 08 2016 00:43 UTC
@wearenotgroot OH!
greg
@wearenotgroot
Feb 08 2016 00:43 UTC
@mynameissal then you are missing the #
Salman Shahid
@salman-shahid
Feb 08 2016 00:45 UTC
@wearenotgroot Thanks but it still doesn't work I think there is something wrong with my syntax..
https://jsfiddle.net/himynameissal/dn3ekoos/
CamperBot
@camperbot
Feb 08 2016 00:45 UTC
mynameissal sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 674 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 00:46 UTC
@mynameissal try .getHeight()
Salman Shahid
@salman-shahid
Feb 08 2016 00:51 UTC
nope
greg
@wearenotgroot
Feb 08 2016 00:52 UTC
@mynameissal oh try .height()
Salman Shahid
@salman-shahid
Feb 08 2016 00:53 UTC
I tried that too.. I think it must be something wrong with how it's allocated to line-height
greg
@wearenotgroot
Feb 08 2016 00:54 UTC
@mynameissal did you use lh and not lh.value
Salman Shahid
@salman-shahid
Feb 08 2016 00:56 UTC
yes
Ryan Thomas
@Placid7
Feb 08 2016 01:01 UTC
I thought I had devised a clever way to test if the first letter in an item of an array was capitalized but it's not working.
Any ideas?
function titleCase(str) {
var arr = str.split(' ');

  if(arr[0].toUpperCase() == arr[0]){
    return arr[0];
  }
else return arr[0] + " " + false;

}

titleCase("I'm a little tea pot");
it returns "I'm" false
obviously "I'm" being the word i tested
Salman Shahid
@salman-shahid
Feb 08 2016 01:03 UTC
@Placid7 Please link the challenge.
Ryan Thomas
@Placid7
Feb 08 2016 01:04 UTC
@mynameissal well this isn't necessarily part of the challenge. this is a tool I built to test something I want to implement in my code.
http://www.freecodecamp.com/challenges/title-case-a-sentence
@mynameissal please limit response to my query
Salman Shahid
@salman-shahid
Feb 08 2016 01:05 UTC
What I'm thinking is if (arr[0][0].toUppercase == arr[0][0]) { return arr[0] }
Zac Clemans
@zaclem01
Feb 08 2016 01:05 UTC
I'm a little confused by the expected outputs for the Symmetric Difference problem. For example, one output says this: sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3], [5, 3, 9, 8], [1])should return [1, 2, 4, 5, 6, 7, 8, 9]. However, 1, 2, and 5 all occur in multiple arrays. Is this a mistake or am I missing something about what symmetric arrays mean?
Salman Shahid
@salman-shahid
Feb 08 2016 01:06 UTC
@Placid7 You were checking if the whole word was uppercase.
Also, missing a curly bracket after your else statement
Ryan Thomas
@Placid7
Feb 08 2016 01:06 UTC
@mynameissal good man! and thanks for the explaination on how it works. that makes perfect sense
CamperBot
@camperbot
Feb 08 2016 01:06 UTC
placid7 sends brownie points to @mynameissal :sparkles: :thumbsup: :sparkles:
:star: 282 | @mynameissal | http://www.freecodecamp.com/mynameissal
Ryan Thomas
@Placid7
Feb 08 2016 01:08 UTC
@mynameissal tell you what the farther you get on these challenges the more fun they become
Sergey
@SZharkov
Feb 08 2016 01:10 UTC
@zackgus thanks
CamperBot
@camperbot
Feb 08 2016 01:10 UTC
szharkov sends brownie points to @zackgus :sparkles: :thumbsup: :sparkles:
:star: 273 | @zackgus | http://www.freecodecamp.com/zackgus
Zackarias Gustavsson
@hackarias
Feb 08 2016 01:11 UTC
:+1:
Salman Shahid
@salman-shahid
Feb 08 2016 01:12 UTC
@Placid7 Until you start the web projects. You can get stuck for hours and then realise you made a typo..
Otman Bouchari
@obouchari
Feb 08 2016 01:13 UTC
Hello folks!
Is switch(true) { ... } a hacky solution?
Herman Fassett
@HermanFassett
Feb 08 2016 01:15 UTC
Depends, I think it's normally just fine @obouchari
Otman Bouchari
@obouchari
Feb 08 2016 01:16 UTC
I was wondering since MDN refer to it as hacky way in one of their example
Herman Fassett
@HermanFassett
Feb 08 2016 01:17 UTC
Ah, well I know I have used it before. It can probably normally be more easily replaced by something else but I know I've seen places it felt best
Otman Bouchari
@obouchari
Feb 08 2016 01:18 UTC
That's what I think too, I just want a third opinion :)
@HermanFassett Thanks
CamperBot
@camperbot
Feb 08 2016 01:18 UTC
obouchari sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 1549 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
bitgrower
@bitgrower
Feb 08 2016 01:19 UTC
oh yeah ... the famous typos ...
Michael Betts
@MichaelFlops
Feb 08 2016 01:21 UTC
ahahah how do you give someone brownie points?
Otman Bouchari
@obouchari
Feb 08 2016 01:21 UTC
@MichaelFlops Thanks
CamperBot
@camperbot
Feb 08 2016 01:21 UTC
obouchari sends brownie points to @michaelflops :sparkles: :thumbsup: :sparkles:
:star: 18 | @michaelflops | http://www.freecodecamp.com/michaelflops
Jeff Garrett
@jeffjg
Feb 08 2016 01:22 UTC
Is there a way to log something to the console in FCC? console.log("hi"); isn't working for some reason...
bitgrower
@bitgrower
Feb 08 2016 01:23 UTC
it should -- but you have to open the console window, @jeffjg
Jeff Garrett
@jeffjg
Feb 08 2016 01:23 UTC
ok. So no way to use the console bulit into fcc?
bitgrower
@bitgrower
Feb 08 2016 01:23 UTC
I don't even know what that would be...
Jeff Garrett
@jeffjg
Feb 08 2016 01:23 UTC
oh looks like "return("hi");" works
bitgrower
@bitgrower
Feb 08 2016 01:23 UTC
the console.log will work on chrome ...
and on firefox
the js console is just one part of the chrome dev tools -- which is so huge they even have a conference ...
YAY!!!!!
Michael Betts
@MichaelFlops
Feb 08 2016 01:39 UTC
ahahaha @camperbot Thanks
CamperBot
@camperbot
Feb 08 2016 01:39 UTC
michaelflops sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1124 | @camperbot | http://www.freecodecamp.com/camperbot
Michael Betts
@MichaelFlops
Feb 08 2016 01:39 UTC
AHAHAHHAA @obouchari Thanks
EHunt13
@EHunt13
Feb 08 2016 01:42 UTC
function lookUp(firstName, prop){
// Only change code below this line
for(var i =0; i<contacts.length; i++)
  if(firstName === contacts[i].firstName){
    if (contacts[i].hasOwnProperty(prop)){
      return contacts[i].prop;
    }
  }

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

return "No such contact";

// Only change code above this line
}
// Change these values to test your function
lookUp("Harry", "likes");
i think the first part still isn't working...can someone give me a hint?
for(var i =0; i<contacts.length; i++)
  if(firstName === contacts[i].firstName){
    if (contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
bitgrower
@bitgrower
Feb 08 2016 01:47 UTC
@EHunt13 ... looks very close ...
EHunt13
@EHunt13
Feb 08 2016 01:47 UTC
this worked.......why do i need prop in brackets
why cant I use .prop?
thanks @bitgrower
CamperBot
@camperbot
Feb 08 2016 01:47 UTC
ehunt13 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 379 | @bitgrower | http://www.freecodecamp.com/bitgrower
greg
@wearenotgroot
Feb 08 2016 01:48 UTC
@EHunt13 you can also use else instead of else if in the test for property
EHunt13
@EHunt13
Feb 08 2016 01:48 UTC
thanks @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 01:48 UTC
ehunt13 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 08 2016 01:48 UTC
^^^ what @wearenotgroot said ... simplify your code when possible ...
CamperBot
@camperbot
Feb 08 2016 01:48 UTC
:star: 675 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
EHunt13
@EHunt13
Feb 08 2016 01:48 UTC
why didn't it work with ".prop" though?
return contacts[i].prop;
bitgrower
@bitgrower
Feb 08 2016 01:49 UTC
@EHunt13 dunno
EHunt13
@EHunt13
Feb 08 2016 01:49 UTC
so normally that would work?
bitgrower
@bitgrower
Feb 08 2016 01:49 UTC
it may be that you are consigned to be consistent -- so if you are using [], you have to stay with that notation ...
you're asking questions that are above my pay grade ... sorry, don't have an answer for you ... however, they are great questions ... if you go and research them out on the web you'll learn a ton ...
EHunt13
@EHunt13
Feb 08 2016 01:50 UTC
ok thanks!
bitgrower
@bitgrower
Feb 08 2016 01:51 UTC
MDN is a great place to start ... and if you don't find an answer ... start using google ... stackexchange, youtube are great resources, among others ...
I usually read a bit about js before I go to sleep at night ...
...ever expanding my knowledge ... :)
EHunt13
@EHunt13
Feb 08 2016 01:57 UTC
thanks....it works now and is simplified...still having trouble wrapping my head around the code
greg
@wearenotgroot
Feb 08 2016 01:59 UTC
@EHunt13 read it as it is
@EHunt13 it will make sense
EHunt13
@EHunt13
Feb 08 2016 02:00 UTC
just clicked
thanks again guys
greg
@wearenotgroot
Feb 08 2016 02:02 UTC
@EHunt13 also as for you question about the .prop and why it didnt work
@EHunt13 there is no property in the objects in the contacts list named prop, but you have a parameter named prop
@EHunt13 so it will return undefined
@EHunt13 while in the case of .firstName on the other hand
@EHunt13 you have both a parameter named firstName and object property inside contacts called firstName
@EHunt13 look at this
 {
        "firstName": "Akira", <------------------------------firstName so can be access with contacts[i].firstName
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
@EHunt13 but if you do contacts[i].prop above^ there is no property named prop so it wont work
greg
@wearenotgroot
Feb 08 2016 02:07 UTC
@EHunt13 however if you doe contacts[i][prop] ^ you'll get a value because, prop is a parameter with a value eg. "likes". so ------------------------>contacts[i]["likes"] will be the same as contacts[i][prop]
Chase Childers
@d00mb0x
Feb 08 2016 02:09 UTC
Hello everyone, I'm having a problem with the Stand in Line challenge, anyone have a moment who could help explain it to me?
greg
@wearenotgroot
Feb 08 2016 02:10 UTC
@d00mb0x what didnt you understand? and post what you got so far
Chase Childers
@d00mb0x
Feb 08 2016 02:10 UTC
@wearenotgroot I don't have any working code at the time. I thought initially they wanted me to use .shift and .pop but I don't think thats correct for this solution.
greg
@wearenotgroot
Feb 08 2016 02:11 UTC
@d00mb0x yes use shift() to remove element at index 0
@d00mb0x however you also need to add the item with .push(item)
Ekpo David
@ekpo-d
Feb 08 2016 02:12 UTC
hi guys
greg
@wearenotgroot
Feb 08 2016 02:12 UTC
@d00mb0x re-read the instruction carefully :smile:
Ekpo David
@ekpo-d
Feb 08 2016 02:12 UTC
pls im looking for someone to pair program with
Chase Childers
@d00mb0x
Feb 08 2016 02:12 UTC
@wearenotgroot I'll try again thanks for the input
CamperBot
@camperbot
Feb 08 2016 02:12 UTC
d00mb0x sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
Austin West
@scienceoflife
Feb 08 2016 02:12 UTC
@ekpo-d what exactly are you looking to do?
CamperBot
@camperbot
Feb 08 2016 02:12 UTC
:star: 676 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Ekpo David
@ekpo-d
Feb 08 2016 02:12 UTC
im in intermediate js scripting...anyone interested?
Austin West
@scienceoflife
Feb 08 2016 02:13 UTC
@ekpo-d when you say pair programming, how are you wanting to do that?
Chase Childers
@d00mb0x
Feb 08 2016 02:13 UTC
@wearenotgroot Appreciate it!
Ekpo David
@ekpo-d
Feb 08 2016 02:13 UTC
noting really, been doing the challenges on my own, but thought it'd be fun to have someone who we could go through it together
greg
@wearenotgroot
Feb 08 2016 02:13 UTC
@d00mb0x :+1:
Ekpo David
@ekpo-d
Feb 08 2016 02:14 UTC
@scienceoflife i mean go through the challenges together with
Austin West
@scienceoflife
Feb 08 2016 02:14 UTC
@ekpo-d how do you propose doing that? are you going to share your screen and then communicate via chat?
Ekpo David
@ekpo-d
Feb 08 2016 02:17 UTC
yes...
and i also felt finding someone in who's at intermediat algo scripting too would be cool
intermidiate*
@scienceoflife interested?
Austin West
@scienceoflife
Feb 08 2016 02:25 UTC
@ekpo-d not at the moment.pair coding on challenges would be a little difficult over the web
but if you ever take on some independent projects and want to work via something like c9.io feel free to hit me up
Cooper Reck
@cooperreck
Feb 08 2016 02:28 UTC

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun = wordBlanks[0];
myAdjective = wordBlanks1;
myVerb = wordBlanks[2];
myAdverb = wordBlanks[3];
result = "The stupid " + myNoun + " stupidly " + myVerb + " very " + myAdverb + " into the freaking door.";

// Your code above this line
return result;
}

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

what am I doing wrong?
:(
rphares
@rphares
Feb 08 2016 02:29 UTC
@cooperreck you dont need all the top part,
myNoun = wordBlanks[0]; myAdjective = wordBlanks1; myVerb = wordBlanks[2]; myAdverb = wordBlanks[3];
thats unecceary, you are just building a sentence, the function will fill in the words for you when you call in :)
@ekpo-d , there is a pair programming room if you are looking for a paiar--
as i understand it, the room is often pretty dead, but
if you leave a message there, people may get back to you :)
(pairing is pretty popular-- its was originally required, if i recall-- as its good for both partners and quite valuable as a potential hire :) )
Cooper Reck
@cooperreck
Feb 08 2016 02:32 UTC
when I got rid of the top part the output was correct but the test did not pass
@rphares
Ekpo David
@ekpo-d
Feb 08 2016 02:33 UTC
@scienceoflife ok
rphares
@rphares
Feb 08 2016 02:33 UTC
@cooperreck , can you paste again?
(sorry, i may have missed small things-- just waking up :blush: )
Cooper Reck
@cooperreck
Feb 08 2016 02:33 UTC

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

result = "The stupid " + myNoun + " stupidly " + myVerb + " very " + myAdverb + " into the freaking door.";

// Your code above this line
return result;
}

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

rphares
@rphares
Feb 08 2016 02:33 UTC
oh--
Ekpo David
@ekpo-d
Feb 08 2016 02:34 UTC
@rphares thanks alot, didn't know there's a room for that
CamperBot
@camperbot
Feb 08 2016 02:34 UTC
ekpo-d sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2540 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 08 2016 02:34 UTC
do you have myAdjective in there? @cooperreck
you need all four...
sure thing! (do note it sometimes takes a bit of time-- its isn't a super active room, but can be useful as a message board type way of finding someone :) @ekpo-d )
Cooper Reck
@cooperreck
Feb 08 2016 02:35 UTC
-_- well crap @rphares haha thanks!
CamperBot
@camperbot
Feb 08 2016 02:35 UTC
cooperreck sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2541 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 08 2016 02:35 UTC
anytime~
Ekpo David
@ekpo-d
Feb 08 2016 02:37 UTC
@rphares ok,cool
swynt
@swynt
Feb 08 2016 02:37 UTC
hi guys, i need help at checkpoint Profile Lookup
//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
  if ((firstName ==  contacts[0]) && ((prop == "firstName") || (prop == "lastName") || (prop == "number") || (prop == "likes"))) {
    return contacts.prop;
  } else if (firstName !=  contacts[0]) {
    return "No such contact";
  } else if ((prop != "firstName") || (prop != "lastName") || (prop != "number") || (prop != "likes")) {
    return "No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Austin West
@scienceoflife
Feb 08 2016 02:38 UTC
@swynt when are you checking if firstName == contacts[1]?
thats your clue as to where to start
Cooper Reck
@cooperreck
Feb 08 2016 02:39 UTC
btw just for future knowledge, how does one paste like that ^^^^
Ken Haduch
@khaduch
Feb 08 2016 02:40 UTC
help format
CamperBot
@camperbot
Feb 08 2016 02:40 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Ken Haduch
@khaduch
Feb 08 2016 02:40 UTC
@cooperreck - that ^^^ is for you
swynt
@swynt
Feb 08 2016 02:44 UTC
@scienceoflife i dont really get it
Cooper Reck
@cooperreck
Feb 08 2016 02:44 UTC
@khaduch thanks!
CamperBot
@camperbot
Feb 08 2016 02:44 UTC
cooperreck sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 491 | @khaduch | http://www.freecodecamp.com/khaduch
Austin West
@scienceoflife
Feb 08 2016 02:44 UTC
arlight @swynt , if you were to return contacts[0]
what would be the value it would give?
Jay Song
@jsjjashik
Feb 08 2016 02:46 UTC
Hello, I'm attempting the exercise "Factorialize a Number". I have the following code: function factorialize(num) {
for (var x = 1; x<=num; x++) {
num = num * x;
}
return num;
}
it's giving me an "error: potential infinite loop at line 2.". I don't understand why this is an inifintie loop.
could someone explain?
swynt
@swynt
Feb 08 2016 02:49 UTC
@scienceoflife
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
}
Senfex
@Senfex
Feb 08 2016 02:49 UTC
@jsjjashik Hello , every time you iterate you are increasing num, so x is never less than x.
Austin West
@scienceoflife
Feb 08 2016 02:50 UTC
@swynt so nowhere in your code is it checking the name against any other indexes in the array
Jay Song
@jsjjashik
Feb 08 2016 02:50 UTC
gotcha. thank you
swynt
@swynt
Feb 08 2016 02:51 UTC
@scienceoflife yes, i think i got what you mean
Ivan Perez
@joannesalfa
Feb 08 2016 02:54 UTC
tax camper bot
Minh
@Burange
Feb 08 2016 02:57 UTC

function queue(arr, item) {
// Your code here
console.log(arr.length);
if(arr.length == 1){
return arr[0];
} else if (arr.length === 0){
return item;
} else{
arr.push(item);
var rem = arr.splice(0,1);
console.log(rem);
return rem; // Change this line
}
}

// Test Setup
var testArr = [5,6,7,8,9];

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

it says queue([5,6,7,8,9], 1) should return 5, i don't get it
rphares
@rphares
Feb 08 2016 02:59 UTC
@Burange , is that stand in line?
i suggest reading up on push and shift, maybe check out the MDNs,
thats really all you need, nothing complicated :blush:
swynt
@swynt
Feb 08 2016 03:08 UTC
@scienceoflife how about this one?
function lookUp(firstName, prop){
// Only change code below this line
  if (((firstName == contacts[0]["firstName"]) || 
       (firstName == contacts[1]["firstName"]) || 
       (firstName == contacts[2]["firstName"]) || 
       (firstName == contacts[3]["firstName"])) && 
      ((prop == "firstName") || 
       (prop == "lastName") || 
       (prop == "number") || 
       (prop == "likes"))) {
        return contacts.prop;
  } else if ((firstName !=  contacts[0]["firstName"]) || 
             (firstName !=  contacts[1]["firstName"]) || 
             (firstName !=  contacts[2]["firstName"]) || 
             (firstName !=  contacts[3]["firstName"])) {
        return "No such contact";
  } else if ((prop != "firstName") || 
             (prop != "lastName") || 
             (prop != "number") || 
             (prop != "likes")) {
        return "No such property";
  }
// Only change code above this line
}
Austin West
@scienceoflife
Feb 08 2016 03:09 UTC
@swynt dont use chained or's , try a for loop
Garrett
@grrttmrtn
Feb 08 2016 03:15 UTC
can someone help me with this

function phoneticLookup(val) {
var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");

rphares
@rphares
Feb 08 2016 03:15 UTC
sure, @grrttmrtn ~
you have a good start, but we have three things to fix
first, we were supposed to make 'a table called lookup' (from instructions)
so you should name your table var lookup, not val
the, the next two things-- we need to build the lookup part (where it gets val) and then think about the return,
here, @grrttmrtn ?
Garrett
@grrttmrtn
Feb 08 2016 03:17 UTC
Yep, I'm here
I fixed the variable
rphares
@rphares
Feb 08 2016 03:17 UTC
okay-- so lets look at the lookup part,
checkout the example on the left
their table is named var alpha and they want to get 2, so they write alpha[2]
your table is named var lookup and you want to get val, so you can write...?
Garrett
@grrttmrtn
Feb 08 2016 03:19 UTC
lookup["string"]
rphares
@rphares
Feb 08 2016 03:19 UTC
mm, you dont need "string"
we were told to lookup up val, that will work perfectly for us :)
but thats the format, yes tableName[thingWeWantToGet]
This message was deleted
so we dont want to just return lookup[val] in this exercise, which would work but doesn't follow what we've been given,
This message was deleted
so, we set result = " " above the table
now, we want to put our nice lookup that we just built in result before we return,
so that it gives us what we are looking for,
how could you write that?
swynt
@swynt
Feb 08 2016 03:29 UTC
@scienceoflife
function lookUp(firstName, prop){
// Only change code below this line
  for(i=0; i<4; i++){
    if (((firstName == contacts[i]["firstName"])) && 
        ((prop == "firstName") || 
         (prop == "lastName") || 
         (prop == "number") || 
         (prop == "likes"))) {
          return contacts.prop;    
  } else if ((firstName !=  contacts[i]["firstName"])) {
        return "No such contact";
  } else if ((prop != "firstName") || 
             (prop != "lastName") || 
             (prop != "number") || 
             (prop != "likes")) {
        return "No such property";
  }
  }
// Only change code above this line
}
rphares
@rphares
Feb 08 2016 03:30 UTC
@grrttmrtn , you get it?
Garrett
@grrttmrtn
Feb 08 2016 03:30 UTC
Not yet. Working on it still
Austin West
@scienceoflife
Feb 08 2016 03:30 UTC
@swynt you shouldnt be using any || or && operations
rphares
@rphares
Feb 08 2016 03:31 UTC
okay, cool-- feel free to paste again if you are still stuck :blush:
swynt
@swynt
Feb 08 2016 03:31 UTC
@scienceoflife any other hints?
Austin West
@scienceoflife
Feb 08 2016 03:32 UTC
@swynt sure (this may not be 100%, but along this route): if (prop === contacts[i][prop])
Garrett
@grrttmrtn
Feb 08 2016 03:32 UTC
@rphares finally got it...I was missing my return statement
rphares
@rphares
Feb 08 2016 03:32 UTC
yay! congrats, @grrttmrtn ~
Garrett
@grrttmrtn
Feb 08 2016 03:33 UTC
Thanks for the help!
rphares
@rphares
Feb 08 2016 03:33 UTC
@swynt , profile lookup? dunno where you are, but here is a hint someone left that seemed to help someone else a lot,
some pseudocode for this might look like this:
for each item in the contact list
    does this person have the name we are looking for?
        YES - does this person have the property we are looking for?
           YES - return the property value
           NO - return the 'no such property' return
        NO - (this s the non-matching name test) just continue the loop
(after running out of names) - return "No such contact"
anytime, @grrttmrtn :) Happy coding~
swynt
@swynt
Feb 08 2016 03:34 UTC
@scienceoflife @rphares thanks for the hints, will try again now
CamperBot
@camperbot
Feb 08 2016 03:34 UTC
swynt sends brownie points to @scienceoflife and @rphares :sparkles: :thumbsup: :sparkles:
:star: 2544 | @rphares | http://www.freecodecamp.com/rphares
:star: 69 | @scienceoflife | http://www.freecodecamp.com/scienceoflife
rphares
@rphares
Feb 08 2016 03:35 UTC
not even mine, heh-- ill thank him
thanks, @khaduch ~
CamperBot
@camperbot
Feb 08 2016 03:35 UTC
rphares sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 492 | @khaduch | http://www.freecodecamp.com/khaduch
swynt
@swynt
Feb 08 2016 03:43 UTC
still doesnt work
function lookUp(firstName, prop){
// Only change code below this line
  for(i=0; i<4; i++){
    if ((firstName === contacts[i]["firstName"]) && 
        (prop === contacts[i][prop])) {
          return contacts.prop;    
  } else if ((firstName !== contacts[i]["firstName"])) {
        return "No such contact";
  } else if (prop === contacts[i][prop]) {
        return "No such property";
  }
  }
// Only change code above this line
}
bitgrower
@bitgrower
Feb 08 2016 03:44 UTC
@swynt -- think about each condition separately, and how you would fulfill that condition ?
try not to think about them all at once ... but look at EACH condition and see how you would solve it ... separately ...
Pete Considine
@pjconsidine
Feb 08 2016 03:53 UTC
Hi everyone. I need some help with the Arguments Optional challenge
bitgrower
@bitgrower
Feb 08 2016 03:56 UTC
go for it @pjconsidine
Austin Thornley
@AustinThornley
Feb 08 2016 03:56 UTC
This message was deleted
bitgrower
@bitgrower
Feb 08 2016 03:56 UTC
I just recently did that one ... and it took me a bit to get my mind around it ...
Austin ```js
Austin Thornley
@AustinThornley
Feb 08 2016 03:57 UTC
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

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

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

  return myBike;
  // Only change code above this line.
};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(1);
I need some help on Make Object Properties Private
@bitgrower Yes I know. I meant to press shift enter after that haha
I'm still getting these errors after this code
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Pete Considine
@pjconsidine
Feb 08 2016 03:58 UTC
@bitgrower It seems my function to test whether an argument is a number isn't working
though it really looks like it ought to be
bitgrower
@bitgrower
Feb 08 2016 03:58 UTC
paste away @pjconsidine
it's probably something minor, then ...
Pete Considine
@pjconsidine
Feb 08 2016 03:59 UTC
function add() {
    function isNumber(arg) {
        if (typeof arg !== "number") {
            return undefined;
        } else {
            return arg;
        }
    }
    // the variables the function needs to run
    var i = arguments.length;
    var x = isNumber(arguments[0]);
    var y = i > 1 ? arguments[1] : undefined;

    // the function that needs to run
    var sum = isNumber(y) !== undefined ? x + y : (function(){
        return function(y) {
            return x + y;
        };
    })();
    // return the function
    return sum;
}
bitgrower
@bitgrower
Feb 08 2016 03:59 UTC
@AustinThornley -- have you output intermediate results to console.log and see what they ARE returning ?
a lot of times when you see what your program is doing, you can easily figure out what it's doing WRONG ...
Austin Thornley
@AustinThornley
Feb 08 2016 04:00 UTC
@bitgrower It's not returning anything though..
bitgrower
@bitgrower
Feb 08 2016 04:01 UTC
do you have a return statement ?
swynt
@swynt
Feb 08 2016 04:01 UTC

@bitgrower
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact. If both are true, then return the "value" of that property.

if ((firstName === contacts[i]["firstName"]) && 
        (prop === contacts[i][i])) {
          return contacts[i][prop];

If firstName does not correspond to any contacts then return "No such contact"

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

If prop does not correspond to any valid properties then return "No such property"
```

If prop does not correspond to any valid properties then return "No such property"
if (prop !== contacts[i][prop]) {
        return "No such property";
Jacob Andra
@jacob4
Feb 08 2016 04:01 UTC
Hodor!
rphares
@rphares
Feb 08 2016 04:01 UTC
@jacob4 ! WB :)
Jacob Andra
@jacob4
Feb 08 2016 04:02 UTC
haha
bitgrower
@bitgrower
Feb 08 2016 04:02 UTC
okay ... excellent @swynt -- what do you have to do to satisfy the LAST constraint ?
Austin Thornley
@AustinThornley
Feb 08 2016 04:02 UTC
@bitgrower Yes I have return myBike;
bitgrower
@bitgrower
Feb 08 2016 04:02 UTC
where is myBike defined ?
Austin Thornley
@AustinThornley
Feb 08 2016 04:03 UTC
@bitgrower Wait so should I define it or be calling something else?
Pete Considine
@pjconsidine
Feb 08 2016 04:03 UTC
@AustinThornley not to butt in, but I see that your setGear method is actually adding or subtracting, not setting the gear
Austin Thornley
@AustinThornley
Feb 08 2016 04:04 UTC
@pjconsidine Oh thank you! ;P
CamperBot
@camperbot
Feb 08 2016 04:04 UTC
austinthornley sends brownie points to @pjconsidine :sparkles: :thumbsup: :sparkles:
:star: 387 | @pjconsidine | http://www.freecodecamp.com/pjconsidine
Pete Considine
@pjconsidine
Feb 08 2016 04:04 UTC
so when you do setGear(4), it's subtracting 4 from 6
bitgrower
@bitgrower
Feb 08 2016 04:04 UTC
well, it's kinda hard to return a variable you haven't defined, and even harder if you haven't declared it ... the first would get you "undefined" ... not sure about the second ... I think that will actually get you an interpreter error ...
Pete Considine
@pjconsidine
Feb 08 2016 04:05 UTC
@AustinThornley you're welcome...if it actually works. ;0
bitgrower
@bitgrower
Feb 08 2016 04:05 UTC
@pjconsidine ... I'm not sure if I understand enough in how you are solving the problem to help you ...
I will go look at my solution ... but it seems like you have defined 2 new functions ... I don't recall having to do that ...
Pete Considine
@pjconsidine
Feb 08 2016 04:06 UTC
yeah. the first one is for checking if an argument is a number
the second is supposed to be the function to return if only one argument is passed in
swynt
@swynt
Feb 08 2016 04:07 UTC
@bitgrower i am not sure, but is this correct?
if (prop !== contacts[i][i]) {
        return "No such property";
  }
bitgrower
@bitgrower
Feb 08 2016 04:08 UTC
yeah, I basically used a switch statement to determine the number of arguments passed to add ... and then when that was 1, I determined whether the next argument on the stack was a number ...
@swynt -- how does that fit in the larger context ?
Pete Considine
@pjconsidine
Feb 08 2016 04:08 UTC
@bitgrower I thought about doing that
I might just go with that, since the number of options are so small
bitgrower
@bitgrower
Feb 08 2016 04:08 UTC
@swynt if you were to write pseudocode to solve it, what would it look like ... ?
@pjconsidine well ... basically ... case of 0 is undefined, case of 2 if both aren't numbers is undefined ... and I figured for completeness ... to have a default case to return undefined ... seemed cleaner that way (and far more comprehensible to my sometimes befogged mind ... )
@swynt -- the biggest problem folks seem to have with that particular problem is with when to and when not to loop thru all the elements ...
(the 2nd is in addressing the appropriate element)
swynt
@swynt
Feb 08 2016 04:12 UTC
some pseudocode for this might look like this:
for each item in the contact list
    does this person have the name we are looking for?
        YES - does this person have the property we are looking for?
           YES - return the property value
           NO - return the 'no such property' return
        NO - (this s the non-matching name test) just continue the loop
(after running out of names) - return "No such contact"
someone showed me this hint
sennett
@skboi
Feb 08 2016 04:13 UTC
how should i approach the codepen.io exercises...any advice on how to start and what resources would be helpful?
bitgrower
@bitgrower
Feb 08 2016 04:13 UTC
unfortunately, no ...
Pete Considine
@pjconsidine
Feb 08 2016 04:14 UTC
@skboi I started by setting up a template workspace with all the various add-ins I wanted to use (jQuery, Bootstrap, etc.).
bitgrower
@bitgrower
Feb 08 2016 04:14 UTC
okay, @swynt -- how would you make that into js ?
Pete Considine
@pjconsidine
Feb 08 2016 04:14 UTC
then I just cloned the workspace for each new exercise
saved some time that way
bitgrower
@bitgrower
Feb 08 2016 04:14 UTC
good plan, @pjconsidine
sennett
@skboi
Feb 08 2016 04:15 UTC
how do i set up the template?
bitgrower
@bitgrower
Feb 08 2016 04:15 UTC
@swynt ... you may have other problems in your code ... but the easiest one to identify is that you are returning the "no such contact" too soon ...
Pete Considine
@pjconsidine
Feb 08 2016 04:16 UTC
@skboi When you click New Pen, there's a checkbox under Settings for Template
then, the next time you click New Pen, you'll have the option to select "New Pen from Template"
and you can just use the template you made
sennett
@skboi
Feb 08 2016 04:17 UTC
o i see
thanks
i guess I'm just wondering how to set up my template
Pete Considine
@pjconsidine
Feb 08 2016 04:18 UTC
oh.
sennett
@skboi
Feb 08 2016 04:18 UTC
should i look back on previous exercises to see how it is set up
Pete Considine
@pjconsidine
Feb 08 2016 04:18 UTC
that would work
sennett
@skboi
Feb 08 2016 04:19 UTC
I've been so focused on the javascript challenges that it's been a while since doing the html and css
Pete Considine
@pjconsidine
Feb 08 2016 04:19 UTC
I just put a basic HTML structure in there, because I wanted to have the same header and footer in all of them
here's mine, if you want to see what I did
also look at the Settings tab to see what I set there, because that was a lot of why I used templates in the first place
swynt
@swynt
Feb 08 2016 04:22 UTC
@bitgrower so how about this one?
function lookUp(firstName, prop){
// Only change code below this line
  for(i=0; i<4; i++){
    if (firstName === contacts[i]["firstName"]){
      if (prop === contacts[i][i]){
        return contacts[i][prop];
      } else {
        return "No such property";
      } 
        return "No such contact";

    }    
  }  
  }
sennett
@skboi
Feb 08 2016 04:23 UTC
thanks
this will be challenging..
haha
bitgrower
@bitgrower
Feb 08 2016 04:23 UTC
say you have 10 marbles, and you are looking to see if you have a black one in the group -- do you stop after looking at the first marble ?
can you tell me there is no such contact if you haven't looked thru all the objects ?
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:26 UTC
HI
bitgrower
@bitgrower
Feb 08 2016 04:27 UTC
your first return statement will return the correct thing when you get your if statements cleaned up a bit ... as will your 2nd return statement ... but your 3rd statement is in the wrong place ...
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:27 UTC
I need help understanding filter(), can anyone help me?
swynt
@swynt
Feb 08 2016 04:27 UTC
@bitgrower youre right
function lookUp(firstName, prop){
// Only change code below this line
  for(i=0; i<4; i++){
    if (firstName === contacts[i]["firstName"]){
      if (prop === contacts[i][prop]){
        return contacts[i][prop];
      } else {
        return "No such property";
      }       
    }   
  }
  return "No such contact";
  }
bitgrower
@bitgrower
Feb 08 2016 04:27 UTC
:)
Pete Considine
@pjconsidine
Feb 08 2016 04:28 UTC
@Pilotwing I can give it a shot
bitgrower
@bitgrower
Feb 08 2016 04:28 UTC
to make it a more general solution, I wouldn't use "firstname" literal there, but use the firstname variable which was passed to the the function ...
@Pilotwing -- I love Array.filter .. bring it on ... :)
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:29 UTC
function bouncer(arr) {
  var newArr = arr.filter(function(val) {
    return (val !== false) || (val !== "") || (val !== null) || (val != "undefined") || (val != "NaN") || (val !== 0);
  });
  return newArr;
}

bouncer([7, "ate", "", false, 9]);
Is it valid to put a lot of arguments the return of the callbac function? @pjconsidine
bitgrower
@bitgrower
Feb 08 2016 04:30 UTC
hahahahaha ... Falsy bouncer ... you want help with Array.filter, or with solving the challenge ?
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:30 UTC
well I think my problem is that I don't understand how to use the filter function @bitgrower
Pete Considine
@pjconsidine
Feb 08 2016 04:31 UTC
I don't know whether it's valid, but I would think there's a better way than listing all the individual cases
bitgrower
@bitgrower
Feb 08 2016 04:31 UTC
that's a heck of a boolean statement there ... LOL ...
DJ
@qualitymanifest
Feb 08 2016 04:31 UTC
@Pilotwing it's easier to think of it this way: just return the value if it's truthy :wink2:
bitgrower
@bitgrower
Feb 08 2016 04:31 UTC
what ^^^ @qualitymanifest said
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:32 UTC
@qualitymanifest I remember you help me yesterday
@bitgrower lol I know
bitgrower
@bitgrower
Feb 08 2016 04:32 UTC
yeah, @qualitymanifest is very helpful ... :)
DJ
@qualitymanifest
Feb 08 2016 04:32 UTC
haha cool. i'm here a lot... maybe too much
bitgrower
@bitgrower
Feb 08 2016 04:32 UTC
I know that feeling ...
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:32 UTC
@qualitymanifest I tried doind seprate if statements but still it wont work
bitgrower
@bitgrower
Feb 08 2016 04:33 UTC
@Pilotwing -- WHY doesn't it work ?

...try and figure that out ...

but, I'll also give you a hint -- go read the two helpful hint pages provided, and you'll find an easy solution ... :)

I spent hours on that challenge ... and while I did have a solution, and I learned a bunch ... after that, I re-read the pages and discovered a super easy solution ...
swynt
@swynt
Feb 08 2016 04:35 UTC
to make it a more general solution, I wouldn't use "firstname" literal there, but use the firstname variable which was passed to the the function ...
i dont get it...
@bitgrower any other hints?
bitgrower
@bitgrower
Feb 08 2016 04:37 UTC
firstname is a variable which contains the property "firstname" ... when you use the variable, you can use the code to search for any other property ...
Anthony Isaacs
@AnthonyIsaacs
Feb 08 2016 04:37 UTC
@swynt He’s just saying that hardcoding the string “firstName” means that you can never use that function for any other property. But if you use a variable, just as you did for prop, then it’s no problem.
bitgrower
@bitgrower
Feb 08 2016 04:37 UTC
when you use "firstname" literally, you are hard-coding a vallue into the code ... and hardcoding is not good for a variety of reasons ...
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:38 UTC
ok so if I only check one argument, for example: val !== false then I get that element out of the array. But if I try two or more I get the array without changes @bitgrower but I read the two pages again to see what I am missing
Jason Ulaner
@julaner
Feb 08 2016 04:38 UTC
Totally stuck and confused on nesting for loops. I don't understand the multiple for loops and how they relate to the array?
bitgrower
@bitgrower
Feb 08 2016 04:38 UTC
let's see your code again, @Pilotwing
DJ
@qualitymanifest
Feb 08 2016 04:39 UTC
@Pilotwing http://www.w3schools.com/js/js_booleans.asp the more relevant bits start about halfway through but you might wanna skim the whole thing
Jason Ulaner
@julaner
Feb 08 2016 04:39 UTC

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++)
for (var j = 0; j < arr[i].length; i++)
product *= arr[i][j];
// Only change code above this line
return product;
}

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

swynt
@swynt
Feb 08 2016 04:39 UTC
@AnthonyIsaacs @bitgrower
function lookUp(firstName, prop){
// Only change code below this line
  for(i=0; i<4; i++){
    if (firstName === contacts[i][prop]){
      if (prop === contacts[i][prop]){
        return contacts[i][prop];
      } else {
        return "No such property";
      }       
    }   
  }
  return "No such contact";
  }
Jason Ulaner
@julaner
Feb 08 2016 04:39 UTC
probably way off
Anthony Isaacs
@AnthonyIsaacs
Feb 08 2016 04:39 UTC
@julaner Please put backticks before and after your code so it looks nice :)
bitgrower
@bitgrower
Feb 08 2016 04:39 UTC
@swynt ... you want to use the Object function .hasOwnProperty ...
David Weedmark
@DavidWeedmark
Feb 08 2016 04:40 UTC
@julaner which project is that? I found this discussion helpful for nested loops in general http://stackoverflow.com/questions/6237692/javascript-confused-about-how-nested-for-loops-work
Jason Ulaner
@julaner
Feb 08 2016 04:40 UTC
@AnthonyIsaacs will do
@DavidWeedmark hey how are you?! I'll go check out that link, thank you!
CamperBot
@camperbot
Feb 08 2016 04:40 UTC
julaner sends brownie points to @davidweedmark :sparkles: :thumbsup: :sparkles:
:star: 297 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
bitgrower
@bitgrower
Feb 08 2016 04:40 UTC
@julaner -- I don't see anything obviouslly wrong ...
DJ
@qualitymanifest
Feb 08 2016 04:40 UTC
@julaner for (var j = 0; j < arr[i].length; i++) look at the bold text
@julaner also both of your loops are missing semicolons
bitgrower
@bitgrower
Feb 08 2016 04:41 UTC
lol ...
I missed that one, @qualitymanifest
DJ
@qualitymanifest
Feb 08 2016 04:41 UTC
:wink2:
bitgrower
@bitgrower
Feb 08 2016 04:41 UTC
loops -- semicolons ?
Jason Ulaner
@julaner
Feb 08 2016 04:42 UTC
@qualitymanifest I added semicolons, and changed i++ to j++ but still no go
bitgrower
@bitgrower
Feb 08 2016 04:42 UTC
oh, within the loops
DJ
@qualitymanifest
Feb 08 2016 04:42 UTC
@julaner paste your code again
or wait
better yet
bitgrower
@bitgrower
Feb 08 2016 04:42 UTC
@julaner
post this way ...
<code>
oops .. I thought that didint' work unless it was on the first line ...
Jason Ulaner
@julaner
Feb 08 2016 04:42 UTC

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++);
for (var j = 0; j < arr[i].length; j++);
product *= arr[i][j];
// Only change code above this line
return product;
}

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

<code>
DJ
@qualitymanifest
Feb 08 2016 04:43 UTC
oh vrap
bitgrower
@bitgrower
Feb 08 2016 04:43 UTC
@julaner ... on your first line put ```js
DJ
@qualitymanifest
Feb 08 2016 04:43 UTC
*crap
i meant curly braces not semicolons
{}
bitgrower
@bitgrower
Feb 08 2016 04:43 UTC
on the 2nd line, paste in your code
DJ
@qualitymanifest
Feb 08 2016 04:43 UTC
my mistake
Jason Ulaner
@julaner
Feb 08 2016 04:43 UTC
@bitgrower how do you paste in that format?
Anthony Isaacs
@AnthonyIsaacs
Feb 08 2016 04:43 UTC
```
code here
```
bitgrower
@bitgrower
Feb 08 2016 04:43 UTC
copy and paste, @julaner ...
DJ
@qualitymanifest
Feb 08 2016 04:43 UTC
for (blah blah) {

}
bitgrower
@bitgrower
Feb 08 2016 04:44 UTC
Well @AnthonyIsaacs -- he does have to put ```js in there or the syntax coloring won't work
==> first line ==> js ==> 2nd line forward ==> all of your code ==> after that, another new line, and
David Weedmark
@DavidWeedmark
Feb 08 2016 04:45 UTC
ha FCC should add an exercise for posting code here. I still screw it up half the time too
bitgrower
@bitgrower
Feb 08 2016 04:45 UTC
yeah, I should make a video ...
DJ
@qualitymanifest
Feb 08 2016 04:45 UTC
could just make a gif haha
bitgrower
@bitgrower
Feb 08 2016 04:45 UTC
the explain format doesn't quite do the trick ...
Pete Considine
@pjconsidine
Feb 08 2016 04:46 UTC
control-shift-M
gives you all the keyboard shortcuts
DJ
@qualitymanifest
Feb 08 2016 04:46 UTC
ideally this video or gif should be in howtobasic style https://www.youtube.com/watch?v=MX6uewdLrjs
Pete Considine
@pjconsidine
Feb 08 2016 04:47 UTC
@julaner did you get your answer?
Jason Ulaner
@julaner
Feb 08 2016 04:47 UTC
@qualitymanifest do you mean that the {} go around the return product?
bitgrower
@bitgrower
Feb 08 2016 04:47 UTC
hahahahahahahaha
Jason Ulaner
@julaner
Feb 08 2016 04:47 UTC
@pjconsidine still struggling a bit
Anthony Isaacs
@AnthonyIsaacs
Feb 08 2016 04:47 UTC
@bitgrower I was unaware. Thanks.
CamperBot
@camperbot
Feb 08 2016 04:47 UTC
anthonyisaacs sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 380 | @bitgrower | http://www.freecodecamp.com/bitgrower
Pete Considine
@pjconsidine
Feb 08 2016 04:47 UTC
@julaner double check the formatting of your loops
bitgrower
@bitgrower
Feb 08 2016 04:47 UTC
that's oddly satifying @qualitymanifest
DJ
@qualitymanifest
Feb 08 2016 04:47 UTC
@julaner
for (blah; blah; blah) {
    for (blah; blah; blah) {

    }
}
bitgrower
@bitgrower
Feb 08 2016 04:47 UTC
hey, @AnthonyIsaacs -- we were all unaware at some point ...
Pete Considine
@pjconsidine
Feb 08 2016 04:47 UTC
right now, they're just single line statements, not actual loops
DJ
@qualitymanifest
Feb 08 2016 04:48 UTC
@bitgrower yeah i love those videos
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:48 UTC
@bitgrower @qualitymanifest
DJ
@qualitymanifest
Feb 08 2016 04:48 UTC
@Pilotwing you're missing code. there's yer problem, right there :wink:
bitgrower
@bitgrower
Feb 08 2016 04:49 UTC
definitely bookmarking it for future use, @qualitymanifest
Pete Considine
@pjconsidine
Feb 08 2016 04:50 UTC
thanks @Rafase282 @coded9 for your help with Bonfire: Arguments Optional
CamperBot
@camperbot
Feb 08 2016 04:50 UTC
pjconsidine sends brownie points to @rafase282 and @coded9 :sparkles: :thumbsup: :sparkles:
:star: 958 | @rafase282 | http://www.freecodecamp.com/rafase282
:star: 337 | @coded9 | http://www.freecodecamp.com/coded9
swynt
@swynt
Feb 08 2016 04:51 UTC
@bitgrower why do i need hasOwnProperty ?
Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:51 UTC
function bouncer(arr) {
  var newArr = arr.filter(function(val) {
    return Boolean(val);
  });
  return newArr;
}
bouncer([7, "ate", "", false, 9]);
@qualitymanifest @bitgrower after reading the links and understanding what count as false with boolean I solve it! Thanks!
CamperBot
@camperbot
Feb 08 2016 04:51 UTC
pilotwing sends brownie points to @qualitymanifest and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 925 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 381 | @bitgrower | http://www.freecodecamp.com/bitgrower
DJ
@qualitymanifest
Feb 08 2016 04:52 UTC
@Pilotwing cool glad to hear it :thumbsup:
Jason Ulaner
@julaner
Feb 08 2016 04:52 UTC
@qualitymanifest Thanks! the {} did the trick but only after the second for loop.
CamperBot
@camperbot
Feb 08 2016 04:52 UTC
julaner sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 926 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
bitgrower
@bitgrower
Feb 08 2016 04:52 UTC
lol, amazing what a little research can do, eh @Pilotwing
Jason Ulaner
@julaner
Feb 08 2016 04:52 UTC
why do we use multiple for loops like that?
bitgrower
@bitgrower
Feb 08 2016 04:53 UTC
clarity
Jason Ulaner
@julaner
Feb 08 2016 04:53 UTC
still confusing even though I got the code to pass
David Weedmark
@DavidWeedmark
Feb 08 2016 04:53 UTC

@Pilotwing cool. I just did that one today too ```js function bouncer(arr) {
return arr.filter(Boolean);
}

bouncer([7, "ate", "", false, 9]);```

bitgrower
@bitgrower
Feb 08 2016 04:53 UTC
sorry ... paste your code again and ask again...
David Weedmark
@DavidWeedmark
Feb 08 2016 04:53 UTC
see!?!? I still mess up the code here
bitgrower
@bitgrower
Feb 08 2016 04:53 UTC
@DavidWeedmark -- you need to put the backticks starting on a new line
with nothing else on the line
1 single line ...
David Weedmark
@DavidWeedmark
Feb 08 2016 04:54 UTC
function bouncer(arr) {
  return arr.filter(Boolean);
}

bouncer([7, "ate", "", false, 9]);
bitgrower
@bitgrower
Feb 08 2016 04:54 UTC
tadaaa!!!!
David Weedmark
@DavidWeedmark
Feb 08 2016 04:54 UTC
@bitgrower thanks
CamperBot
@camperbot
Feb 08 2016 04:54 UTC
davidweedmark sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 382 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 08 2016 04:54 UTC
yw
help format
CamperBot
@camperbot
Feb 08 2016 04:55 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Iván Muñiz Rivera
@Pilotwing
Feb 08 2016 04:55 UTC
@DavidWeedmark O I see cause you can put any function as the callback function nice!
bitgrower
@bitgrower
Feb 08 2016 04:55 UTC
lol ... I was hoping there were instructions on how to contribute to the wiki ... sigh ...
swynt
@swynt
Feb 08 2016 04:56 UTC

@bitgrower thanks for the hints so far, it works now

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

but what should i "firstName" replace with?

CamperBot
@camperbot
Feb 08 2016 04:56 UTC
swynt sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 383 | @bitgrower | http://www.freecodecamp.com/bitgrower
David Weedmark
@DavidWeedmark
Feb 08 2016 04:56 UTC
I used to really hate JS... now that I'm getting through these exercises I only mildly detest it
Jason Ulaner
@julaner
Feb 08 2016 04:57 UTC
Thanks guys! have a great night!
bitgrower
@bitgrower
Feb 08 2016 04:57 UTC
awesome, @qualitymanifest
Jason Ulaner
@julaner
Feb 08 2016 04:57 UTC
@DavidWeedmark couldnt agree more
lol
DJ
@qualitymanifest
Feb 08 2016 04:57 UTC
:wave: @julaner
bitgrower
@bitgrower
Feb 08 2016 04:57 UTC
js is growing on me ...
Jason Ulaner
@julaner
Feb 08 2016 04:57 UTC
@qualitymanifest thanks again for the help
bitgrower @bitgrower kicks @camperbot ...
David Weedmark
@DavidWeedmark
Feb 08 2016 04:58 UTC
@julaner have a great nite. I'm outta here
Jason Ulaner
@julaner
Feb 08 2016 04:58 UTC
@DavidWeedmark you too man!
bitgrower
@bitgrower
Feb 08 2016 04:58 UTC
thanks @qualitymanifest
CamperBot
@camperbot
Feb 08 2016 04:58 UTC
bitgrower sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 927 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
bitgrower
@bitgrower
Feb 08 2016 04:59 UTC
wonder why it didn't respond to @julaner's appreciation ...
Norman Dela Cruz
@dcnr
Feb 08 2016 04:59 UTC
@DavidWeedmark it gets better when you learn of other methods of solving problems! :D
DJ
@qualitymanifest
Feb 08 2016 04:59 UTC
@bitgrower ha. tax. cbot hangs up like that sometimes, don't know why but oh well
CamperBot
@camperbot
Feb 08 2016 04:59 UTC
qualitymanifest sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 384 | @bitgrower | http://www.freecodecamp.com/bitgrower
Jay
@lantiwonka
Feb 08 2016 05:00 UTC
can one use two different if/else statements in the same function?
if not why?
DJ
@qualitymanifest
Feb 08 2016 05:01 UTC
the general theory is that he is stockpiling brownies, in a salami slicing type scheme
bitgrower
@bitgrower
Feb 08 2016 05:01 UTC
as soon as I can speak js a bit better, I'll be a very happy camper indeed!
DJ
@qualitymanifest
Feb 08 2016 05:01 UTC
@lantiwonka you can. are you returning before the second one maybe?
Jay
@lantiwonka
Feb 08 2016 05:01 UTC
second
DJ
@qualitymanifest
Feb 08 2016 05:01 UTC
@lantiwonka well paste your code?
Jay
@lantiwonka
Feb 08 2016 05:01 UTC
im returning after the first one
DJ
@qualitymanifest
Feb 08 2016 05:01 UTC
@lantiwonka when you return it exits the function
(IF the conditions are met, in your if statement, to cause the return)...
Jay
@lantiwonka
Feb 08 2016 05:02 UTC
what if i have 3 different conditions to return?
DJ
@qualitymanifest
Feb 08 2016 05:03 UTC
@lantiwonka you will want to return them ONLY if the conditions are met
bitgrower
@bitgrower
Feb 08 2016 05:03 UTC
you might have 3 different return statements !
DJ
@qualitymanifest
Feb 08 2016 05:03 UTC
it's really hard to say what's going on without seeing your code but it sounds like you're returning when you shouldn't... that or there's a problem with your conditions
Jay
@lantiwonka
Feb 08 2016 05:04 UTC

var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 || card <= 6){
count ++;
}
else if (card === 10 || "J" || "Q" || "K" || "A"){
count--;
}

if (count < 0){
return count + " Hold";
}
else if (count === 0){
return count + " Hold";
}
else if (count > 0){
return count + " Bet";
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');

here is the code
10, j, Q, K,A
these inputs are not returning -5
DJ
@qualitymanifest
Feb 08 2016 05:05 UTC
(card === 10 || "J" || "Q" || "K" || "A") so there's a problem here. you need to do card === this || card === that not card === this || that
bitgrower
@bitgrower
Feb 08 2016 05:06 UTC
what I was about to say ..
Jay
@lantiwonka
Feb 08 2016 05:06 UTC
oh #%&$
what is the solution to this?
i mean a short way
aebm
@arthurebm
Feb 08 2016 05:06 UTC
This message was deleted
bitgrower
@bitgrower
Feb 08 2016 05:06 UTC
well, I used a bunch of case statements ...
Jay
@lantiwonka
Feb 08 2016 05:06 UTC
oh alright
thanks @qualitymanifest
CamperBot
@camperbot
Feb 08 2016 05:07 UTC
lantiwonka sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 928 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Jay
@lantiwonka
Feb 08 2016 05:07 UTC
and others
Olawale Akinseye
@brainyfarm
Feb 08 2016 05:14 UTC
About @brainyfarm
CamperBot
@camperbot
Feb 08 2016 05:14 UTC
:star: 1370 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
venkats4me
@venkats4me
Feb 08 2016 05:14 UTC

function queue(arr, item) {
// Your code here
var arry;

return arry; // 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));

any body help
bitgrower
@bitgrower
Feb 08 2016 05:14 UTC
did the challenge pages change format ? Mine did, and I'd like the old format back...
@venkats4me ... what do you need to do, and what tools do you have ?
Olawale Akinseye
@brainyfarm
Feb 08 2016 05:16 UTC
@venkats4me you are yet to do anything and remember you should be working with arr and not arry.
venkats4me
@venkats4me
Feb 08 2016 05:17 UTC
i d't understand...
Olawale Akinseye
@brainyfarm
Feb 08 2016 05:17 UTC
You should look into arr.shift() and arr.push @venkats4me.
venkats4me
@venkats4me
Feb 08 2016 05:17 UTC
ok
Olawale Akinseye
@brainyfarm
Feb 08 2016 05:20 UTC
arr. push(item) will add a new item into arr while arr.shift() will delete the first item from arr @venkats4me.
Tridev
@TridevGuha
Feb 08 2016 05:31 UTC
how to compare the elements
DJ
@qualitymanifest
Feb 08 2016 05:34 UTC
@TridevGuha read the "helpful links" provided on the left. .indexOf() is what you will use to compare. .filter() is what you will use to remove... etc
Tridev
@TridevGuha
Feb 08 2016 05:34 UTC
ah ok :)
Devarsh Ruparelia
@devarsh1997
Feb 08 2016 05:34 UTC
Hi Guys. Need some help for "Concatenating Strings with the Plus Equals Operator" challenge. My code seems correct yet I am not getting the waypoint. Can you show me where am I wrong? Code:
DJ
@qualitymanifest
Feb 08 2016 05:35 UTC
@devarsh1997 just paste the full URL to the waypoint so i can see what they expect
if you don't delete any part of the URL i will be able to see your code in it
DJ
@qualitymanifest
Feb 08 2016 05:36 UTC

@devarsh1997 read the instructions...

Instructions
Build myStr over several lines by concatenating these two strings:
"This is the first sentence. " and "This is the second sentence." using the += operator.

Devarsh Ruparelia
@devarsh1997
Feb 08 2016 05:37 UTC
I don't know but I reloaded the challenge and same code worked. Thanks @qualitymanifest for your time, btw.
CamperBot
@camperbot
Feb 08 2016 05:37 UTC
devarsh1997 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 930 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Feb 08 2016 05:38 UTC
@devarsh1997 huh, strange. the code i got in the URL you provided hadn't been changed at all from how it starts. not sure why it didn't include your code. anyway, glad it worked :+1:
Greetings! I've been blazing through everything so far until the "Finding a Remainder" question. I'm not even sure I understand what it's asking me to do.
bitgrower
@bitgrower
Feb 08 2016 05:39 UTC
when you did long division in @Sikthought -- if a number didn't go evenly into a number, there was a "remainder" -- a number smaller than the divisor ...
Corey Gilmore
@sikthought
Feb 08 2016 05:40 UTC
Correct
bitgrower
@bitgrower
Feb 08 2016 05:41 UTC
so ... if you were to divide a number by a divisor, you'd get a whole number and a remainder, right ?
Corey Gilmore
@sikthought
Feb 08 2016 05:42 UTC
Right
bitgrower
@bitgrower
Feb 08 2016 05:42 UTC
so all you have to do is show you know how to use the '%' operator to set the intended variable to the remainder divided by 3 ... without the whole number ...
Corey Gilmore
@sikthought
Feb 08 2016 05:43 UTC
I'm not sure what to do to get the remainder to be 2, and not 3.666666
bitgrower
@bitgrower
Feb 08 2016 05:43 UTC
easy to do --- you just put the remainder operator in there, just like you would use a "/" operator ...
Corey Gilmore
@sikthought
Feb 08 2016 05:43 UTC
Seriously. That was it?
lol
bitgrower
@bitgrower
Feb 08 2016 05:43 UTC
you must be dividing it ... you don't need to divide it ... you don't want the whole number
LOL...yep that's all there is to it ...
Corey Gilmore
@sikthought
Feb 08 2016 05:44 UTC
I'm a moron
bitgrower
@bitgrower
Feb 08 2016 05:44 UTC
LOL ... nah ...
Corey Gilmore
@sikthought
Feb 08 2016 05:44 UTC
hangs head in shame ;)
bitgrower
@bitgrower
Feb 08 2016 05:44 UTC
coding is just humbling ... we all make stupid mistakes ... any coder who tells you differently is lying ...
nothing to hang your head in shame about ...
Corey Gilmore
@sikthought
Feb 08 2016 05:45 UTC
Thanks for your help!
bitgrower
@bitgrower
Feb 08 2016 05:45 UTC
you're most welcome !
Sarthak Langde
@sarthaksl
Feb 08 2016 06:08 UTC
'''
CamperBot
@camperbot
Feb 08 2016 06:08 UTC
:bulb: to format code use backticks! ``` more info
Sarthak Langde
@sarthaksl
Feb 08 2016 06:11 UTC
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
How to solve this?
bitgrower
@bitgrower
Feb 08 2016 06:17 UTC
what do you need to do, @sarthaksl ?
you need to create a statement which gets the value for the key indicated, yes ?
I've tried a few different versions of this in Safari's console and it works ok.
bitgrower
@bitgrower
Feb 08 2016 06:35 UTC
use chrome, you'll be happier ... safari apparently is not quite as compliant as chrome & firefox ...
Adie Williams
@adieCodes
Feb 08 2016 06:36 UTC
Hi all, I'm know I'm missing something obvious but I can't see it. I'm writing a if/else loop a Profile Lookup, when I test the first if statement it works fine, until I add the else if statements then the first statement is ignored but the else if statements are correct. Please help
// search contact list
for(var contact in contacts){
  // If firstName var equals contacts firstName and contact has the var prop return contacts property value
  if (contacts[contact].firstName == firstName && contacts[contact][prop]){
    return contacts[contact][prop];
  // if var firstName is not assigned to a contact return "No such contact"
  } else if (contacts[contact].firstName != firstName){
    return "No such contact";
  // if var prop is not assigned to the contact return no such property
  } else if (contacts[contact][prop] != prop){
    return "No such property";
  }
}
bitgrower
@bitgrower
Feb 08 2016 06:36 UTC
does it pass the tests ?
@thewebologist ... separate the problem into 3 parts ... the 3 things you need to return ...
figure out how you would return each of them -- separately ...
greg
@wearenotgroot
Feb 08 2016 06:38 UTC
@thewebologist the first if statement is not entirely correct
@thewebologist also use regular for loop
bitgrower
@bitgrower
Feb 08 2016 06:39 UTC
ah yes, for sure do that ...
that is, a regular for loop ... otherwise you could get weird results ...
greg
@wearenotgroot
Feb 08 2016 06:39 UTC
@thewebologist for var is use iterating to objects with properties
bitgrower
@bitgrower
Feb 08 2016 06:40 UTC
it also will go down something called the prototype chain ... which you don't want to do here ...
Corey Gilmore
@sikthought
Feb 08 2016 06:40 UTC

I went with

  farenheit = celsius * 9;
  farenheit /= 5;
  farenheit += 32;

with no success.

EHunt13
@EHunt13
Feb 08 2016 06:41 UTC
var lowOnlyAlpha = str.toLowerCase().replace(/[^a-z0-9\s]/gi);
greg
@wearenotgroot
Feb 08 2016 06:41 UTC
@thewebologist
if (contacts[contact].firstName == firstName && contacts[contact][prop])<--------------------------this guy at the end doesnt belong there. if you want to test if a property exist use .hasOwnProperty('somepropname')
bitgrower
@bitgrower
Feb 08 2016 06:41 UTC
yeah, that could be some strange oddities that have to do with the not-quite-equivalence of floating point numbers, @sikthought
EHunt13
@EHunt13
Feb 08 2016 06:42 UTC
hey @wearenotgroot @bitgrower still around huh
bitgrower
@bitgrower
Feb 08 2016 06:42 UTC
hahahahahaha ...
greg
@wearenotgroot
Feb 08 2016 06:42 UTC
@EHunt13 just woke up
bitgrower
@bitgrower
Feb 08 2016 06:42 UTC
come and go ...just like you ...
EHunt13
@EHunt13
Feb 08 2016 06:42 UTC
haha nice
just needed some help figuring out that regular expression, or where to find more info on it.....can't figure out how to get rid of the whitespace
palindrome problem
greg
@wearenotgroot
Feb 08 2016 06:43 UTC
might be a bit loopy. needs fuel COFFEEE!
@EHunt13 here practice -------->https://regex101.com/
@EHunt13 rules at the bottom right of the page
EHunt13
@EHunt13
Feb 08 2016 06:43 UTC
perfect thanks @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 06:43 UTC
ehunt13 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 677 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 06:43 UTC
@EHunt13 also \s is what you want<-----------------------means any whitespace charactes
EHunt13
@EHunt13
Feb 08 2016 06:45 UTC
i'm close, just need to figure out how the regex statement works with the brackets etc...ill practice
bitgrower
@bitgrower
Feb 08 2016 06:45 UTC
help regex
CamperBot
@camperbot
Feb 08 2016 06:46 UTC

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

greg
@wearenotgroot
Feb 08 2016 06:46 UTC
@EHunt13 also ready this thouroughly using replace with regex https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace will help you a ton
bitgrower
@bitgrower
Feb 08 2016 06:46 UTC
should give you all the help you you need ... tutorials, testing, games, blogs, software ... and wiki ref!
EHunt13
@EHunt13
Feb 08 2016 06:46 UTC
thanks @bitgrower
CamperBot
@camperbot
Feb 08 2016 06:46 UTC
ehunt13 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 385 | @bitgrower | http://www.freecodecamp.com/bitgrower
greg
@wearenotgroot
Feb 08 2016 06:48 UTC
anyways going to eat breakfast :smile:
EHunt13
@EHunt13
Feb 08 2016 06:48 UTC
enjoy!
greg
@wearenotgroot
Feb 08 2016 06:48 UTC
@EHunt13 thanks
CamperBot
@camperbot
Feb 08 2016 06:48 UTC
wearenotgroot sends brownie points to @ehunt13 :sparkles: :thumbsup: :sparkles:
:star: 267 | @ehunt13 | http://www.freecodecamp.com/ehunt13
Corey Gilmore
@sikthought
Feb 08 2016 06:49 UTC
@bitgrower — Bummer. I'll just skip it for now and come back later and try it again. Thanks again.
CamperBot
@camperbot
Feb 08 2016 06:49 UTC
sikthought sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 386 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 08 2016 06:49 UTC
didn't the other way work?
Corey Gilmore
@sikthought
Feb 08 2016 06:50 UTC
No. I couldn't get any of it to work.
bitgrower
@bitgrower
Feb 08 2016 06:50 UTC
weird ... I thought you said it worked sometimes in safari ?
mldom
@mldom
Feb 08 2016 06:51 UTC
Just joined
Corey Gilmore
@sikthought
Feb 08 2016 06:51 UTC
Just using the console, not the actual FCC page.
bitgrower
@bitgrower
Feb 08 2016 06:51 UTC
well, like I say, I would use chrome, not safari ... safari reportedly is less standard ...
osheenn
@osheenn
Feb 08 2016 06:51 UTC

function palindrome(str) {
// Good luck!

str = str.toLowerCase();
str = str.replace(/[^\w\s]|_/g, "");
str = str.replace(/\s+/,"");
var n = str.length;
for(i=0;i<n;i++){
if(str[i]!=str[n-1-i])return false;
}

return true;
}

palindrome("never odd or even");

whats wrong with this code ?
Corey Gilmore
@sikthought
Feb 08 2016 06:52 UTC
I'm in Chrome now.
osheenn
@osheenn
Feb 08 2016 06:52 UTC
to check for palindromes
bitgrower
@bitgrower
Feb 08 2016 06:52 UTC

osheen ...

explain format

okay sheesh
explain format
CamperBot
@camperbot
Feb 08 2016 06:52 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

osheenn
@osheenn
Feb 08 2016 06:53 UTC

function palindrome(str) {
// Good luck!

`str = str.toLowerCase();
str = str.replace(/[^\w\s]|_/g, "");
str = str.replace(/\s+/,"");
var n = str.length;
for(i=0;i<n;i++){
if(str[i]!=str[n-1-i])return false;
}

return true;
}

palindrome("never odd or even");`

```function palindrome(str) {
// Good luck!

str = str.toLowerCase();
str = str.replace(/[^\w\s]|_/g, "");
str = str.replace(/\s+/,"");
var n = str.length;
for(i=0;i<n;i++){
if(str[i]!=str[n-1-i])return false;
}

return true;
}

palindrome("never odd or even");

sorry cant figure it out
can anybody help?
bitgrower
@bitgrower
Feb 08 2016 06:54 UTC

first line type ...

```js <-- with NOTHING else on the line

then paste in your code

then type a newline

with

``` <-- with nothing else on it

osheenn
@osheenn
Feb 08 2016 06:55 UTC
thanks @bitgrower
CamperBot
@camperbot
Feb 08 2016 06:55 UTC
osheenn sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 387 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 08 2016 06:55 UTC
yw
osheenn
@osheenn
Feb 08 2016 06:55 UTC
```js<--

```js<--function palindrome(str) {
// Good luck!

str = str.toLowerCase();
str = str.replace(/[^\w\s]|_/g, "");
str = str.replace(/\s+/,"");
var n = str.length;
for(i=0;i<n;i++){
if(str[i]!=str[n-1-i])return false;
}

return true;
}

palindrome("never odd or even");

bitgrower
@bitgrower
Feb 08 2016 06:56 UTC
LOL ... just the ```js
nothing else
only one line ...
then your code
then a single line with 3 backticks on it
Corey Gilmore
@sikthought
Feb 08 2016 06:59 UTC

@bitgrower — This worked:

var fahrenheit = ((celsius * 9) / 5) + 32;

Which I got from a wiki page when looking to see if their was a bug for this problem.

…if THERE was…
Yatendra Pawar
@YatenRuby123
Feb 08 2016 06:59 UTC
Hello need help
I m stuck
Ivan Perez
@joannesalfa
Feb 08 2016 06:59 UTC
@YatenRuby123 what's wrong?
Yatendra Pawar
@YatenRuby123
Feb 08 2016 06:59 UTC

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

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

bitgrower
@bitgrower
Feb 08 2016 07:00 UTC
well ask for help and we'll (hopefully) get you unstuck ...
Salvatore Santamaria
@ssroman
Feb 08 2016 07:00 UTC
Hi. im having trouble with the word blanks game
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:00 UTC
what is wrong with code
osheenn
@osheenn
Feb 08 2016 07:00 UTC

function palindrome(str) {
// Good luck!

str = str.toLowerCase();
str = str.replace(/[^\w\s]|_/g, "");
str = str.replace(/\s+/,"");
var n = str.length;
for(i=0;i<n;i++){
if(str[i]!=str[n-1-i])return false;
}

return true;
}

palindrome("never odd or even");

Ivan Perez
@joannesalfa
Feb 08 2016 07:00 UTC
@YatenRuby123 what's the goal to get passed?
osheenn
@osheenn
Feb 08 2016 07:00 UTC
these green popping out notis are anoying me so much
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:00 UTC
You should not change the original array.
You should add three to each value in the array.
You should be making use of the map method.
You should only modify the array with map.
Adding is where I am stuck
osheenn
@osheenn
Feb 08 2016 07:01 UTC
was that for me?
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:01 UTC
Sorry I changed the val + 3
bitgrower
@bitgrower
Feb 08 2016 07:01 UTC
@YatenRuby123 -- adding ?
osheenn
@osheenn
Feb 08 2016 07:01 UTC
@bitgrower will u help me?
bitgrower
@bitgrower
Feb 08 2016 07:01 UTC
and how is that working now ?
osheenn
@osheenn
Feb 08 2016 07:01 UTC
with my code
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:01 UTC
Adding 3 to each value in the array
Ivan Perez
@joannesalfa
Feb 08 2016 07:02 UTC
@YatenRuby123 oldArray.map() is kind of conversion function, you should modify return val + 3;
bitgrower
@bitgrower
Feb 08 2016 07:02 UTC
explain format
CamperBot
@camperbot
Feb 08 2016 07:02 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Ivan Perez
@joannesalfa
Feb 08 2016 07:02 UTC
@YatenRuby123 and you need to assign this variable correctly
bitgrower
@bitgrower
Feb 08 2016 07:02 UTC
please follow the instructions CLOSELY ...
Vinícius
@vinicius978
Feb 08 2016 07:03 UTC

Can someone help me with this code:
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Ivan Perez
@joannesalfa
Feb 08 2016 07:03 UTC
var newArray = addThree;
@vinicius978 you need to make a sentence inside of result
Vinícius
@vinicius978
Feb 08 2016 07:04 UTC
<function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly");>
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:04 UTC
Ohh ...
Thanks @joannesalfa
CamperBot
@camperbot
Feb 08 2016 07:04 UTC
yatenruby123 sends brownie points to @joannesalfa :sparkles: :thumbsup: :sparkles:
:star: 362 | @joannesalfa | http://www.freecodecamp.com/joannesalfa
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:04 UTC
it worked
budimanfix
@budimanfix
Feb 08 2016 07:04 UTC

function myTest(val) {
var answer = "";
// Only change code below this line

function myTest(val) {
case value1:
var answer = "alpha";
} like this???

bitgrower
@bitgrower
Feb 08 2016 07:05 UTC
@all who are looking for help ... please enter your code, tell us what challenge you are working on (name), and where you are having a problem ...
Ivan Perez
@joannesalfa
Feb 08 2016 07:05 UTC
like
"Hello my name is " + myName + "and  Im "+  myAge +"  years old"
bitgrower
@bitgrower
Feb 08 2016 07:05 UTC
@YatenRuby123 -- what did you do to fix it ?
abdelaziz Galal mahfouz
@abdelazizMahfouz
Feb 08 2016 07:06 UTC
any help with function:
```
Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:06 UTC
So I was using
abdelaziz Galal mahfouz
@abdelazizMahfouz
Feb 08 2016 07:06 UTC
function chunk(arr, size) {


  var resArr=[];

  for(var sp = 0;sp<arr.length; sp+=size){

    resArr.push(arr.slice(sp,size));
    //resArr.push(sp);

  }


  return resArr ;
}

chunk(["a", "b", "c", "d"], 2);

Yatendra Pawar
@YatenRuby123
Feb 08 2016 07:06 UTC
var newArray = oldArray, instead of var newArray = addThree
Vinícius
@vinicius978
Feb 08 2016 07:06 UTC

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

// Your code above this line
return result;
}

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

I'm having problem on these one
Word Blanks
Ivan Perez
@joannesalfa
Feb 08 2016 07:07 UTC
@vinicius978 look my example above
Vinícius
@vinicius978
Feb 08 2016 07:08 UTC
Ok
osheenn
@osheenn
Feb 08 2016 07:08 UTC
someone help me
im new here
Ivan Perez
@joannesalfa
Feb 08 2016 07:08 UTC
@osheenn what's wrong?
osheenn
@osheenn
Feb 08 2016 07:09 UTC

function palindrome(str) {
// Good luck!

str = str.toLowerCase();
str = str.replace(/[^\w\s]|_/g, "");
str = str.replace(/\s+/,"");
var n = str.length;
for(i=0;i<n;i++){
if(str[i]!=str[n-1-i])return false;
}

return true;
}

palindrome("never odd or even");

whats wrong with this code im verifying palindrome character
@joannesalfa
Vinícius
@vinicius978
Feb 08 2016 07:10 UTC
How can i insert a code here with this fancy way?
Ivan Perez
@joannesalfa
Feb 08 2016 07:10 UTC
@osheenn you need to make 2 variables, normalString and reverseString, then compare between normalString and reverseString are same, it should return true
bitgrower
@bitgrower
Feb 08 2016 07:10 UTC
explain format
CamperBot
@camperbot
Feb 08 2016 07:10 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

bitgrower
@bitgrower
Feb 08 2016 07:10 UTC
follow the instructions CAREFULLY ...
Ivan Perez
@joannesalfa
Feb 08 2016 07:11 UTC
@osheenn but reverseString is derived from normalString in backwards if you used split(); then join
also use regex to clean all spaces.
osheenn
@osheenn
Feb 08 2016 07:11 UTC
but what did i do wrong in this? im comparing each element
Ivan Perez
@joannesalfa
Feb 08 2016 07:11 UTC
@osheenn you don't need loop
osheenn
@osheenn
Feb 08 2016 07:11 UTC
whats regex?
bitgrower
@bitgrower
Feb 08 2016 07:11 UTC
help regex
CamperBot
@camperbot
Feb 08 2016 07:11 UTC

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

bitgrower
@bitgrower
Feb 08 2016 07:12 UTC
regular expressions
Ivan Perez
@joannesalfa
Feb 08 2016 07:12 UTC
@osheenn regex = regular expression, did you pass this regex lessons?
osheenn
@osheenn
Feb 08 2016 07:12 UTC
thanks @joannesalfa
CamperBot
@camperbot
Feb 08 2016 07:12 UTC
osheenn sends brownie points to @joannesalfa :sparkles: :thumbsup: :sparkles:
:star: 363 | @joannesalfa | http://www.freecodecamp.com/joannesalfa
osheenn
@osheenn
Feb 08 2016 07:12 UTC
oh ok cool
i dint know the abbreviation
bitgrower
@bitgrower
Feb 08 2016 07:12 UTC
np
Ivan Perez
@joannesalfa
Feb 08 2016 07:13 UTC
for normalString needs to be lower case and replace using regex to remove non-alphanumeric letters
then for reverseString needs split to normalString, then do reverse(); and join();
Vinícius
@vinicius978
Feb 08 2016 07:14 UTC

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

// Your code above this line
return result;
}

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

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

// Your code above this line
return result;
}

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

Ivan Perez
@joannesalfa
Feb 08 2016 07:14 UTC
@vinicius978 you need to add + between strings and arguments
"My name is"; is incomplete
Vinícius
@vinicius978
Feb 08 2016 07:15 UTC
I'm going to take a look at that
Hey, I can't code format this
Ivan Perez
@joannesalfa
Feb 08 2016 07:15 UTC
you need to apply new line
Vinícius
@vinicius978
Feb 08 2016 07:15 UTC
i neede to use my code here?
Ohh
Ivan Perez
@joannesalfa
Feb 08 2016 07:16 UTC
```
code
```
``` code --> THIS IS NOT CORRECT
Vinícius
@vinicius978
Feb 08 2016 07:16 UTC
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "My name is";
  // Your code below this line


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Yay
thanks @joannesalfa
CamperBot
@camperbot
Feb 08 2016 07:17 UTC
vinicius978 sends brownie points to @joannesalfa :sparkles: :thumbsup: :sparkles:
:star: 364 | @joannesalfa | http://www.freecodecamp.com/joannesalfa
Ivan Perez
@joannesalfa
Feb 08 2016 07:17 UTC
var result = " My name is " + myNoun ...
you need to complete sentence with strings and arguments
greg
@wearenotgroot
Feb 08 2016 07:19 UTC
@osheenn you were very close
Ivan Perez
@joannesalfa
Feb 08 2016 07:19 UTC
myNoun is an argument from function that can pass value, it could be "dog"
greg
@wearenotgroot
Feb 08 2016 07:19 UTC
@osheenn here is the fix version of you code`
function palindrome(str) {
// Good luck!
str = str.toLowerCase();
str = str.replace(/[\W_\s]/g, "");
var n = str.length;
for(i=0;i<n;i++){
console.log(str[i]);
console.log(' : '+str[n-1-i]);
if(str[i]!=str[n-1-i])return false;
}
return true;
}
palindrome("never odd or even");
@osheenn remember the ^\w is the same as \W and the underscore should be inside the [] so it will match it with the non-word characters
@osheenn :+1:
osheenn
@osheenn
Feb 08 2016 07:25 UTC
thanks alot @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 07:25 UTC
osheenn sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 678 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 07:26 UTC
@osheenn you did great :+1:
Markus Kiili
@Masd925
Feb 08 2016 07:26 UTC
@osheenn If you make the palindromicality test by comparing the first letter to the last etc, you only have to loop the characters to the half of the string.
Vinícius
@vinicius978
Feb 08 2016 07:27 UTC
what it means by:
'wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).'
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "My name is";
  // Your code below this line


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
greg
@wearenotgroot
Feb 08 2016 07:28 UTC
@vinicius978 just make a sentence using those word. btw the word are stored in the function parameters
Vinícius
@vinicius978
Feb 08 2016 07:29 UTC
Ok
I'll try it
greg
@wearenotgroot
Feb 08 2016 07:29 UTC
@vinicius978 so just concatenate them with +
Jorge Méndez Otero
@Luyes
Feb 08 2016 07:30 UTC
Hi guys, can you recommend me some book or another source of information of jquery for the ziplines?
Adie Williams
@adieCodes
Feb 08 2016 07:30 UTC
@wearenotgroot Thanks for the advice, I definately went down the wrong path. I ended up using seperate if statements, feels clunky but works
CamperBot
@camperbot
Feb 08 2016 07:30 UTC
thewebologist sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 679 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 07:31 UTC
@thewebologist YW
Adie Williams
@adieCodes
Feb 08 2016 07:31 UTC
@bitgrower Thanks for the advice, done seperate if statements and will look to conjoin later
CamperBot
@camperbot
Feb 08 2016 07:31 UTC
thewebologist sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 388 | @bitgrower | http://www.freecodecamp.com/bitgrower
Vinícius
@vinicius978
Feb 08 2016 07:32 UTC
It works. thanks @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 07:32 UTC
vinicius978 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 680 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 07:32 UTC
@vinicius978 YW :smile:
Vinícius
@vinicius978
Feb 08 2016 07:33 UTC
People here are really helpful
bitgrower
@bitgrower
Feb 08 2016 07:33 UTC
@thewebologist -- that's part of it, it helps to know where in the loop you need to return things ...
Vinícius
@vinicius978
Feb 08 2016 07:33 UTC
It's impressive
greg
@wearenotgroot
Feb 08 2016 07:34 UTC
@vinicius978 we are all here to learn from each other :smile:
@Luyes just start with the api for jquery-------->https://api.jquery.com/
Vinícius
@vinicius978
Feb 08 2016 07:36 UTC
;)))
Do you guys know something practical that I can do to exercise what I've learned?
About jQuery
CamperBot
@camperbot
Feb 08 2016 07:38 UTC
you need to ask about @someone!
osheenn
@osheenn
Feb 08 2016 07:39 UTC

function findLongestWord(str) {
var max=0;
var arr = str.split(' ');
var ans = arr.reduce(function(prev,curr){
max = prev.length;
if(curr.length>=max) prev=curr;
return prev;

}, 0);

return ans;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
HELP PLEASE

whats wrong again?
Jorge Méndez Otero
@Luyes
Feb 08 2016 07:39 UTC
@wearenotgroot seems a good point to start, thanks :)
CamperBot
@camperbot
Feb 08 2016 07:39 UTC
luyes sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 681 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 08 2016 07:40 UTC
@Luyes they also have a learning center i thnk
osheenn
@osheenn
Feb 08 2016 07:40 UTC
thanks @all
CamperBot
@camperbot
Feb 08 2016 07:40 UTC
osheenn sends brownie points to @all :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for all
osheenn
@osheenn
Feb 08 2016 07:40 UTC
help me someone
CamperBot
@camperbot
Feb 08 2016 07:41 UTC
no wiki entry for: me someone
osheenn
@osheenn
Feb 08 2016 07:43 UTC
help @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 07:43 UTC
no wiki entry for: @wearenotgroot
bitgrower
@bitgrower
Feb 08 2016 07:44 UTC

@osheenn -- why not just create a variable and set it to longest ... initialize it to 0 and then just iterate thru the array looking for the longest ...

Array.reduce is probably overkill here

greg
@wearenotgroot
Feb 08 2016 07:45 UTC
@osheenn well you were overwriting the value each time the reduce went
@osheenn dont initialise the max inside the reduce function
Kai Schoos
@kschoos
Feb 08 2016 07:46 UTC
Hi there o/
greg
@wearenotgroot
Feb 08 2016 07:47 UTC
@osheenn also you didnt assignt the curr.length to your variable
AndrewBrin
@AndrewBrin
Feb 08 2016 07:47 UTC
Why doesnt my code work

var count = 0;

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

if(card === 2 || card === 3 || card === 4 || card === 5 || card === 6 &&
card === 2 || card === 3 || card === 4 || card === 5 || card === 6 &&
card === 2 || card === 3 || card === 4 || card === 5 || card === 6 &&
card === 2 || card === 3 || card === 4 || card === 5 || card === 6 &&
card === 2 || card === 3 || card === 4 || card === 5 || card === 6)
{
return "5 Bet";
}
else if(card === 7 || card === 8 || card === 9 &&
card === 7 || card === 8 || card === 9 && card === 7 || card === 8 || card === 9)
{
return "0 Hold";
}
else if (card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A' &&
card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A' &&
card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A' &&
card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A' &&
card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A')
{
return "-5 Hold";
}
else if(card === 3 || card === 2 || card === 'A' || card === 10 || card === 'K' &&
card === 3 || card === 2 || card === 'A' || card === 10 || card === 'K' &&
card === 3 || card === 2 || card === 'A' || card === 10 || card === 'K' &&
card === 3 || card === 2 || card === 'A' || card === 10 || card === 'K' &&
card === 3 || card === 2 || card === 'A' || card === 10 || card === 'K'){
return "-1 Hold";
}

return "Change Me";
// 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');

greg
@wearenotgroot
Feb 08 2016 07:47 UTC
@osheenn but instead you assigned the value
bitgrower
@bitgrower
Feb 08 2016 07:48 UTC
@AndrewBrin -- try using a switch statement ... it's cleaner
greg
@wearenotgroot
Feb 08 2016 07:49 UTC

@osheenn

function findLongestWord(str) {
var max=0;
var arr = str.split(' ');
var ans = arr.reduce(function(prev,curr){
max = prev.length; <----------------------no need for this line
if(curr.length>=max) prev=curr;<--------------------forgot to set the length shoudl be prev  = curr.length
return prev;
}, 0);
return ans;
}
findLongestWord("The quick brown fox jumped over the lazy dog");

also just use max instead of prev to keep the values of the longest length
replace all prev with max instead

Markus Kiili
@Masd925
Feb 08 2016 07:49 UTC
@AndrewBrin Lookup object is also an option.
osheenn
@osheenn
Feb 08 2016 07:51 UTC
@wearenotgroot still doesnt work
greg
@wearenotgroot
Feb 08 2016 07:51 UTC
@osheenn replace all prev with max
osheenn
@osheenn
Feb 08 2016 07:52 UTC
@wearenotgroot thanks i missed that max=curr.length thingy
CamperBot
@camperbot
Feb 08 2016 07:52 UTC
osheenn sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: osheenn already gave wearenotgroot points
greg
@wearenotgroot
Feb 08 2016 07:52 UTC
@osheenn YW
osheenn
@osheenn
Feb 08 2016 07:53 UTC
:)
AndrewBrin
@AndrewBrin
Feb 08 2016 07:53 UTC
my switch satement

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
return "5 Bet";
case 7:
case 8:
case 9:
return "0 Hold";
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
return "-5 Hold";
case 3:
case 2:
case 'A':
case 10:
case 'K':
return "-1 Hold";
}

return "Change Me";
// 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');

greg
@wearenotgroot
Feb 08 2016 07:54 UTC
@AndrewBrin you were suppose to use the count-------->increment or decrement it
@AndrewBrin re-read the instruction again :smile:
bitgrower
@bitgrower
Feb 08 2016 07:59 UTC
help sym
CamperBot
@camperbot
Feb 08 2016 07:59 UTC

:point_right: bonfire symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Bonfire you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about bonfire symmetric difference on the FCC Wiki

Kai Schoos
@kschoos
Feb 08 2016 08:00 UTC
Hey, I have a little problem. The solutions I am getting are right but FCC won't accept them. What am I doing wrong?
abdelaziz Galal mahfouz
@abdelazizMahfouz
Feb 08 2016 08:01 UTC

hi all, any help with this code:
```function chunk(arr, size) {

var resArr=[];

for(var sp = 0;sp<arr.length; sp+=size){

resArr.push(arr.slice(sp,size));
//resArr.push(sp);

}

return resArr ;
}

chunk(["a", "b", "c", "d"], 2);
```

function chunk(arr, size) {


  var resArr=[];

  for(var sp = 0;sp<arr.length; sp+=size){

    resArr.push(arr.slice(sp,size));
    //resArr.push(sp);

  }


  return resArr ;
}

chunk(["a", "b", "c", "d"], 2);
rahulkavi
@rahulkavi
Feb 08 2016 08:01 UTC
I don't know what's wrong with my code in "Make Unique Objects by Passing Parameters to our Constructor" challenge? Someone help me to sort this out.

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

//Try it out here
var myCar = new Car(3, 1, 2);
(function() {return JSON.stringify(myCar);})();

EHunt13
@EHunt13
Feb 08 2016 08:02 UTC
function findLongestWord(str) {
  var array = str.split(" ");
  var longest = 0;
  for (var i=0; i<array.length; i++){
    if (array[i].length>array[i+1].length){
      if(array[i].length>longest){
        longest = array[i].length ;
      }
      return longest;
    }
  } 
 }

findLongestWord("the quick brown fox jumped over");
need help with this can't seem to solve, but I think i'm close
i know it won't work if the last word is the longest one, but it is still not working for other examples either and I can't figure out why
greg
@wearenotgroot
Feb 08 2016 08:05 UTC
@EHunt13 just use one if statement
@EHunt13 also remove the return statement inside the loop
@EHunt13 if it is inside it will break the loop and stop the search
osheenn
@osheenn
Feb 08 2016 08:06 UTC
how do we access a letter of an element of an array?
rahulkavi
@rahulkavi
Feb 08 2016 08:07 UTC
got the solution...
EHunt13
@EHunt13
Feb 08 2016 08:07 UTC
got it thanks again @wearenotgroot makes perfect sense too
CamperBot
@camperbot
Feb 08 2016 08:07 UTC
ehunt13 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 682 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Kai Schoos
@kschoos
Feb 08 2016 08:08 UTC
my problem was solved! using !== still created the right output but wasnt accepted. !=worked though.
greg
@wearenotgroot
Feb 08 2016 08:08 UTC
@skusku remember !== is strict mode
Markus Kiili
@Masd925
Feb 08 2016 08:09 UTC
@skusku I didn't check your link, but were you passing arguments[i] into the filter callback?
Kai Schoos
@kschoos
Feb 08 2016 08:10 UTC
@wearenotgroot the strange thing is that it behaved right but FCC wouldnt accept it. Yes I passed arguments[i] as thisObject to the filter callback function
greg
@wearenotgroot
Feb 08 2016 08:10 UTC
@skusku sometime the check have some requirements
Markus Kiili
@Masd925
Feb 08 2016 08:10 UTC
@skusku It is better to pass arguments in and use loop or indexOf inside the callback.
That way you only have to filter the array once.
Kai Schoos
@kschoos
Feb 08 2016 08:11 UTC
Isnt it the same amount of operations ?
Markus Kiili
@Masd925
Feb 08 2016 08:11 UTC
@skusku No.
Kai Schoos
@kschoos
Feb 08 2016 08:12 UTC
Okay.
osheenn
@osheenn
Feb 08 2016 08:12 UTC
@wearenotgroot

function titleCase(str) {
str= str.toLowerCase();
var arr = str.split(' ');
var ans = arr.map(function(val){
var temp = val.split('');
temp[0]=temp[0]-32;
val = temp.join('');
return val;
});
var nstr = arr.join(' ');
return nstr;
}

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

greg
@wearenotgroot
Feb 08 2016 08:12 UTC
@rahulkavi why did you hardcode the values?
Kai Schoos
@kschoos
Feb 08 2016 08:12 UTC
thanks for your help, gotta think that through :) @Masd925
CamperBot
@camperbot
Feb 08 2016 08:12 UTC
skusku sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 939 | @masd925 | http://www.freecodecamp.com/masd925
osheenn
@osheenn
Feb 08 2016 08:12 UTC
whats wrong with this one?
greg
@wearenotgroot
Feb 08 2016 08:12 UTC
@rahulkavi you were supposed to use the function parameters
osheenn
@osheenn
Feb 08 2016 08:12 UTC
@masd925 @wearenotgroot
budimanfix
@budimanfix
Feb 08 2016 08:13 UTC

Hello guys!! What actually i miss with my code? i couldn't run test : function myTest(val) {
var answer = "";
// Only change code below this line

switch(val){
case 1:
answer = "Marley";
break;

case 42: 
  answer = "The Answer";
  break;

case 1:
answer = "There is no #1";
break;

case 99: 
answer = "Missed me by this much!";
  break;

case 7:
answer = "Ate Nine";
  break;

}

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

greg
@wearenotgroot
Feb 08 2016 08:13 UTC
@osheenn where is the uppercase?
budimanfix
@budimanfix
Feb 08 2016 08:14 UTC

switch(val){
case 1:
answer = "Marley";
break;

case 42: 
  answer = "The Answer";
  break;

case 1:
answer = "There is no #1";
break;

case 99: 
answer = "Missed me by this much!";
  break;

case 7:
answer = "Ate Nine";
  break;

}

greg
@wearenotgroot
Feb 08 2016 08:14 UTC
@osheenn tip! write a psuedo code first then write the code
@osheenn that way you can check if you fullfilled the requirements
@osheenn it also helps visualise the problem
osheenn
@osheenn
Feb 08 2016 08:16 UTC
i cant figure out whats wrong in it? things seem in place this time
@wearenotgroot

function titleCase(str) {
str= str.toLowerCase();
var arr = str.split(' ');
var ans = arr.map(function(val){
var temp = val.split('');
temp[0]=temp[0]-32;
val = temp.join('');
return val;
});
var nstr = arr.join(' ');
return nstr;
}

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

@wearenotgroot i subtracted ascii value 32 from temp[0] so it will become uppercase
greg
@wearenotgroot
Feb 08 2016 08:21 UTC
@osheenn why not use toUpperCase
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 08:27 UTC
hello
greg
@wearenotgroot
Feb 08 2016 08:27 UTC
@osheenn also slow down a bit
@osheenn here is your problem, you forgot to use ans
@osheenn you've used arr instead of ans
@osheenn `
function titleCase(str) {
str= str.toLowerCase();
var arr = str.split(' ');
var temp = '';
var ans = arr.map(function(val){
temp = val.split('');
console.log(temp);
console.log(temp[0]);
temp[0] = temp[0].toUpperCase(); ///<------------use to uppercase much easier
console.log(temp);
val = temp.join('');
return val;
});
var nstr = ans.join(' ');
return nstr;
}
titleCase("I'm a little tea pot");
budimanfix
@budimanfix
Feb 08 2016 08:35 UTC
@cannelflow would you correct this challenge bro? freecodecamp.com/challenges/replacing-if-else-chains-with-switch
greg
@wearenotgroot
Feb 08 2016 08:36 UTC
@budimanfix check the <-----------example
@budimanfix it said to use switch instead of if statements
budimanfix
@budimanfix
Feb 08 2016 08:37 UTC

I did this : switch (val) {
case 1:
answer = "Marley";
break;

case 42: 
  answer = "The Answer";
  break;

case 1:
answer = "There is no #1";
break;

case 99: 
answer = "Missed me by this much!";
  break;

case 7:
answer = "Ate Nine";
  break;

case 8:
  answer = "";
break;
case 156:
  answer = "";
@wearenotgroot left to task : myTest("bob") should be "Marley"
greg
@wearenotgroot
Feb 08 2016 08:38 UTC
@budimanfix case 1 should be 'bob'<------------ case 'bob'
budimanfix
@budimanfix
Feb 08 2016 08:40 UTC
@wearenotgroot and this one : myTest(1) should be "There is no #1"
greg
@wearenotgroot
Feb 08 2016 08:40 UTC
@budimanfix you had conflicting switch statement
@budimanfix right now you have two case 1
@budimanfix the first one should be case 'bob'
budimanfix
@budimanfix
Feb 08 2016 08:41 UTC
'bob couldn't work @wearenotgroot
greg
@wearenotgroot
Feb 08 2016 08:42 UTC
@budimanfix
case 1: //<-----------------------------should be bob the switch statement will always look for the first thing it will find then with break it will exit
answer = "Marley";
break;
case 42: 
  answer = "The Answer";
  break;
case 1:
answer = "There is no #1";
break;
case 99: 
answer = "Missed me by this much!";
  break;

case 7:
answer = "Ate Nine";
  break;

case 8:
  answer = "";
break;
case 156:
  answer = "";
budimanfix
@budimanfix
Feb 08 2016 08:43 UTC
@wearenotgroot switch (val) {
case bob:
answer = "Marley";
break;
greg
@wearenotgroot
Feb 08 2016 08:43 UTC
@budimanfix bob inside ""
@budimanfix should be a string
budimanfix
@budimanfix
Feb 08 2016 08:44 UTC
Thank you.. Worked!! :+1:
greg
@wearenotgroot
Feb 08 2016 08:45 UTC
@budimanfix YW
budimanfix
@budimanfix
Feb 08 2016 08:45 UTC
@wearenotgroot Thanks worked!! :+1:
CamperBot
@camperbot
Feb 08 2016 08:45 UTC
budimanfix sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 683 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Vinícius
@vinicius978
Feb 08 2016 08:47 UTC
I'm having problem with the Stand in Line problem

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

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

function queue(arr, item) {
  // Your code here
  var arr = [5,4,3,2,1];


  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 08:48 UTC
hello need help regarding Title case a sentence challenge
greg
@wearenotgroot
Feb 08 2016 08:49 UTC
@CrazyboOoy123 what you got so far?
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 08:49 UTC
function titleCase(str) {

  // 1. str > lower case
  // 2. array > str.split by space to array
  // 3. uppercase first letter 
  // 4. join array
  var array;
  var upperCase;
  var sentence;

    str = str.toLowerCase();//  lowercase;
    array = str.split(' ');//split string to arrays by space;

  for (var i = 0 ; i < array.length; i++){
         upperCase = array[i].charAt(0);

        } 

    sentence = upperCase.join(" ");
}

titleCase("I'm a little tea pot");
Darla Sudheer
@sudheerdarla
Feb 08 2016 08:49 UTC
function largestOfFour(arr) {
  // You can do this!
  var largestArray = [];

  largestArray.push("hello");

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



      }
    }

  return largestArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
greg
@wearenotgroot
Feb 08 2016 08:50 UTC
@vinicius978 here check for array method you can use------>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array read about push and shift
Darla Sudheer
@sudheerdarla
Feb 08 2016 08:50 UTC
dont know where to go from here..Return Largest Numbers in Arrays
function largestOfFour(arr) {
  // You can do this!
  var largestArray = [];

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



      }
    }

  return largestArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
greg
@wearenotgroot
Feb 08 2016 08:51 UTC
@CrazyboOoy123 where is the rest of the string?
@CrazyboOoy123 chartAt only get the character at index 0
@CrazyboOoy123 also you were supposed to put it to uppercase
@CrazyboOoy123 hint! use slice
@CrazyboOoy123 then make a new string with the chartAt and the slice part of the string
@sudheerdarla hint! you can use sort() to sort each array individually
CrazyboOoy123
@CrazyboOoy123
Feb 08 2016 08:54 UTC
@wearenotgroot okay will try that
greg
@wearenotgroot
Feb 08 2016 08:54 UTC
@sudheerdarla the largest can be found either at the index 0 or at the last index. you can also feed the sort() function with custom function
Abhishek Kumar
@abhishekKumar1
Feb 08 2016 08:56 UTC
@sudheerdarla try thinking of one array at a time and then sort it to find the maximum and then push it to the largestArray. FYI don't use i in the second loop because you have used it in first loop.
Vinícius
@vinicius978
Feb 08 2016 08:58 UTC
thanks @wearenotgroot
CamperBot
@camperbot
Feb 08 2016 08:58 UTC
vinicius978 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 684 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Nikolay
@luisciphere
Feb 08 2016 09:00 UTC
hello guys
can anybody give me a hint
Jeremy Parmenter
@JeremyJaydan
Feb 08 2016 09:00 UTC
@luisciphere Heyo!
Nikolay
@luisciphere
Feb 08 2016 09:00 UTC
function destroyer(arr) {
  // Remove all the values

  return arr.filter(function(val) {
    for (var i = 1; i < arr.length; i++) {
      return val == i;
    }

  });
}
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
why it filters out 5 with 2 and 3
Jeremy Parmenter
@JeremyJaydan
Feb 08 2016 09:01 UTC
What is your expected outcome?
greg
@wearenotgroot
Feb 08 2016 09:02 UTC
Nikolay
@luisciphere
Feb 08 2016 09:04 UTC
@JayParmz oh, im kinda sleepy right now, and after your message i see how rediciolus my code is)
Jeremy Parmenter
@JeremyJaydan
Feb 08 2016 09:05 UTC
@luisciphere Aha, alrighty.
lou
@louise-r-blue
Feb 08 2016 09:08 UTC
var code ="formatted";
sendruck
@sendruck
Feb 08 2016 09:11 UTC
Hi guys, do you have any problems with escaped characters challenge?
greg
@wearenotgroot
Feb 08 2016 09:12 UTC
@sendruck do you?
Vivek
@vivek28111992
Feb 08 2016 09:12 UTC
@wearenotgroot hi, how are you?
sendruck
@sendruck
Feb 08 2016 09:12 UTC
Yes, it works in some cases
greg
@wearenotgroot
Feb 08 2016 09:13 UTC
@vivek28111992 fine i guess :smile: , and how are you?
sendruck
@sendruck
Feb 08 2016 09:13 UTC
and didnt want wark at common
151 challenge
Vivek
@vivek28111992
Feb 08 2016 09:13 UTC
@wearenotgroot fine :smile:
@wearenotgroot how's your work on 3D modelling going on?
greg
@wearenotgroot
Feb 08 2016 09:15 UTC
@sendruck post you code and we'll have a look at it
@vivek28111992 going fine i guess. suppose to be working on it right now actually :smile: dont tell anyone
sendruck
@sendruck
Feb 08 2016 09:16 UTC
var myStr = " \ \t \t \r \n ";
greg
@wearenotgroot
Feb 08 2016 09:16 UTC
@sendruck you need to escape the escape \
sendruck
@sendruck
Feb 08 2016 09:17 UTC
var myStr = " \ \t \t \r \n ";
massenger avoid it
var myStr = " \\ \t \t \r \n ";
like that?
greg
@wearenotgroot
Feb 08 2016 09:18 UTC
@sendruck two \ in front
@sendruck the rest should be fine
@sendruck refresh the page if it doesnt work
sendruck
@sendruck
Feb 08 2016 09:20 UTC
no, there is output var myStr = " \t \t \n ";
i delete backspace here
greg
@wearenotgroot
Feb 08 2016 09:20 UTC
@sendruck did you put space between them
sendruck
@sendruck
Feb 08 2016 09:21 UTC
yeah
greg
@wearenotgroot
Feb 08 2016 09:21 UTC
@sendruck it should work
sendruck
@sendruck
Feb 08 2016 09:21 UTC
ok i try it again
greg
@wearenotgroot
Feb 08 2016 09:21 UTC
@sendruck try and reset the challenge
sendruck
@sendruck
Feb 08 2016 09:22 UTC
thanks
greg
@wearenotgroot
Feb 08 2016 09:22 UTC
@sendruck YW