These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Jan 2017
Jameel Matin
@cutiepatootiebear
Jan 09 2017 00:01
Add the greater than operator to the indicated lines so that the return statements make sense.

```function testGreaterThan(val) {
if (val > 200) { // Change this line
return "Over 100";
}

if (val > 20) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(300);
```

Pieter Stokkink
@forkerino
Jan 09 2017 00:01
@HeebieGeeBee hover can only be used like this: $('.online').hover(function....
Moisés Man
@moigithub
Jan 09 2017 00:01
backticks on its OWN line @yassbetch
shift enter to add new line
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:02
yeah
with two functions
Pieter Stokkink
@forkerino
Jan 09 2017 00:02
yes
Moisés Man
@moigithub
Jan 09 2017 00:02
@yassbetch over 100.. probably should be > 100 ?
Pieter Stokkink
@forkerino
Jan 09 2017 00:03
@HeebieGeeBee Next challenge: make sure only the details of the selected item are turned on/off. :P
Not all of them.
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:03
$('.online').hover(function() {
              $('.details').show(500);
            }, function() {
               $('.details').hide(500);
            }
            );
this works but it does it to all the online elements
Jameel Matin
@cutiepatootiebear
Jan 09 2017 00:04
function testGreaterThan(val) {
  if (val > 200) {  // Change this line
    return "Over 100";
  }

  if (val > 20) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(300);
got it @moigithub Thanks!
CamperBot
@camperbot
Jan 09 2017 00:06
yassbetch sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2448 | @moigithub |http://www.freecodecamp.com/moigithub
Olly
@obolland
Jan 09 2017 00:06
function testGreaterThan(val) {
  if (val > 100) {  // Change this line
    return "Over 100";
  }

  if (val > 10) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(300);
@yassbetch ^
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:09
ok that was solved relatively easy thanks to a bit of 'this' @forkerino
CamperBot
@camperbot
Jan 09 2017 00:09
heebiegeebee sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: heebiegeebee already gave forkerino points
Pieter Stokkink
@forkerino
Jan 09 2017 00:09
yes!
:+1:
I'm turning in. Night night!
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:12
cya sleep well
foxdog
@foxdog
Jan 09 2017 00:17
what up people
Ok im stuck big time on "Profile Lookup"
Ogundele Olumide
@Lumexralph
Jan 09 2017 00:18
@foxdog where?
foxdog
@foxdog
Jan 09 2017 00:19
hang on I did something strange with this help box
Stephen James
@sjames1958gm
Jan 09 2017 00:19
@seanparkin you are looping over arr and then using it as an index for arr[1] -
Doesn't really make sense? maybe arr[1].length ?
foxdog
@foxdog
Jan 09 2017 00:20
alright, Im not really getting what to do on this one
I mostly understand what it wants
Ogundele Olumide
@Lumexralph
Jan 09 2017 00:20
@foxdog what're you trying to implement?
Frank XC
@tenkdayz
Jan 09 2017 00:21
Does anyone want to collaborate on a sudoku puzzle solver? maybe someone who's still learning?
foxdog
@foxdog
Jan 09 2017 00:21
but I dont get how to go about comparing the values passed in with several blocks
Ogundele Olumide
@Lumexralph
Jan 09 2017 00:22
@foxdog don't understand
mitron6
@mitron6
Jan 09 2017 00:22
@foxdog Does this link help? Don't read past the spoiler warning unless you want to see the answers. https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Challenge-Profile-Lookup
foxdog
@foxdog
Jan 09 2017 00:23
That does look like it'll be helpful
thanks @mitron6 i'll come back if I cant figure it out
CamperBot
@camperbot
Jan 09 2017 00:24
foxdog sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 439 | @mitron6 |http://www.freecodecamp.com/mitron6
Stephen James
@sjames1958gm
Jan 09 2017 00:25
@foxdog So contacts is an array and you are supposed to search for a matching first name -
Sounds like some sort of loop
foxdog
@foxdog
Jan 09 2017 00:26
yeah
with several blocks
Hasan
@MHAhmed
Jan 09 2017 00:32
hey guys i need some help please
Ty
@Medic1
Jan 09 2017 00:33

I'm stuck. Plz help.
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]]);

Hasan
@MHAhmed
Jan 09 2017 00:34
var StrSplit = [];
var strLength = 0;
var strNumber = 0;
var strArray = [];

function findLongestWord(str) {
  strSplit = str.split(' ');
  strLength = strSplit.length;

  for (var i = 0; i <= strLength.length; i++) {
     strNumber = strSplit[i].length;
     strArray = strNumber.push;
     strArray.sort(function(a, b){
       return b - a;
     });
  }
 return strArray[0];

}

findLongestWord("The quick brown fox jumped over the lazy dog");
can someone please tell me whats wrong with my script? it keeps returning my strArray[0]; as [] is it because i used a global space variable ?
babajide odusola
@cesarecaravaggio
Jan 09 2017 00:34
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    "alpha": "Adams",

    "bravo": "Boston",

    "charlie": "Chicago",

    "delta": "Denver",

   "echo": "Easy",

    "foxtrot": "Frank"
  };

  // Only change code above this line
  return result;
}
i'm doing the object lookup. Can someone point me in theright direction pls lol
Ty
@Medic1
Jan 09 2017 00:35
@cesarecaravaggio
First, you have to take off the quotes on alpha, bravo, etc.
babajide odusola
@cesarecaravaggio
Jan 09 2017 00:37
@Medic1 just did.
Tony Miri
@TonyMiri
Jan 09 2017 00:38
Hey everyone, I just came back from a little break from coding and I noticed my twitch.tv app isn't working anymore. I don't think it has to do with the client id requirements that happened in August. I'm getting a strange error in the console that says there is an unexpected '<' , but I can't find it. I have a lot of stuff that adds dynamically so I think it might be part of the problem, but I can't seem to narrow it down. Anybody feel like debugging my code for me? :smile:
babajide odusola
@cesarecaravaggio
Jan 09 2017 00:38
@Medic1 in the previous exercies though , the object properties would have "" around it as well though.
Stephen James
@sjames1958gm
Jan 09 2017 00:39
@MHAhmed YOu cannot use global variables and pass the FCC tests - they don't get reset
Ty
@Medic1
Jan 09 2017 00:39
@cesarecaravaggio
Use it to lookup val and assign the associated string to the result variable.
Stephen James
@sjames1958gm
Jan 09 2017 00:39
@cesarecaravaggio The quotes are fine you need to set result variable to the value of the property in val from the object lookup
Manish Giri
@Manish-Giri
Jan 09 2017 00:40
@FatTone225 link your pen
Ty
@Medic1
Jan 09 2017 00:40
@sjames1958gm any help on my 18:33?
Hasan
@MHAhmed
Jan 09 2017 00:41
@sjames1958gm ahh okay thanks
babajide odusola
@cesarecaravaggio
Jan 09 2017 00:41
@sjames1958gm working on it now.
CamperBot
@camperbot
Jan 09 2017 00:41
mhahmed sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5231 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
babajide odusola
@cesarecaravaggio
Jan 09 2017 00:42
@sjames1958gm should i return lookup then?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:48
damn @FatTone225 i was gonna try and do a streamer search for my twitch app too
did you get it to work?
Hasan
@MHAhmed
Jan 09 2017 00:48
can someone please tell me whats wrong with my code?
function findLongestWord(str) {
  var strSplit = str.split(' ');
  var strLength = strSplit.length;
  var strArray = [];

  for (var i = 0; i <= strLength.length; i++) {
     var strNumber = strSplit[i].length;
      strArray.push([strNumber]);
  }

  strArray.sort(function(a, b){
       return b - a;
  });

  return strArray[0];

}

findLongestWord("The quick brown fox jumped over the lazy dog");
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:49
i couldnt get thetwtich api search query to work with the fcc work around api
Tony Miri
@TonyMiri
Jan 09 2017 00:49
@HeebieGeeBee Not yet. I mean, it was working perfectly when I left it, but I came back and now it doesn't work anymore.
Moisés Man
@moigithub
Jan 09 2017 00:49
@MHAhmed strLength is a number.,... var strLength = strSplit.length;
numbers do not have length property
for (var i = 0; i <= strLength.length; i++) { <--- wrong
Hasan
@MHAhmed
Jan 09 2017 00:49
ahh thats why my for loop was not working
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:50
@thats not the link i have for the twitch api work around @FatTone225
Hasan
@MHAhmed
Jan 09 2017 00:50
@moigithub thanks
CamperBot
@camperbot
Jan 09 2017 00:50
:star2: 2449 | @moigithub |http://www.freecodecamp.com/moigithub
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:50
is that something you found yourself?
CamperBot
@camperbot
Jan 09 2017 00:50
mhahmed sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Tony Miri
@TonyMiri
Jan 09 2017 00:51
the wind-bow link?
@HeebieGeeBee
Moisés Man
@moigithub
Jan 09 2017 00:51
@MHAhmed also arrays are 0 based index.. if u do <= u last element will be unexistant...
and u pushing an array inside another array strArray.push([strNumber]);
soo ur strArray will end up like this [[1],[2],[3]]
remove the bracket on push
Tony Miri
@TonyMiri
Jan 09 2017 00:51
I think that's the one that was provided
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:51
yeah
Tony Miri
@TonyMiri
Jan 09 2017 00:52
Maybe it changed again
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:52
still need to do some styling and few bugs
and i had to scrap the idea of the channel search cus i just couldnt get that window bow api to work with the twitch search query
Tony Miri
@TonyMiri
Jan 09 2017 00:54
@HeebieGeeBee That was it. They changed the link again
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:54
just kept saying access denied
Tony Miri
@TonyMiri
Jan 09 2017 00:54
@HeebieGeeBee except now my 404's aren't displaying properly
FlawlessXD
@FlawlessXD
Jan 09 2017 00:55
Need some help on escape sequences in strings challenge, this is my code, var myStr="Firstline\n\SecondLine\\rThirdline";
Tony Miri
@TonyMiri
Jan 09 2017 00:55
@HeebieGeeBee It's working for me, though the layout is a little effed up lol
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:56
yeah that twitch logo and buttons i need to sort out
Yi
@ycoding007
Jan 09 2017 00:56

Hello all, I have a question about filter and indexOf

var arr1 = [2,6];
  function someValue(value) {
        return arr1.indexOf(value)!==-1;
  }

var arr2 = [1,2,3,4,5,6];

arr2.filter(someValue);

if i run above code, i got result [2,6], but why not [1,3,5], the "return" code will give me "True", so in the last line of filtering code, the filter should filter out 2,4...... I am confused, please help, thank you

HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:56
not sure where to put it yet
Tony Miri
@TonyMiri
Jan 09 2017 00:56
I see. I like it though.
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:56
can change all your 404 and stuff to undefined
Sander Berntsen
@sbxn14
Jan 09 2017 00:57
can someone help me with the word blanks challenge?
Tony Miri
@TonyMiri
Jan 09 2017 00:57
@HeebieGeeBee Thanks for the info. Yeah mine are showing undefined now. I'll have to tinker with it
CamperBot
@camperbot
Jan 09 2017 00:57
fattone225 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 483 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Sander Berntsen
@sbxn14
Jan 09 2017 00:57
im totally lost on what to do
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:57
you's looking good too
btw
Tony Miri
@TonyMiri
Jan 09 2017 00:57
ty, ty
FlawlessXD
@FlawlessXD
Jan 09 2017 00:58
Could really use some help on the code, var myStr="Firstline\n\SecondLine\\rThirdline"; for escape sequences in string. The error says that mystr should have encoded text with proper escape sequences and no spacing
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 00:58
@sbxn14 make sure you include the spaces
Sander Berntsen
@sbxn14
Jan 09 2017 00:59
I just figured it out the moment you said that :D
Tony Miri
@TonyMiri
Jan 09 2017 00:59
I wonder if they pruned nonactive accounts
llamatarianism
@llamatarianism
Jan 09 2017 00:59
@ycoding007 arr1.indexOf(value) !== -1 this returns true if value is inside arr1
not if it isn't inside arr1
if you want it to return [1, 3, 4, 5], then change the !== to ===
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:00
@FlawlessXD put your code between backticks
Sander Berntsen
@sbxn14
Jan 09 2017 01:01
hehe this looks so dumb but hey if it works...
Mohamed Osama Khan
@Assaonator
Jan 09 2017 01:01
var lookup = {
  "alpha": "Adams",
  "bravo": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank"
};
what I have done wrong
Sander Berntsen
@sbxn14
Jan 09 2017 01:01
 result = "There was this " + myAdjective + " " + myNoun + " that for some reason " + myVerb + " " + myAdverb;
if it aint broke dont fix it
FlawlessXD
@FlawlessXD
Jan 09 2017 01:02
@HeebieGeeBee The entire code? This didn't work, var myStr="\Firstline\n\SecondLine\\rThirdline\";
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:05
just cant tell how many backslashes you have in the chat cus it sometimes deletes them without putting it in backticks
Yi
@ycoding007
Jan 09 2017 01:06
@llamatarianism Thank you but could you explain more about the indexOf, I am looking at the Mozilla developer site but still dont fully understand. so arr1.indexOf(value) !== -1 will return true because all values are present in arr1; now in the filtering, the filter should eliminate those true values....my thought is still in opposite side.. how to correctly understand what the filter does.?
CamperBot
@camperbot
Jan 09 2017 01:06
ycoding007 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1464 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Bryan Reese
@breese8009
Jan 09 2017 01:06
@HeebieGeeBee hey how long have u been coding in javascript?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:06
about a month
CamperBot
@camperbot
Jan 09 2017 01:06
you need to ask about @someone!
Bryan Reese
@breese8009
Jan 09 2017 01:07
@HeebieGeeBee learned everything on here or did u go to other sites as well
??
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:07
well ive read a lot
FlawlessXD
@FlawlessXD
Jan 09 2017 01:07
@HeebieGeeBee Well, the only error that pops up, is "myStr should have encoded text with the proper escape sequences and no spacing", And, I have the escape sequences required for the other criteria (with no spacing)
Bryan Reese
@breese8009
Jan 09 2017 01:08
@HeebieGeeBee nice man, ur very good at it., especially for only a month at it.
llamatarianism
@llamatarianism
Jan 09 2017 01:09
@ycoding007 this is what filter does:
function filter(array, func) {
  var newArray = [];
  for (var i = 0; i < array.length; i++) {
    if (func(array[i])) {
      newArray.push(array[i]);
    }
  }
  return newArray;
}
Array.prototype.indexOf returns -1 if the item isn't inside the array
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:09
@breese8009 ty but still just a noob really
CamperBot
@camperbot
Jan 09 2017 01:09
heebiegeebee sends brownie points to @breese8009 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for breese8009
llamatarianism
@llamatarianism
Jan 09 2017 01:09
otherwise, it returns its index
Tony Miri
@TonyMiri
Jan 09 2017 01:09
@HeebieGeeBee Fixed it now. They changed which api call got the "status: 404" in the API responsetext. Why can't they just make things simple and leave it alone :laughing:
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:09
@FlawlessXD var myStr = "FirstLine\n\\SecondLine\\\rThirdLine"; this is the solution
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:10
@FatTone225 twitch never leave anything alone
FlawlessXD
@FlawlessXD
Jan 09 2017 01:10
Omg, my L on the thirdline wasn't capitalized....
Welp, thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 09 2017 01:11
flawlessxd sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 484 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Sander Berntsen
@sbxn14
Jan 09 2017 01:11
``

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];
how do I make it so it recognizeds the 8
recognizes*
or better said is equal to it
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:12
@jerryslone myVar++ is the same as saying myVar = myVar + 1
you need to access the 8 @sbxn14
Sander Berntsen
@sbxn14
Jan 09 2017 01:12
@HeebieGeeBee yea and how do I do that. i dont get it
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:12
what is myArray[0] in that array
Sander Berntsen
@sbxn14
Jan 09 2017 01:13
uh 1
and 4?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:13
no
its the first element of the array
which just so happens to be an array
Sander Berntsen
@sbxn14
Jan 09 2017 01:13
O wait
so i gotta put 2 there?
so it picks the 3rd one?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:13
so myArray[0] is the [1, 2, 3]
now how would you access the number two in this array
Sander Berntsen
@sbxn14
Jan 09 2017 01:14
by typing in 1
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:14
no
Sander Berntsen
@sbxn14
Jan 09 2017 01:14
but isnt the 1 0a nd the 2 1?
wut
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:15
by calling myArray[0] your accessing the first element of the array
which happens to be another array or a sub array
so how you would access the first element of the sub array found at myArray[0]
Sander Berntsen
@sbxn14
Jan 09 2017 01:16
myArray[1][0]?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:16
almost
why did you put 1?
Sander Berntsen
@sbxn14
Jan 09 2017 01:16
cause the 0 is the first part aka everything if im thinking right. so 1 is the first array
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:17
no 0 is the first array or element
Sander Berntsen
@sbxn14
Jan 09 2017 01:17
oh okay now I get it
I kept thinking you ment it was the entire thing
Yi
@ycoding007
Jan 09 2017 01:17
@llamatarianism thank you, now I understand, what the filter does is it looks into the argument, it will return the results that satisfy the condition in the filter argument....initially i interpreted it using the English language, filter (something), that something must be filtered out.....-_-
CamperBot
@camperbot
Jan 09 2017 01:17
ycoding007 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: ycoding007 already gave llamatarianism points
Sander Berntsen
@sbxn14
Jan 09 2017 01:17
so I just go for myArray[0][0]
which would be 1
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:17
yes
Sander Berntsen
@sbxn14
Jan 09 2017 01:17
and so 8 would be
myArray[2][1]
Jameel Matin
@cutiepatootiebear
Jan 09 2017 01:18
Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside".
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 10 || val < 20) {
    return "Outside";
  }


  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(12);
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:18
sounds good to me
Sander Berntsen
@sbxn14
Jan 09 2017 01:18
alright I get it now
thanks! @HeebieGeeBee
CamperBot
@camperbot
Jan 09 2017 01:18
sbxn14 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 485 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Sander Berntsen
@sbxn14
Jan 09 2017 01:18
going to do one more challenge and then off to bed!
see ya guys
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:19
good luck
@yassbetch what do you think they mean by 'inclusive'
its not 'or' is it, its 'and' isnt it?
Jameel Matin
@cutiepatootiebear
Jan 09 2017 01:20
@HeebieGeeBee included
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:20
also your thinking is a little mixed up
Mohamed Osama Khan
@Assaonator
Jan 09 2017 01:20
{ 
"artist": "Pharrell",
"title": "Happy",
"release_year": 2015,
"formats": [
"mp3",
"cd"
"tape"
]
}
];
please kindly tell me what I'm doing wrong
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:20
you dont want it to be greater than 10 and less than 20 to be outside
its the other way round isnt
it
Jameel Matin
@cutiepatootiebear
Jan 09 2017 01:21
@HeebieGeeBee you're right!
thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 09 2017 01:21
yassbetch sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 486 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Mohamed Osama Khan
@Assaonator
Jan 09 2017 01:22
?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:23
@Assaonator you need to elaborate thats just an object
and it looks fine
well actuall
is that all your code?
Danilo Geronimo
@danilogeronimo
Jan 09 2017 01:24
@Assaonator you missed a comma after "cd"
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:24
the last ] shouldnt be there
but i dunno if theres nore code
oh yeah thats a problem like @danilogeronimo said
Mohamed Osama Khan
@Assaonator
Jan 09 2017 01:25
@danilogeronimo @HeebieGeeBee thanks
CamperBot
@camperbot
Jan 09 2017 01:25
assaonator sends brownie points to @danilogeronimo and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 487 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 287 | @danilogeronimo |http://www.freecodecamp.com/danilogeronimo
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:25
i dont remember doing that exercise at all
was it just to write an object?
Tony
@FreakishLancer
Jan 09 2017 01:25
Hello, I'd like to ask a simple question: how do you check if a string corresponds to any valid properties of an object?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:26
could say object.hasOwnProperty('string')
if thats what you mean
Aidan M
@AIDXNZ
Jan 09 2017 01:27
var myStr= "This is the first sentence.";
myStr += "This the sencond sentence.";
what did i do wrong?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:28
second*
Aidan M
@AIDXNZ
Jan 09 2017 01:28
thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 09 2017 01:28
aidxnz sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 488 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Tony
@FreakishLancer
Jan 09 2017 01:28
Hmm, well that is different. That is checking whether a value corresponds to a value of an existing property. @HeebieGeeBee
Aidan M
@AIDXNZ
Jan 09 2017 01:28
lol
Tony
@FreakishLancer
Jan 09 2017 01:28
At least, that is what I think it does.
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:28
so whats the different?
Tony
@FreakishLancer
Jan 09 2017 01:29

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

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

I get the first question right.
wwbrrt
@wwbrrt
Jan 09 2017 01:29
HELP Make Object Properties Private in FreeCodeCamp. I'm stuck and I'm running out of hair!
CamperBot
@camperbot
Jan 09 2017 01:29
no wiki entry for: make object properties private in freecodecamp im stuck and im running out of hair
Tony
@FreakishLancer
Jan 09 2017 01:29
But not the second.
Manish Giri
@Manish-Giri
Jan 09 2017 01:30
@wwbrrt what's the problem
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:30
if (contacts[i[.hasOwnProperty(prop) === false) {
return "No such property">
?
Tony
@FreakishLancer
Jan 09 2017 01:30
Hmm. That makes sense.
I will try that and see.
wwbrrt
@wwbrrt
Jan 09 2017 01:31
I can get most of it but I can't figure out why 'should return 3' and 'should return 1' are not doing that.
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:32
@wwbrrt put your code up
RomingArt
@RomingArt
Jan 09 2017 01:32
Hello everyone I am having an issue with Global Scope and Functions can someone please help me out?
wwbrrt
@wwbrrt
Jan 09 2017 01:33
this is my first time to this forum so please be patient with me. heres my code

var gear = 0;

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

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

};

var myBike = new Bike();

var myCar = new Car();

HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:33
looks like youre both on the same challenge
wwbrrt
@wwbrrt
Jan 09 2017 01:33
lol! Its a tough one
I have been learning coding for about two weeks and I am starting to question my sanity
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:34
that will happen
Aysenur Erdem
@aysenurerdem
Jan 09 2017 01:35

var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort();

HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:35
dont think you want to += change @wwbrrt
Aysenur Erdem
@aysenurerdem
Jan 09 2017 01:35

question is Use sort to sort array from largest to smallest.

can you help me i have no idea

wwbrrt
@wwbrrt
Jan 09 2017 01:35
what do you recommend?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:35
just =
Tony
@FreakishLancer
Jan 09 2017 01:35
Sometimes, I hate that the prompts force you to make a solution using the strategy that it wants. >,<
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:36
@aysenurerdem you need to read up about sort() method works
llamatarianism
@llamatarianism
Jan 09 2017 01:36
you can do the challenges however you want as long as it actually works
Tyrone Cartwright
@boss1son
Jan 09 2017 01:36
Im trying to space this string using the special characters but I'm not getting the newLine
var myStr = '"FirstLine"\n\"SeconLine\"\n"ThirdLine"\r'; // Change this line
llamatarianism
@llamatarianism
Jan 09 2017 01:36
@aysenurerdem Array.prototype.sort doesn't work that way
wwbrrt
@wwbrrt
Jan 09 2017 01:37
That did it! thanks a ton @HeebieGeeBee
CamperBot
@camperbot
Jan 09 2017 01:37
:cookie: 489 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
wwbrrt sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Jan 09 2017 01:37
if you don't pass a function in, it sorts the array in lexicographical order
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 01:37
np
llamatarianism
@llamatarianism
Jan 09 2017 01:37
so it turns [1, 12, 21, 2] into [1, 12, 2, 21]
you have to pass a function in, for example:
[1, 12, 21, 2].sort(function(a, b) {
  return b - a;
});
// [21, 12, 2, 1]
Aysenur Erdem
@aysenurerdem
Jan 09 2017 01:38
@llamatarianism okay thanks
CamperBot
@camperbot
Jan 09 2017 01:38
aysenurerdem sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1465 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Mohamed Osama Khan
@Assaonator
Jan 09 2017 01:40
// Only change code below this line

var secondTree = "pine"; // Change this line
I'm having difficulties with Use dot and bracket notation to access myPlants
Chris Wingler
@chriswingler
Jan 09 2017 01:43
@Assaonator myPlants.secondTree = 'pine' ?
Daniel
@doodleslr
Jan 09 2017 01:44

searching for numbers and white spaces in expressions required a + in the expression to continue the search instead of terminating at the first result
var expression = /\s+/g;
var expression = /\d+/g;

But when inverting to search characters with the uppercase S, why doesnt it use + to continue along the line instead of terminating at the first character?
var expression = /\S/g;

Joseph
@revisualize
Jan 09 2017 01:50
@Assaonator What is the object for that challenge?
@Assaonator Actually, let's do it this way.
@Assaonator Let's say we have an array:
var contacts = [ "A" , "H" , "S" , "K" ];
How do you access "H"?
llamatarianism
@llamatarianism
Jan 09 2017 01:51
@doodleslr the + isn't necessary in either case
because it has the g flag
Joseph
@revisualize
Jan 09 2017 01:51
@Assaonator I want to make sure you know how to access array elements by indexes.
Danilo Geronimo
@danilogeronimo
Jan 09 2017 01:53
@doodleslr this site help me a lot to learn regex http://regexr.com/ checkout
what am i doing wrong here
Joseph
@revisualize
Jan 09 2017 01:54
@boss1son You have far too many "s in your "solution".
Danilo Geronimo
@danilogeronimo
Jan 09 2017 01:54
@jerryslone +=
Jenky W. Nolasco
@jenkynolasco11
Jan 09 2017 01:54
var h = contacts.reduce(function (tt, el){ if (el == "H") return tt + el; return tt; }, "");
Joseph
@revisualize
Jan 09 2017 01:55
@jerryslone Frist off. You haven't declared myVar
@jerryslone Second, You are not following the instructions.
@jerryslone Your code shouldn't have myVar in it anywhere.
@jenkynolasco11 Is that your answer to my question?
Jenky W. Nolasco
@jenkynolasco11
Jan 09 2017 01:58
Lol Im just kidding
Joseph
@revisualize
Jan 09 2017 01:59
@jerryslone You should reset the challenge and try again.
davelee0403
@davelee0403
Jan 09 2017 02:12
I thought the solution was changing the H to J but it tells me
TypeError: Attempted to assign readonly property.
babajide odusola
@cesarecaravaggio
Jan 09 2017 02:16
what does this question mean?
whats it asking for?
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var checkObj=myObj[checkProp];
  return "checkProp";
}

// Test your code by modifying these values
checkObj("gift");
help. please.
Jerry Purvis
@MessiaHack
Jan 09 2017 02:22
var taxRate = 0.09;
var bankAcct = prompt("How much money is in your bank?");
var phones = prompt("How many phones would you like?");
var phoneAmt = 99.99;
var phoneAccAmt = 9.99;
var purchaseAmt = "";
function purchase(phones) {
    var a = phones * phoneAmt;
    var b = a * taxRate;
    purchaseAmt = a + b;
}

if(purchaseAmt <= bankAcct) {
    var purchaseAcc = prompt("Would you like to purchase an accessory?");
}else {
    alert("Sorry, but you cannot afford this purchase");
}
something is not working here. no matter what I put in as my bankAcct amount and my phones amount, it always returns with the true portion of the conditional. It's like the function I created is not changing the global "purchaseAmt" variable.
Mohamed Osama Khan
@Assaonator
Jan 09 2017 02:22
@revisualize yeah i tried that
uriznik
@uriznik
Jan 09 2017 02:28
@MessiaHack you've created the function but then you still need to call it at some point with purchase(100000); or whatever
Jerry Purvis
@MessiaHack
Jan 09 2017 02:29
okay? I don't understand. how do I call it?
@uriznik
James Eldridge
@jeldridgeTS
Jan 09 2017 02:29
purchase() will execute the function
Jerry Purvis
@MessiaHack
Jan 09 2017 02:31
okay? but how do I call that function automatically within the js itself?
James Eldridge
@jeldridgeTS
Jan 09 2017 02:31
You need to put a line somewhere with purchase()
So right now
Jerry Purvis
@MessiaHack
Jan 09 2017 02:32
would it be something like if(purchase() <= bankAcct) be legitimate?
James Eldridge
@jeldridgeTS
Jan 09 2017 02:32
You have defined the function, that is to say... you have laid out what this thing will do - but you have not actually executed it
I'd start by just testing it out - comment out the entire if statement, and just above it, put a new line w/ purchase(323)
the number shouldn't matter
Jerry Purvis
@MessiaHack
Jan 09 2017 02:36
right now, it returns NaN
Yintii
@Yintii
Jan 09 2017 02:37
I've ran into a challenge that doesn't seem to run at all... I even deleted all the code the just run something basic, console.log("hello world") , and that didn't even print. Is this broken? I already cleared my cache, disabled caching in my dev tools, and crtl f5'd the page a bunch
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  console.log(firstName + " " + prop);
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
I feel like that should at least print, "Akira likes" but it doesn't run at all
James Eldridge
@jeldridgeTS
Jan 09 2017 02:39
@MessiaHack So that's something, then - it means the function is executing, but it's returning not a number
Shantay
@shgradyy
Jan 09 2017 02:40
Ok, I need help with my golf code... Hello all!

function golfScore(par, strokes) {
// Only change code below this line
if (strokes = 1) {
return "Hole-in-one!";
}
else if (strokes <= par - 2) {
return "Eagle";
}
else if (strokes = par - 1) {
return "Birdie";
}
else if (strokes = par) {
return "Par";
}
else if (strokes = par + 1) {
return "Bogey";
}
else if (strokes = par + 2) {
return "Double Bogey";
}
else if (strokes >= par + 3) {
return "Go Home!";
}
// Only change code above this line
}

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

Richard Gottleber
@rgottleber
Jan 09 2017 02:41
Hi, is there a react specific help room or would this be an alright place for that?
Jerry Purvis
@MessiaHack
Jan 09 2017 02:41
@jeldridgeTS right, but why? is it one of my prompts causing that?
James Eldridge
@jeldridgeTS
Jan 09 2017 02:42
@rgottleber I dno, I don't see anything for react specifically
uriznik
@uriznik
Jan 09 2017 02:42
@shgradyy if (strokes = 1) <- that's setting strokes to 1 (and then evaluating 1) rather than comparing
James Eldridge
@jeldridgeTS
Jan 09 2017 02:42
^^
Shantay
@shgradyy
Jan 09 2017 02:42
ohh
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 02:43
isnt react written by facebook?
Shantay
@shgradyy
Jan 09 2017 02:43
funny thing, that's the only line that's testing correct
James Eldridge
@jeldridgeTS
Jan 09 2017 02:43
@MessiaHack Looks like the issue is in this line var a = phones * phoneAmt;
so
above the function
look at what the phones var is set to
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 02:43
@shgradyy well it would do wouldnt it
Richard Gottleber
@rgottleber
Jan 09 2017 02:43

well guess I’ll toss my issue out here then see if anything stands out to anyone..

the following code snippet gives me the error
undefined is not an object (evaluating ‘this.state.boardValue …

  constructor(props) {
    super(props);
    this.state = {
    clicks: 0,
    boardValues: [
      ['-','-','-'],
      ['-','-','-'],
      ['-','-','-']
    ]
    };
    console.log(this.props);
  }

  handleClick(boardIndex, rowIndex){
    var boardValues = this.state.boardValues;
    var newValue='X';
    if (this.state.clicks % 2 ===0){
      newValue = 'O';
    }
@HeebieGeeBee it is yes...
James Eldridge
@jeldridgeTS
Jan 09 2017 02:44
@MessiaHack You're trying to multiply a prompt var with a number
Shantay
@shgradyy
Jan 09 2017 02:45
so should i use strokes && 1
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 02:45
how about if strokes === 1
James Eldridge
@jeldridgeTS
Jan 09 2017 02:45
@shgradyy Looks like you'd want to do strokes == 1 or strokes === 1
uriznik
@uriznik
Jan 09 2017 02:45
@shgradyy that's a logical and, use ===
Shantay
@shgradyy
Jan 09 2017 02:45
hmmm
ahh ok
James Eldridge
@jeldridgeTS
Jan 09 2017 02:46
= sets - === compares
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 02:46
thers is a guy who used react a lot i think
but he doesnt seem to be about at the moment
Shantay
@shgradyy
Jan 09 2017 02:46
thanks @uriznik @jeldridgeTS @HeebieGeeBee
CamperBot
@camperbot
Jan 09 2017 02:46
:cookie: 10 | @jeldridgets |http://www.freecodecamp.com/jeldridgets
:cookie: 469 | @uriznik |http://www.freecodecamp.com/uriznik
shgradyy sends brownie points to @uriznik and @jeldridgets and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 490 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
James Eldridge
@jeldridgeTS
Jan 09 2017 02:47
np, goodluck!
Shantay
@shgradyy
Jan 09 2017 02:47
thanks
Mohamed Osama Khan
@Assaonator
Jan 09 2017 02:53
myPlants.secondTree = "pine"
someone please help me
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 02:55
myPlants[secondTree] maybe
Ken Haduch
@khaduch
Jan 09 2017 02:58
@rgottleber - I'm just going through React lessons - do you have more context, like a URL that you can provide?
babajide odusola
@cesarecaravaggio
Jan 09 2017 02:59
can someone help me with the testing objects for properties exercise?
Jerry Purvis
@MessiaHack
Jan 09 2017 02:59
@jeldridge. right. The prompt returns with a number though
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:03

Okay, uncle. I believe that the problem is in my first if statement, and I'm stuck


can anyone say what my problem might be and why? or give me a hint?

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

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

// Change these values to test your function
lookUpProfile("Bob", "number");
James Shore
@Jimbobmahooley
Jan 09 2017 03:03
Can someone please explain why hat and shirt don't need "" when reading an object property

\
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj.hat; // Change this line
var shirtValue = testObj.shirt; // Change this line
\

Ken Haduch
@khaduch
Jan 09 2017 03:04
@cesarecaravaggio - checkObj is the function name -you should not use it as a variable name. What you want to do is use .hasOwnProperty(checkProp) to check that object to see if the property exists. Then if it does, return the property's value, or return "Not Found". You do not want to return the string "checkProp" under any conditions.
Gunavardhan Darimidi
@gunavardhandarimidi
Jan 09 2017 03:05
@cesarecaravaggio var check =myObj.hasOwnProperty(checkProp);
return myObj[checkProp];
Ken Haduch
@khaduch
Jan 09 2017 03:07
@Jimbobmahooley - "hat" and "shirt" are actual object property names that meet the requirements for being able to use dot notation when accessing the object. You could always write them as testObj["hat"] and testObj["shirt"], which converts them to bracket notation. But they can be accessed with dot notation. You should look up the different conditions where you have to use bracket notation vs. where you can use dot notation. (Not sure if that helps, but basically if you have an alphabetic word as the property name, you can access it with dot notation.)
James Shore
@Jimbobmahooley
Jan 09 2017 03:08
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj.hat;      // Change this line
var shirtValue = testObj.shirt;    // Change this line
babajide odusola
@cesarecaravaggio
Jan 09 2017 03:08
@khaduch @gunavardhandarimidi ty guys. gonna go work on it now.
CamperBot
@camperbot
Jan 09 2017 03:08
cesarecaravaggio sends brownie points to @khaduch and @gunavardhandarimidi :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @gunavardhandarimidi |http://www.freecodecamp.com/gunavardhandarimidi
:star2: 2233 | @khaduch |http://www.freecodecamp.com/khaduch
Jameel Matin
@cutiepatootiebear
Jan 09 2017 03:10

Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"
par and strokes will always be numeric and positive.

function golfScore(par, strokes) {
  // Only change code below this line
  if (par === 1 && strokes === 1) {
    return "Hole-in-one!";
  } else if (par <= par-2 && strokes <= par -2) {
    return "Eagle";
  } else if (par === par-1 && strokes === par-1) {
    return "Birdie";
  } else if (par === par) {
    return "Par";
  } else if (par === par+1) {
    return "Bogey";
  }else if (par === par+2) {
    return "Double Bogey";
  }else if (par >= par +3) {
    return "Go Home!";
  } else {

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

// Change these values to test
golfScore(1, 1);
could use some help por favor
Kelechi Chinaka
@ke1echi
Jan 09 2017 03:12
hey guys how do i go bout the random quote machine, just finished the ui now
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:13
@yassbetch golf is comparing your strokes to par. so in your if statements you are comparing par to par eg. if (par===par+2){} will never be true....try comparing strokes to par, and checking the logical order of your statements
Jerry Purvis
@MessiaHack
Jan 09 2017 03:13
var taxRate = 0.09;
var bankAcct = parseFloat(prompt("How much money is in your bank?", ""));
var phones = parseFloat(prompt("How many phones would you like?", ""));
var phoneAmt = 99.99;
var phoneAccAmt = 9.99;
var purchaseAmt = "";
function purchase(phones) {
    var a = phones * phoneAmt;
    var b = a * taxRate;
    purchaseAmt = a + b;
    return purchaseAmt;
}

console.log(purchase())
This still returns NaN
Emily Sperry
@sperrye
Jan 09 2017 03:15
Awhile ago someone posted a link to a pair-programming match up site... any clue out there what that was?
Ken Haduch
@khaduch
Jan 09 2017 03:16

@vzambrano98 - hey there... You definitely do not need your first test condition - for this problem, the objects all have their .firstName defined. The only thing that you want to do, at least the first thing that I would say you want to do, is this:

for (...) {
    if ( contacts[i].firstName === firstName ) {
        // perform the check for the property and make the appropriate return
        // either the property value or "No such property"
    } 
} // note that this is the end of the "for" loop
// when you get here, you haven't found a contact that matched, because you would have returned a value

I hope that wasn't too much of a spoiler. You have most of the necessary code in there, it just needs a bit of tweaking around.

Jameel Matin
@cutiepatootiebear
Jan 09 2017 03:17

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1 && par === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par-2 && par <= par -2) {
    return "Eagle";
  } else if (strokes === par-1 && par === par-1) {
    return "Birdie";
  } else if (strokes === par) {
    return "Par";
  } else if (strokes === par+1) {
    return "Bogey";
  }else if (strokes === par+2) {
    return "Double Bogey";
  }else if (strokes >= par +3) {
    return "Go Home!";
  } else {

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

// Change these values to test
golfScore(4, 1);
Ken Haduch
@khaduch
Jan 09 2017 03:17
@sperrye - not sure if it is active, but try this room: https://gitter.im/FreeCodeCamp/LetsPair?source=orgpage
Ramone
@RamoneQR
Jan 09 2017 03:19
@yassbetch I think the first if statement should be
```
if (strokes == 1){}
Jameel Matin
@cutiepatootiebear
Jan 09 2017 03:19

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par-2 ) {
    return "Eagle";
  } else if (strokes === par-1 ) {
    return "Birdie";
  } else if (strokes === par) {
    return "Par";
  } else if (strokes === par+1) {
    return "Bogey";
  }else if (strokes === par+2) {
    return "Double Bogey";
  }else if (strokes >= par +3) {
    return "Go Home!";
  } else {

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

// Change these values to test
golfScore(4, 1);
Ramone
@RamoneQR
Jan 09 2017 03:19
@yassbetch Yeah that looks right
Jameel Matin
@cutiepatootiebear
Jan 09 2017 03:20
Thanks @RamoneQR !
CamperBot
@camperbot
Jan 09 2017 03:20
yassbetch sends brownie points to @ramoneqr :sparkles: :thumbsup: :sparkles:
:cookie: 199 | @ramoneqr |http://www.freecodecamp.com/ramoneqr
Ramone
@RamoneQR
Jan 09 2017 03:21
@yassbetch No problem!
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:21
@yassbetch you can remove your last if statement as well and just have it as the else statement.
Jameel Matin
@cutiepatootiebear
Jan 09 2017 03:22
thanks @vzambrano98
CamperBot
@camperbot
Jan 09 2017 03:22
yassbetch sends brownie points to @vzambrano98 :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @vzambrano98 |http://www.freecodecamp.com/vzambrano98
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:23
@yassbetch any time :+1:
Ammy3165
@Ammy3165
Jan 09 2017 03:26

help me run this code, and the instructions are:- You should use the split method on the string.
You should split the string by its spaces.

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('\s');

CamperBot
@camperbot
Jan 09 2017 03:26
no wiki entry for: me run this code and the instructions are-
Kelechi Chinaka
@ke1echi
Jan 09 2017 03:27
pls guys who wants to walk me through the random quote machine
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:28
@khaduch I think I get it lol, I think I might be java-slow. I think I know what you are saying though, let me keep working on it. thanks for never giving me the answer
CamperBot
@camperbot
Jan 09 2017 03:28
vzambrano98 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2234 | @khaduch |http://www.freecodecamp.com/khaduch
jerryslone
@jerryslone
Jan 09 2017 03:32
On Testing Objects for Properties how do i return checkObj("house")? i cant get it to return "not found".
Ken Haduch
@khaduch
Jan 09 2017 03:33
@vzambrano98 okay - you just need to key the main actions off the name match with one of the objects, and you never want to return anything for a non-match until you have a chance to test every user (object) for a match.
babajide odusola
@cesarecaravaggio
Jan 09 2017 03:33
js is really starting to frustrate
Ammy3165
@Ammy3165
Jan 09 2017 03:35

help me run this code, and the instructions are:- You should use the split method on the string.
You should split the string by its spaces.

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('\s');

CamperBot
@camperbot
Jan 09 2017 03:35
no wiki entry for: me run this code and the instructions are- you should use the split method on the stringyou should split the string by its spacesvar string split me into an arrayvar array only change code below this linearray stringsplits
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:36
@khaduch oooooh! roger :fire:
Ammy3165
@Ammy3165
Jan 09 2017 03:37
hey, is there anyone who can help me...
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 03:37
https://codepen.io/Geeheeb/pen/XpmdJR can anyone spot any bugs that need sorting out, i know it still needs to styling changes
@Ammy3165 dont use a \s just do " " for a space
\s is regex
James Eldridge
@jeldridgeTS
Jan 09 2017 03:41
regex is life
Ken Haduch
@khaduch
Jan 09 2017 03:41
@Ammy3165 - it might be that you just need to do string.split(' '); for that split?
Kelechi Chinaka
@ke1echi
Jan 09 2017 03:41
string.split(' ') @Ammy3165
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 03:41
regex is pain @jeldridgeTS
James Eldridge
@jeldridgeTS
Jan 09 2017 03:42
yea, I was being silly
Ammy3165
@Ammy3165
Jan 09 2017 03:42
@kelechichinaka @khaduch @HeebieGeeBee thanks
CamperBot
@camperbot
Jan 09 2017 03:42
ammy3165 sends brownie points to @kelechichinaka and @khaduch and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 2235 | @khaduch |http://www.freecodecamp.com/khaduch
:cookie: 273 | @kelechichinaka |http://www.freecodecamp.com/kelechichinaka
:cookie: 491 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Ken Haduch
@khaduch
Jan 09 2017 03:45
@cesarecaravaggio - what have you got up to this point?
yongjaeya
@yongjaeya
Jan 09 2017 03:47
how would I assign a nickname property in the form of a string value in var myCar= new Car();
Ken Haduch
@khaduch
Jan 09 2017 03:48
@jerryslone - you have to do something like:
if (obj.hasOwnProperty(prop)){
    return obj[prop];
}
yongjaeya
@yongjaeya
Jan 09 2017 03:49

var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 5;
};

// Only change code below this line.

var myCar= new Car();

I don't think i'm allowed to use the if statement
Victoria Zambrano
@vzambrano98
Jan 09 2017 03:54
@khaduch It took me a while but I finally got it! You're my javascript hero :clap: ty
CamperBot
@camperbot
Jan 09 2017 03:54
vzambrano98 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: vzambrano98 already gave khaduch points
Ken Haduch
@khaduch
Jan 09 2017 03:58
@vzambrano98 - great! The thing is to learn from these lessons as they get more complicated. The tricky thing in this one, at least it seems that most people that post here about this, is what to do about "No such contact". The concept of just running through the whole array and not returning anything until afterward seems to escape notice. I think that it's something that seems to be a "surprise" - you can certainly make complicated ways to check for that by keeping counts and states and stuff - but that automatically happens by running through the entire array and having found nothing to match. That's an example - things that you start to pick up as you get more experience...
Happy to help!
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 03:59
@yongjaeya if you read the challenge information it tells you how to do it
Ken Haduch
@khaduch
Jan 09 2017 04:00
@yongjaeya - once you have created the object, you can add properties as they show in the example myCar.turboType = "twin";, you just have to add a similar property with the property name of "nickname". And all you have to do is assign it any string value for the nickname.
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:01
myPlants.secondTree = "pine"
need help on this part
Accessing Nested Arrays
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:02
myPlants[secondTree] @Assaonator
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:03
@HeebieGeeBee sorry i tried that
Ken Haduch
@khaduch
Jan 09 2017 04:03
@HeebieGeeBee @Assaonator - maybe myPlants["secondTree"]? (Depending on which challenge this is? The value in brackets has to be a string or a variable?)
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:03
put all the code up
i dont know what challenge it is
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:03

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

// Only change code below this line

myPlants.[secondTree] = "pine"; // Change this line
Accessing Nested Arrays
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:03
oh ok
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:03
been stuck on this for like 4 hours
any idea?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:04
what does it say you have to do?
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:04
Use dot and bracket notation to access myPlants
Victoria Zambrano
@vzambrano98
Jan 09 2017 04:05
@Assaonator accessing nested arrays via the dot or bracket method. so you begin by usingthe array name and the [index] or number of the array you want, then access the list with either dot or bracket
James Eldridge
@jeldridgeTS
Jan 09 2017 04:05
the last line you’re using a combination of both it seems
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:05
what part of myPlants?
Vizij
@Vizij
Jan 09 2017 04:05
@Assaonator Reset first, it's having you either return that line or assign it to something, you're trying to change the object with that line
Victoria Zambrano
@vzambrano98
Jan 09 2017 04:05
@Assaonator does that make sense?
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:06
confused
Victoria Zambrano
@vzambrano98
Jan 09 2017 04:06
@Assaonator myPlants[#].object
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:06
if a variable cotains two arrays
how would you access the first array?
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:07
myPlants[1].pine; still giving me an error
James Eldridge
@jeldridgeTS
Jan 09 2017 04:07
myPlants is an array, to access and array, you must use an index
myPlants[0] will return the first index, which in this case is the entire object
there is no 1
Vizij
@Vizij
Jan 09 2017 04:07

@Assaonator Pretend that myPlants is an array (it is), but both objects are empty. So it looks like this:

myPlants = [ {}, {}]

myPlants[0] is the first object, myPlants[1] is the second, etc

HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 04:07
where in the object is the pine tree?
James Eldridge
@jeldridgeTS
Jan 09 2017 04:08
my plants is an array with only one object inside of it, thus you need to call myPlants[0] since it’s a 0 based index
Vizij
@Vizij
Jan 09 2017 04:08
@jeldridgeTS It's not, there are two objects
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:08

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

// Only change code below this line

var secondTree = ""; // Change this line
this is the whole code
Victoria Zambrano
@vzambrano98
Jan 09 2017 04:08
@Assaonator oh sorry, you have to access "list" first and then the index for that "list", much like you did for myPlants
mattcharlesh
@mattcharlesh
Jan 09 2017 04:08

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++) {
    console.log(arr[i][j]);
      product = product * multiplyAll(j)
  }
}  
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Nesting For Loops.. what did i miss?
James Eldridge
@jeldridgeTS
Jan 09 2017 04:08
ah yea you’re right sorry
well he’s on the right path then
Manish Giri
@Manish-Giri
Jan 09 2017 04:09
@mattcharlesh product = product * multiplyAll(j)
this line is wrong.
multiplyAll is the name of the function, you need to refer the array arr instead.
mattcharlesh
@mattcharlesh
Jan 09 2017 04:09
@Manish-Giri thanks!
CamperBot
@camperbot
Jan 09 2017 04:09
mattcharlesh sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3652 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Jan 09 2017 04:09
@mattcharlesh - multiplyAll is the function name. That should not appear within the body of the function. You should be using the function argument, which is arr.
Manish Giri
@Manish-Giri
Jan 09 2017 04:10
:+1:
mattcharlesh
@mattcharlesh
Jan 09 2017 04:10
@khaduch thanks too!
CamperBot
@camperbot
Jan 09 2017 04:10
mattcharlesh sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2236 | @khaduch |http://www.freecodecamp.com/khaduch
Vizij
@Vizij
Jan 09 2017 04:10
@Assaonator myPlants[1] You have this part right so far. Now, in that object (which is myPlants1), you have to look for the next "property" (since it's an object) you'll need to access. It has two properties
James Eldridge
@jeldridgeTS
Jan 09 2017 04:11
hint: dot notations comes into play here
CamperBot
@camperbot
Jan 09 2017 04:11
Set a bonfire to talk about with bonfire name
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:12
Ive tried on google and nothing seems to coming up as a solution
this is extremely tricky
Vizij
@Vizij
Jan 09 2017 04:13
@Assaonator It's just about visualizing where you need to go. You're at myPlants[1] right now, so you're at the object you need to be in. Inside that object, you have type: and list: properties.
So how do you access one of those?
Mohamed Osama Khan
@Assaonator
Jan 09 2017 04:15
yes its trees and pine
.....
Vizij
@Vizij
Jan 09 2017 04:16
Yes, I'm saying, how do you actually get to pine? myPlants[1] , now you're trying to access an object property. So what's right after that?
Ramone
@RamoneQR
Jan 09 2017 04:17
var count = 0;

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

  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(2); cc(10);
Anyone willing to help me with the counting cards challenge in the basic javascript section?
James Eldridge
@jeldridgeTS
Jan 09 2017 04:17
@Assaonator So by calling myPlants[1] you get back an object… this object has two properties - type and list
Manish Giri
@Manish-Giri
Jan 09 2017 04:18
@RamoneQR these statements are wrong
 card = count + " Bet";
 card = count + " Hold";
James Eldridge
@jeldridgeTS
Jan 09 2017 04:18
When you have an object, you access it’s properties by using dot notation - Object.type for example
Manish Giri
@Manish-Giri
Jan 09 2017 04:18
inside the switch, you only increment or decrement count as necessary
once outside, you need to check what the value of count is, and return count along with Bet or Hold, as the case maybe
@RamoneQR
Ramone
@RamoneQR
Jan 09 2017 04:20
@Manish-Giri Oh I think I get what you are saying... Let me just rework my code a bit
Manish Giri
@Manish-Giri
Jan 09 2017 04:20
@RamoneQR cool
mattcharlesh
@mattcharlesh
Jan 09 2017 04:24
product = product * arr(j)
Kelechi Chinaka
@ke1echi
Jan 09 2017 04:29
that does target the sub-array @mattcharlesh
use the bracket not to target i, then j @mattcharlesh
Daniel
@doodleslr
Jan 09 2017 04:30

var Bike = function() {

// Only change code below this line.

var gear = 0;

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

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

var myBike = new Bike();

Can anyone help me understand how
this.setGear = function(set)
brings in the value 'set' without it being predefined or even mentioned anywhere previously so if
gear = set
then gear = ??????

james clark
@james0212
Jan 09 2017 04:30

hi, I'm stuck with the challenge "stand in line" can anyone help me?
here's the code:
function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift([],1);
arr.push(item);
arr.shift([2],1);

return (arr,item); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10),testArr[4]); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
what I need to do:
nextInLine([], 1) should return 1(done)
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10(done)

Kelechi Chinaka
@ke1echi
Jan 09 2017 04:32
push() the item and return shift() first element of the array @james0212
shift() does not take any arg @james0212
Matt Husted
@mahusted
Jan 09 2017 04:35

Hello, I am having trouble with the Profile Lookup task. It appears I am not cycling through the entire contacts object. Here's my code: function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];

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

    } else {
  return "No such contact";

  }
} 

// Only change code above this line
}

Sorry, not sure why it broke up my message like that
Tyler Lujan
@tlujan
Jan 09 2017 04:36
I am having trouble with 155 JS and would love some advice.

'
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");
'

It is the Word Blanks challenge and I have no idea what it is asking me to do
mattcharlesh
@mattcharlesh
Jan 09 2017 04:38
@kelechichinaka how to use the bracket to target j but not i?
Kelechi Chinaka
@ke1echi
Jan 09 2017 04:39
j is a sub-arr of i, so u target i before j [i][j] @mattcharlesh
Matt Husted
@mahusted
Jan 09 2017 04:39
@tlujan you have to create a string with the variables myNoun, myAdjective... and concatenate them with your own words to form a sentence. Does that make sense?
Tyler Lujan
@tlujan
Jan 09 2017 04:40
yes @mahusted thank you, you worded it much better
CamperBot
@camperbot
Jan 09 2017 04:40
tlujan sends brownie points to @mahusted :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @mahusted |http://www.freecodecamp.com/mahusted
Matt Husted
@mahusted
Jan 09 2017 04:41
@tlujan you're welcome :smile:
Alex
@Joshua-A-Smith
Jan 09 2017 04:48
var someAdjective "dfl";
var myStr = "Learning to code;

myStr += someAdjective;
Can someone tell me what's wrong On Appending Var to Strings
Kelechi Chinaka
@ke1echi
Jan 09 2017 04:50
just + @Joshua-A-Smith
jerryslone
@jerryslone
Jan 09 2017 04:50
@khaduch I still wasn't able to get it
Alex
@Joshua-A-Smith
Jan 09 2017 04:50
@kelechichinaka Can you be more specific?
Manish Giri
@Manish-Giri
Jan 09 2017 04:51
@Joshua-A-Smith where's the = here? var someAdjective "dfl";
Kelechi Chinaka
@ke1echi
Jan 09 2017 04:52
no = for first line and no ending " for second line @Joshua-A-Smith
dsillydude
@dsillydude
Jan 09 2017 04:52
here's a code, i know i have completed the challenge but i still dont get it how is it possible why do we need that array inside of our code on Testing Objects for Properties challenge
Alex
@Joshua-A-Smith
Jan 09 2017 04:53
@kelechichinaka @Manish-Giri
Thanks A Bunch!
CamperBot
@camperbot
Jan 09 2017 04:53
joshua-a-smith sends brownie points to @kelechichinaka and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @kelechichinaka |http://www.freecodecamp.com/kelechichinaka
dsillydude
@dsillydude
Jan 09 2017 04:53

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

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

//test checkObj("gift");
// Your Code Here

return "Change Me!";
}

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

CamperBot
@camperbot
Jan 09 2017 04:53
:star2: 3654 | @manish-giri |http://www.freecodecamp.com/manish-giri
alarconm
@alarconm
Jan 09 2017 04:53
Hello everyone. Does this reverse a string or am i missing something? strReverse = strNew.split('').reverse().join('');
rajatsaxena6
@rajatsaxena6
Jan 09 2017 04:53
Please help on checking the palindrome challenge.. please
Kelechi Chinaka
@ke1echi
Jan 09 2017 04:53
done the ui but stil dont know how to go bout the rest for the random quote machine @Manish-Giri
Manish Giri
@Manish-Giri
Jan 09 2017 04:53
@alarconm what is strNew
dsillydude
@dsillydude
Jan 09 2017 04:53
anyone?
Ken Haduch
@khaduch
Jan 09 2017 04:53
@jerryslone - what have you got up to this point, then?
alarconm
@alarconm
Jan 09 2017 04:54
function palindrome(str) {
// Good luck!
//remove all non-alphanumeric characters
str = strNew;
strNew = str.replace(/\W/g,'');
//turn everything lower case
strNew =strNew.toLowerCase();
//reverse the string
strReverse = strNew.split('').reverse().join('');
Manish Giri
@Manish-Giri
Jan 09 2017 04:54
@kelechichinaka you could use an array of your own quotes, or you could use an API to provide quotes..
first option might be better to start off with!
@alarconm str = strNew;
check the order of assignment
alarconm
@alarconm
Jan 09 2017 04:55
wow thank you
yikes i have been staring at this too long to miss that, you rock!
Manish Giri
@Manish-Giri
Jan 09 2017 04:56
:+1:
Ken Haduch
@khaduch
Jan 09 2017 04:57
@jerryslone - let me check...
Matt Husted
@mahusted
Jan 09 2017 04:58
Anyone have an idea on my Profile Look code above? I think it has to do with how my conditionals are nested. I've tested and it won't get past the first nested object
*Profile Lookup
Ken Haduch
@khaduch
Jan 09 2017 04:58
@jerryslone - you have to use the names that are provided in the exercise, I was just trying to give you some hint as to what you needed to do. So replace the obj that was in my example with myObj (two places) and the prop that was in my example with checkProp (also in two places.)
@mahusted - you should look at the MarkDown code posting information in the link that CamperBot will post next '''
CamperBot
@camperbot
Jan 09 2017 05:00
:bulb: to format code use backticks! ``` more info
Ken Haduch
@khaduch
Jan 09 2017 05:01
@mahusted - this is your code frrom your previous post -
function lookUpProfile(firstName, prop) {
  // Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if (!contacts[i].hasOwnProperty(prop)) {
      return 'No such property';
    } else {
      return 'No such contact';
    }
  }  // Only change code above this line

}
Kat Martinez
@LoveRoseGoddess
Jan 09 2017 05:02

I'm trying to practice the entire js section and I seem to forget this one every time.

```

Matt Husted
@mahusted
Jan 09 2017 05:02
@khaduch Thanks for the tip on how to post snippets and posting my code too :smile:
CamperBot
@camperbot
Jan 09 2017 05:02
mahusted sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2237 | @khaduch |http://www.freecodecamp.com/khaduch
Kat Martinez
@LoveRoseGoddess
Jan 09 2017 05:02
function golfScore(par, strokes) {
  // Only change code below this line
  if (1, 1) {
    return "Hole-in-one!";
  }

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

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

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

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

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

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

  else {
    return "Go Home!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
It reads the hole in ones but it doesn't read everything else
Noah Overcash
@smileytechguy
Jan 09 2017 05:03
@LoveRoseGoddess if strokes == 1
and so forth, if strokes == par-2
strokes = par-1
= par
= par+1
etc etc
Ken Haduch
@khaduch
Jan 09 2017 05:04
@mahusted - your first conditional looks okay - matching the firstName and checking for the property. But your second conditional no longer knows about the firstName match, so that's not correct. It might work under some conditions.
The last thing, a common problem with this one, is that you are returning "No such contact" before you have a chance to examine all of the contacts in the array. Simply remove that return from within the loop code block to after the loop code block, and if you don't find a match within the loop (from which you will return) you will just fall through to return that final status.
Alex
@alwongg
Jan 09 2017 05:05
Hello, I have a question about if/else if statements in javascript
Noah Overcash
@smileytechguy
Jan 09 2017 05:06
@alwongg whats up
Alex
@alwongg
Jan 09 2017 05:06
question is, do we need to use them at all if FCC says switch statements are easier?
whats the point of if/else if statements then?
Kat Martinez
@LoveRoseGoddess
Jan 09 2017 05:06
@smileytechguy omg lol really Thanks!
CamperBot
@camperbot
Jan 09 2017 05:06
loverosegoddess sends brownie points to @smileytechguy :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @smileytechguy |http://www.freecodecamp.com/smileytechguy
Noah Overcash
@smileytechguy
Jan 09 2017 05:06
@alwongg just 1/2 if/elses are better with that
Ken Haduch
@khaduch
Jan 09 2017 05:06

@mahusted - you can correct the cases where you match the firstName by doing something like this:

if ( contacts[i].firstName === firstName) {
    // check for the property and return it if you find it ELSE return the "No such property"
}

Nest the property checks for the matching contact within the code block where you know you have a match. That will handle it properly.

Noah Overcash
@smileytechguy
Jan 09 2017 05:06
switch is an abbrevieated if else, and cant do some advanced checks you'll learn later
Alex
@alwongg
Jan 09 2017 05:07
ah okay ill keep that in mind
thanks!
Matt Husted
@mahusted
Jan 09 2017 05:07
@khaduch Taking a look now. Appreciate the hint
Ken Haduch
@khaduch
Jan 09 2017 05:08

@jerryslone - great - it is passing two tests. So the last thing that you have to do is

If the property is found, return that property's value. If not, return "Not Found".

You are now handling the case where the property is found. You only have to add code to handle the case where the property is not found, in other words, if myObj.hasOwnProperty(checkProp) === false.

@mahusted - okay, I hope you get it. I have to get off the computer now and get some sleep... :) you will get help from people here if you need it. Just think through your code as you rework it and understand what the tests are telling you... Good luck!
Emily Sperry
@sperrye
Jan 09 2017 05:11
if I give an element an id of [i] to give it a unique ID, how can I use that ID later in the script when I want to identify that element with jquery?
khaduch @khaduch - good night to all - happy coding!
jerryslone
@jerryslone
Jan 09 2017 05:11
got it thanks! @khaduch
CamperBot
@camperbot
Jan 09 2017 05:11
jerryslone sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2238 | @khaduch |http://www.freecodecamp.com/khaduch
Noah Overcash
@smileytechguy
Jan 09 2017 05:11
Emily Sperry
@sperrye
Jan 09 2017 05:11
$("#"+[i]) essentially
Matt Husted
@mahusted
Jan 09 2017 05:13
@khaduch At one point I was checking firstName again in my else if, but moving out the return "No such contact" was the trick. Thanks man! :sparkles: Good night!
CamperBot
@camperbot
Jan 09 2017 05:13
mahusted sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: mahusted already gave khaduch points
Alex
@Joshua-A-Smith
Jan 09 2017 05:13
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World"

myStr[0] = "H"; // Fix Me
Anyone know how to do this properly?
Emily Sperry
@sperrye
Jan 09 2017 05:13
this is using a for loop, the i is the position in the array. ["joe", "brian"] would make <span id="0"> and <span id="1"> and then I'm trying to use that id later to change content inside <span>
Manish Giri
@Manish-Giri
Jan 09 2017 05:14
@Joshua-A-Smith strings are immutable
Ken Haduch
@khaduch
Jan 09 2017 05:14
@sperrye - you need to somehow remember what ID you gave it - if it's something like one of the challenges, say the twitch challenge, you could make an object with usernames as the key and store the ID in a property, so that you know how to look it up later by some known entity? I don't know exactly what scenario you are trying to solve? But you need to have a way to track the unique value in a reliable way that you can look it up.
Manish Giri
@Manish-Giri
Jan 09 2017 05:14
@khaduch howdy :wave:
Ken Haduch
@khaduch
Jan 09 2017 05:14
@Manish-Giri - hello, my friend! How are things?
Manish Giri
@Manish-Giri
Jan 09 2017 05:15
@khaduch been good, thx! you?
CamperBot
@camperbot
Jan 09 2017 05:15
manish-giri sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2239 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jan 09 2017 05:15
@sperrye - you could make a parallel array with the unique ID values? OR if it's really the index of the values in the array, just do a lookup using "indexOf" and get the array index? Just simple ideas that might work...
@Manish-Giri - doing okay, but time to call it a night... :) Thanks for asking, and have fun!
CamperBot
@camperbot
Jan 09 2017 05:16
khaduch sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3656 | @manish-giri |http://www.freecodecamp.com/manish-giri
Alex
@Joshua-A-Smith
Jan 09 2017 05:16
@Manish-Giri I still don't understand?
Will
@wwhite2011
Jan 09 2017 05:16
"I am a \"double quoted\" string inside \"double quotes\"."
there must be a problem with this because I did it exactly like the example!
Manish Giri
@Manish-Giri
Jan 09 2017 05:17
@khaduch you too!
Emily Sperry
@sperrye
Jan 09 2017 05:18
your \ are on the wrong side in a couple of places @wwhite2011
Manish Giri
@Manish-Giri
Jan 09 2017 05:18
@Joshua-A-Smith this line
myStr[0] = "H";
tries to change the first letter in a string, which is not possible because you can't modify strings
you can assign a new string to a variable instead
james clark
@james0212
Jan 09 2017 05:19
I still don't know what to do in the challenge named "stand in line". can anyone help me?
Kelechi Chinaka
@ke1echi
Jan 09 2017 05:20
letsc what you have @james0212
Will
@wwhite2011
Jan 09 2017 05:20
I dont think so cuz that one works
"FirstLine\"SecondLine\"ThirdLine"
this one doesnt but its the saame thing
fernando Reyna
@frr225
Jan 09 2017 05:21
why does it keep saying arr.split is not a i have tried changing the vars names but thiscode is straignt from the documentation

function makeFriendlyDates(arr) {
arr = arr.split("-",4);
return arr;
}

makeFriendlyDates(['2016-07-01', '2016-07-04']);

arr.splitisnotafunction
Alex
@Joshua-A-Smith
Jan 09 2017 05:22
@Manish-Giri So I should assign a new string to the same var
Or create a new var
Alex
@alwongg
Jan 09 2017 05:22
@smileytechguy ah this is so much. how do people do this !
Manish Giri
@Manish-Giri
Jan 09 2017 05:22
@frr225 why two params inside .split()
Alex
@alwongg
Jan 09 2017 05:22
but thanks for the links!
Manish Giri
@Manish-Giri
Jan 09 2017 05:22
@Joshua-A-Smith what's the challenge name?
Noah Overcash
@smileytechguy
Jan 09 2017 05:22
@alwongg check out the rest of my github, all kinds of stuf
Alex
@alwongg
Jan 09 2017 05:23
@smileytechguy for sure!
Noah Overcash
@smileytechguy
Jan 09 2017 05:23
that repo is full of old, bad, very very bad code
but the others are ok
Alex
@Joshua-A-Smith
Jan 09 2017 05:23
@Manish-Giri "Understand String Immutability"
ep2677
@ep2677
Jan 09 2017 05:24
can someone help me with understanding "Nesting for loops"
i finished the challenge
but i just don't understand
Manish Giri
@Manish-Giri
Jan 09 2017 05:24
@Joshua-A-Smith
// Only change code below this line
myStr = "Hello World"

myStr[0] = "H"; // Fix Me
you've already done the required thing
myStr = "Hello World"
fernando Reyna
@frr225
Jan 09 2017 05:25
@Manish-Giri the first because i want to split the date every "-" 11-00- 0000 the other one i was just playing arround to see what happened but still nothing worked
Manish Giri
@Manish-Giri
Jan 09 2017 05:25
now delete this - myStr[0] = "H";
ep2677
@ep2677
Jan 09 2017 05:25
var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
Manish Giri
@Manish-Giri
Jan 09 2017 05:25
@Joshua-A-Smith but put a ;
james clark
@james0212
Jan 09 2017 05:26

@kelechichinaka function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift([2],1);
arr.push(item);
arr.shift([2],1);

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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10),testArr[4]); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
what I need to do:
nextInLine([], 1) should return 1(done)
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10(done)

ep2677
@ep2677
Jan 09 2017 05:26
what is arr[i].length; ?
Alex
@Joshua-A-Smith
Jan 09 2017 05:26
@Manish-Giri
Makes so much sense now Thank you
CamperBot
@camperbot
Jan 09 2017 05:26
joshua-a-smith sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: joshua-a-smith already gave manish-giri points
Kelechi Chinaka
@ke1echi
Jan 09 2017 05:26
ur second line is wrong shift() does not take any arg @Joshua-A-Smith
you're using it on an array.
@Joshua-A-Smith welcome
Kelechi Chinaka
@ke1echi
Jan 09 2017 05:27
third line repeats first line, pls remove it @Joshua-A-Smith
Manish Giri
@Manish-Giri
Jan 09 2017 05:29
@kelechichinaka you're tagging the wrong person mate
Alex
@Joshua-A-Smith
Jan 09 2017 05:29
@kelechichinaka
I understand now
Sidharth Gupta
@sg25mait
Jan 09 2017 05:29
hello guys this is my code for truncate string
function truncateString(str, num)
{
  // Clear out that junk in your trunk
  var a ="...";
  if(num >= str.length)
  {
    return str;
  }
  else if(num>3)
  {
    var c = str.substring(0,num-3);
    return (c.concat(a));
  } 
  else
  {
    var d= str.substring(0,num);
    return d.concat(a);
  }

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Kelechi Chinaka
@ke1echi
Jan 09 2017 05:29
oh :smile: @Manish-Giri
rajatsaxena6
@rajatsaxena6
Jan 09 2017 05:30
Hi, i am getting a failed test case on _eye and 0_000 in the palindrome..plz help
Sidharth Gupta
@sg25mait
Jan 09 2017 05:30
if i use split function instead of substring it does not work any idea y?
fernando Reyna
@frr225
Jan 09 2017 05:30
@Manish-Giri well is in the useful links should i use slice instead ? what do i use in arrays ?
Sidharth Gupta
@sg25mait
Jan 09 2017 05:32
@rajatsaxena6 : replace(/[^\w]|_/g, "") use this and it will remove all non-alphanumeric characters
rajatsaxena6
@rajatsaxena6
Jan 09 2017 05:37
thank you @sg25mait !!
CamperBot
@camperbot
Jan 09 2017 05:37
rajatsaxena6 sends brownie points to @sg25mait :sparkles: :thumbsup: :sparkles:
:cookie: 234 | @sg25mait |http://www.freecodecamp.com/sg25mait
Sidharth Gupta
@sg25mait
Jan 09 2017 05:37
@rajatsaxena6 :+1:
trupal
@Trupal24
Jan 09 2017 05:52
blob
blob
blob
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
I need help to solve this
Alex
@alwongg
Jan 09 2017 05:56
oh I'm on the counting cards challenge too!
can't figure it out tho
Emily Sperry
@sperrye
Jan 09 2017 05:56
I'm still trying to work this out, if somebody wouldn't mind looking at my code and telling me why the status is getting stuck at [1] and then repeating itself it would be much appreciated. http://codepen.io/sperrye/pen/GrJPmG?editors=1111
hushuhang
@1638648707
Jan 09 2017 06:05
I need help to solve Counting Cards,Is there anyone to help me
trupal
@Trupal24
Jan 09 2017 06:10
@1638648707 I also want help in that
Ashish Singh Rawat
@ashish9342
Jan 09 2017 06:11

Need help with this
https://www.freecodecamp.com/challenges/stand-in-line

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

function nextInLine(arr, item) {
// Your code here
if(arr.length === 0){
item = 1;
}else if(arr.length < item){
item = item;
}else {
item = arr.shift();
}

return item; // Change this line
}

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

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

uriznik
@uriznik
Jan 09 2017 06:11
@sperrye by the time your callbacks run and the i variable is used i will be set to 5
trupal
@Trupal24
Jan 09 2017 06:12
@alwongg i also stuck in that. Can u plz send me your code?
Emily Sperry
@sperrye
Jan 09 2017 06:14
@uriznik thank you! that helps immensely!
CamperBot
@camperbot
Jan 09 2017 06:14
sperrye sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @uriznik |http://www.freecodecamp.com/uriznik
trupal
@Trupal24
Jan 09 2017 06:14
hello plz help anyone tp solve counting card challenge
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:16
@sperrye im sure you could get it done with loops eventually but might start getting complicated and confusing maybe you should look into this method if you dont know about it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
Alex
@Joshua-A-Smith
Jan 09 2017 06:16
// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.

var myArray.push(["dog", 3]);
How am I doing this wrong?
trupal
@Trupal24
Jan 09 2017 06:18
@Joshua-A-Smith Which challenge is this?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:18
trupal the first step if to create a variable count that adds 1, subtracts 1, or does nothing depending what the card is, then when all the cards have been processed you make a return of the final count plus either Bet or Hold, dependent on what the size of count is
@Trupal24
Alex
@Joshua-A-Smith
Jan 09 2017 06:18
@Trupal24 "Manipulate Arrays With push"
trupal
@Trupal24
Jan 09 2017 06:19
@HeebieGeeBee sry i m not getting can u plz shoe me the code.
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:19
@Joshua-A-Smith remove var of second code, just myArray
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:19
do you think seeing the answer will be the best way to learn?
trupal
@Trupal24
Jan 09 2017 06:20

@Joshua-A-Smith var ourArray = ["Stimpson", "J", "cat"];
ourArray.push(["happy", "joy"]);
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.

myArray.push(["dog",3]);

uriznik
@uriznik
Jan 09 2017 06:20
@sperrye it'd be cleaner to give your ajax function some parameters (like user name, index) and then do any magic from inside the ajax/fetchdata function as it looks bad to refer to a loop variable that's only defined below
trupal
@Trupal24
Jan 09 2017 06:20
@HeebieGeeBee no
Sarah
@Shoyren
Jan 09 2017 06:20
Does anyone know why my splice functions aren't working here for the Spinal Tap Case Challenge?
function spinalCase(str) {

  var newstr = str.replace(/ /gi, '-');
  newstr = newstr.replace(/_/gi, '-');

  var array = newstr.split('');
  for (var i=0; i<array.length; i++) {
    if (array[i] === array[i].toUpperCase()) {
      array[i] = '-' + array[i].toLowerCase();
    }
  }

  if (array[0] === '-') {
    array.splice(0,1);
  }

  for (var j=0; j<array.length; j++) {
    if (array[j-1] === '-' && array[j] === '-') {
      array.splice(j,1);
    }
  }

  return array.join('');
}

spinalCase('This Is Spinal Tap');
CamperBot
@camperbot
Jan 09 2017 06:20
:bulb: to format code use backticks! ``` more info
trupal
@Trupal24
Jan 09 2017 06:20
@HeebieGeeBee ok wait i will try
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:20
if you want to see the answer you can just google it
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:20
@Joshua-A-Smith doing that, you're declaring another variable and you'll get an error
Alex
@Joshua-A-Smith
Jan 09 2017 06:20
@Lumexralph @Trupal24
Thanks
CamperBot
@camperbot
Jan 09 2017 06:20
joshua-a-smith sends brownie points to @lumexralph and @trupal24 :sparkles: :thumbsup: :sparkles:
:cookie: 194 | @trupal24 |http://www.freecodecamp.com/trupal24
:cookie: 699 | @lumexralph |http://www.freecodecamp.com/lumexralph
Adam Morris
@Adam-Morris
Jan 09 2017 06:21
How could I improve this code?
function rot13Char(arr) {

  var nono = [];

  for (var k = 0; k < 128; k++) {

    if (k === 65) {
      k = 90;
      continue;
    }

    nono.push(k);

  }

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

    if (nono.indexOf(arr[i]) < 0) {

      if ((arr[i] - 13 < 65)) {
        arr[i] = 90 + (arr[i] - 13 - 65) + 1; 
      } else {
        arr[i] -= 13;
      }

    }

  }

}

function rot13(str) { // LBH QVQ VG!

  var charCodes = [];

  for (var i = 0; i < str.length; i++) {
    charCodes.push(str.charCodeAt(i));
  }

  rot13Char(charCodes);

  for (var j = 0; j < charCodes.length; j++) {
    charCodes[j] = String.fromCharCode(charCodes[j]);
  }

  var endString = charCodes.join("");

  return endString;
}
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:21
remove all the empty lines for one
Emily Sperry
@sperrye
Jan 09 2017 06:22
@HeebieGeeBee thanks
CamperBot
@camperbot
Jan 09 2017 06:22
sperrye sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 492 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
trupal
@Trupal24
Jan 09 2017 06:22
@Joshua-A-Smith welcome

@HeebieGeeBee var count = 0;
var count = 1;
var count =-1;
function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4|| card == 5|| card == 6 ){
count += 1;
return "5 Bet";
}

else if (card == 7 || card == 8 || card == 9){
count += 0;
return "0 Hold";  

}
else if(card == 10 || card == 'J' || card =='Q' || card =='K' || card == 'A'){
count -=1;
return "-5 Hold";

}
return "Bet + Hold";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Like this?

Markus Kiili
@Masd925
Jan 09 2017 06:26
@Trupal24 Why there is three variable declarations at start?
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:27
@Trupal24 why doing count = 1 ?
trupal
@Trupal24
Jan 09 2017 06:27

@Masd925 @Lumexralph
var count = 0;
function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4|| card == 5|| card == 6 ){
count += 1;
return "5 Bet";
}

else if (card == 7 || card == 8 || card == 9){
count += 0;
return "0 Hold";  

}
else if(card == 10 || card == 'J' || card =='Q' || card =='K' || card == 'A'){
count -=1;
return "-5 Hold";

}
return "Bet + Hold";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Is it ok?

Ogundele Olumide
@Lumexralph
Jan 09 2017 06:27
@Masd925 Good morning
Markus Kiili
@Masd925
Jan 09 2017 06:27
@Lumexralph Hi.
trupal
@Trupal24
Jan 09 2017 06:27
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold". I m not getting this
Markus Kiili
@Masd925
Jan 09 2017 06:28
@Trupal24 Value of card should just change count (not determine return value).
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:28
@Trupal24 you need just one global variable count = 0
grantknaver
@grantknaver
Jan 09 2017 06:28
am I allowed to do a while loop like this...
function translatePigLatin(str) {
  var lowercase = str.toLowerCase();
  var consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "x", "z", "w"];
  for(var i = 0; i < str.length; i++){
   for(var j =0; j < consonants.length; j++){
     while(str[i] === consonants[j]){
       //alert(str[i]);
       console.log(str[i]);
     }
     if(str[0] != consonants[j]){
       //alert(str[0]);
       console.log(str[0]);
     }
   }
  }
}

translatePigLatin("consonant");
trupal
@Trupal24
Jan 09 2017 06:29
@Masd925 sry i m not getting
Markus Kiili
@Masd925
Jan 09 2017 06:29
@grantknaver Looks like an infinite loop if the condition is true.
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:29
@grantknaver so far it's not infinite loop :smirk:
grantknaver
@grantknaver
Jan 09 2017 06:30
OK
quick question you guys
how is console.log(str[i]); infinite
?
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:31
@Masd925 resumed work?
Alex
@Joshua-A-Smith
Jan 09 2017 06:31
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
myArray.pop();
removeFromMyArray = .pop();
Am I doing this correctly?
grantknaver
@grantknaver
Jan 09 2017 06:31
wouldn't it stop once it hits str.length?
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:31
@grantknaver we mean the loop will run forever
barry01000010
@barry01000010
Jan 09 2017 06:31
how do i post up a screen shot in here, I am having trouble with a simple task, and I am sure I'm doing it right??Please help
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:32
@grantknaver i didn't read the code but if it's an infinite loop, it'll run till it crashes the browser
grantknaver
@grantknaver
Jan 09 2017 06:32
or do I have to establish that i is increasing within the while loop ()?
I know. It is erroring right now when I console log.
OK formatting now.
trupal
@Trupal24
Jan 09 2017 06:33

@Joshua-A-Smith var removedFromMyArray;

var removedFromMyArray = myArray.pop();
Like this

grantknaver
@grantknaver
Jan 09 2017 06:33
function translatePigLatin(str) {
    var lowercase = str.toLowerCase();
    var consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "x", "z", "w"];
    for (var i = 0; i < str.length; i++) {
        for (var j = 0; j < consonants.length; j++) {
            while (str[i] === consonants[j]) {
                //alert(str[i]);
                console.log(str[i]);

            }
            if (str[0] != consonants[j]) {
                //alert(str[0]);
                console.log(str[0]);
            }
        }
    }
}
I have been getting infinite loops a lot lately. I understand a typo, but the whole reason I included i < str.length is prevent an infinite loop
Ogundele Olumide
@Lumexralph
Jan 09 2017 06:35
@barry01000010
3 backticks(```)\\ ``` shift + enter for a newline
the code
3 backticks(```)\\ ``` another to end the code
Markus Kiili
@Masd925
Jan 09 2017 06:38
@Lumexralph Next week.
grantknaver
@grantknaver
Jan 09 2017 06:38
any ideas
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:40
so you have a nested while loop inside a nested for loop
and that while loop will loop while str[i] === consonants [j]
how would that work exactly?
grantknaver
@grantknaver
Jan 09 2017 06:42
it goes through str index by index
comparing that index against consonants
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:43
but if str[i] is b and consonants[j] is f
how will it ever stop
grantknaver
@grantknaver
Jan 09 2017 06:44
what ?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:44
the while loop
the first iteration is going to be str[i] which could be like a 'g'
and the consonant[j] is going to be b
grantknaver
@grantknaver
Jan 09 2017 06:45
OK one sec
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:46
so the while loop gets an g to compare b
and is told to stop looping when g === b
Cal-culator
@Cal-culator
Jan 09 2017 06:46
Hey guys
Can someone tell me why xml.status and xml.readyState are both 0?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:47
thats how it works right?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:47
maybe im missing something i dunno
grantknaver
@grantknaver
Jan 09 2017 06:47
so are you saying that the for loops I have set up will not take ... for instance
str[0] and compare it against all the index of consonants through the "j' for loop?
*indexs
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:50
i dont think the for loops are the problem
the while loop is
grantknaver
@grantknaver
Jan 09 2017 06:50
OK lets say this
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:50
these loops all iterate right
grantknaver
@grantknaver
Jan 09 2017 06:50
good cool. that is what I though
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:50
but it wont ever get past the first iteration
grantknaver
@grantknaver
Jan 09 2017 06:50
*thought
Alros Avellana
@alrosavellana
Jan 09 2017 06:50
guys help on "using objects for lookups"
grantknaver
@grantknaver
Jan 09 2017 06:51
why?
Alros Avellana
@alrosavellana
Jan 09 2017 06:51

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

// Only change code below this line
var lookup = {

"alpha":"Adams",
"bravo" : "Boston",
"charlie" : "Chicago",
"delta" : "Denver",
"echo": "Easy",
"foxtrot" : "Frank",
"" : undefined

};

how do i box my code btw?
grantknaver
@grantknaver
Jan 09 2017 06:51
lets take the example "consonant"
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:52
cus the first iteration is going to be i = 0, and j = 0 and then with these for i and j you have to go through this while loop
grantknaver
@grantknaver
Jan 09 2017 06:52
str[0] == = consonant[1] so the code included in that section should work
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:52
and since i will never equal j unless theyre both the same letter
that while loop is just going to keep looping
before you can even get to a second interation for the for loop j
Ryan
@ryanmcnamara36
Jan 09 2017 06:53
trying to give myCar a nickname property of a string .. this doesn't seem to work:
var myCar.nickname = "Audi";
Cal-culator
@Cal-culator
Jan 09 2017 06:54
Any one who can help?
Alros Avellana
@alrosavellana
Jan 09 2017 06:54
@Cal-culator i can try lol
Cal-culator
@Cal-culator
Jan 09 2017 06:54
Great!
Manish Giri
@Manish-Giri
Jan 09 2017 06:54
@geneyuss isn't myCar already defined earlier?
Cal-culator
@Cal-culator
Jan 09 2017 06:54
Have you done the Wikipedia Viewer assignment?
@alrosavellana
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:54
if str{i] and consonant[j] never change, and your condition on making the while loop to stop is when i and j are equal
Alros Avellana
@alrosavellana
Jan 09 2017 06:54
@Cal-culator ahhh nope XD im still on basic JS
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:54
hows that ever going to happen?
Cal-culator
@Cal-culator
Jan 09 2017 06:54
@alrosavellana ah ok
Ryan
@ryanmcnamara36
Jan 09 2017 06:54
@Manish-Giri only Car is defined
Cal-culator
@Cal-culator
Jan 09 2017 06:55
Good luck
Manish Giri
@Manish-Giri
Jan 09 2017 06:55
@Cal-culator what's the question?
Cal-culator
@Cal-culator
Jan 09 2017 06:55
This is my code pen
grantknaver
@grantknaver
Jan 09 2017 06:55
but j does change
Manish Giri
@Manish-Giri
Jan 09 2017 06:55
@geneyuss challenge name?
Cal-culator
@Cal-culator
Jan 09 2017 06:55
and I don't know why xml.status and xml.readyState outputs 0
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:55
no it doesnt
barry01000010
@barry01000010
Jan 09 2017 06:55
http://i.imgur.com/hbHzPhH.png ??Can anyone see were I gone Wrong???? I dont think I have??
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:55
it never gets passed the first iteration
cus it gets stuck in the while loop
Ryan
@ryanmcnamara36
Jan 09 2017 06:55
@Manish-Giri make instances of an object with a constructor
Manish Giri
@Manish-Giri
Jan 09 2017 06:56
@barry01000010 need a space between the 2 sentences
grantknaver
@grantknaver
Jan 09 2017 06:56
if it works than it runs through the while loop and the if, and than goes to the next j index
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:56
how does it run through the while loop?
Manish Giri
@Manish-Giri
Jan 09 2017 06:56

@geneyuss your first step is this

In the editor, use the Car constructor to create a new instance and assign it to myCar.

then the next step comes, first write the line for this step.
Cal-culator
@Cal-culator
Jan 09 2017 06:56
Help Build a Wikipedia Viewer
CamperBot
@camperbot
Jan 09 2017 06:56
no wiki entry for: build a wikipedia viewer
Chris Wingler
@chriswingler
Jan 09 2017 06:57
stuck on my last basic javascript challenge.. profile lookup.
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      return contacts[i][prop];
    } else if (firstName !== contacts[i][firstName]) {
      return "No such contact";
    } else if (prop !== contacts[i][prop]) {
      return "No such property";
    }
}
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:57
it just gets stuck in the while loop
while i and j are still on their first iteration
Cal-culator
@Cal-culator
Jan 09 2017 06:57
@Manish-Giri did you see the code?
grantknaver
@grantknaver
Jan 09 2017 06:57
why
barry01000010
@barry01000010
Jan 09 2017 06:57
@Manish-Giri as in hitting the enter? Sorry I am newbie :)
Manish Giri
@Manish-Giri
Jan 09 2017 06:57
@Cal-culator looking at it now
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:57
becuase your while loop is in the for loop
grantknaver
@grantknaver
Jan 09 2017 06:57
if it doesn't meet the criteria of the while loop wouldn't it move onto the next index
Manish Giri
@Manish-Giri
Jan 09 2017 06:58
@barry01000010 no, just a space, the spacebar
notice the space in the example they've used
barry01000010
@barry01000010
Jan 09 2017 06:58
@Manish-Giri ok :)
grantknaver
@grantknaver
Jan 09 2017 06:58
would an if statement work
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:58
no the while loop will keep loop waiting for str[i] to === consonant[j]
Greg Duncan
@GregatGit
Jan 09 2017 06:58
@Cal-culator are you doing this in chrome?
Cal-culator
@Cal-culator
Jan 09 2017 06:58
@GregatGit safari
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:59
but they cant ever be equal if they never change
Cal-culator
@Cal-culator
Jan 09 2017 06:59
should i switch?
grantknaver
@grantknaver
Jan 09 2017 06:59
ah
ill do an if statement
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 06:59
yeah might be better
Pravin Shinde
@prawin007
Jan 09 2017 06:59
what is relative position in css?
barry01000010
@barry01000010
Jan 09 2017 07:00
@Manish-Giri Thaannkkss! it worked, its a miracle. Finally. been trying fiure it out for about a hour. shish! :)
grantknaver
@grantknaver
Jan 09 2017 07:00
I dont do a lot of while loops, just started. My mistake thank you
Manish Giri
@Manish-Giri
Jan 09 2017 07:00
@barry01000010 welcome
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:00
its a position that moves relative to its surrounding elements @prawin007
at leasts thats how i think of it
well its the same as a for loop really
if your for loop was confined to str[i] === consonant[j]
that would cause an infinite loop too
Alex
@Joshua-A-Smith
Jan 09 2017 07:03
function reusableFunction() {
  document.write("Hi World");
}

reusableFunction();
If this is wrong how can I output "Hi World" to the console?
grantknaver
@grantknaver
Jan 09 2017 07:03
really
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:03
your loops need an end point
Chris Wingler
@chriswingler
Jan 09 2017 07:03
is there any way to use a debugger on the challenges?
Greg Duncan
@GregatGit
Jan 09 2017 07:03
@Cal-culator no - you tried using
try {
    adddlert("Welcome guest!");
}
catch(err) {
    document.getElementById("demo").innerHTML = err.message;
}
Manish Giri
@Manish-Giri
Jan 09 2017 07:03
@Cal-culator I do all my AJAX with jQuery, so not sure if there's an error with the pure js version, but it looks like this code is never reached/executed
 xml.onreadystatechange = function() {
    console.log("inside");
  if (xml.readyState==4 && xml.status==200){
    console.log(xml.responseText);
    var data=JSON.parse(xml.responseText);

    update(articles);
  }

  xml.open("GET", url);
  xml.send();
};
grantknaver
@grantknaver
Jan 09 2017 07:03
isn't that what i < str.length is for
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:03
and if that end point is a comparison that will never happen
its gonna be infinite
Manish Giri
@Manish-Giri
Jan 09 2017 07:03
the console.log("inside") never executes.
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:04
yes it is
Manish Giri
@Manish-Giri
Jan 09 2017 07:04
@Cal-culator
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:04
but thats not what you did in your while loop
Alex
@Joshua-A-Smith
Jan 09 2017 07:04
Nvmin I got it Now
Manish Giri
@Manish-Giri
Jan 09 2017 07:04
@Joshua-A-Smith for logging to console, use console.log(...)
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:04
you did str[i] === consonant[j]
Cal-culator
@Cal-culator
Jan 09 2017 07:04
@GregatGit I don't quite understand what you mean
@Manish-Giri Yeah. But I don't know how to fix it
grantknaver
@grantknaver
Jan 09 2017 07:05
ya know, but my for loops did have an end point let me post code
unction translatePigLatin(str) {
    var lowercase = str.toLowerCase();
    var consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "x", "z", "w"];
    for (var i = 0; i < str.length; i++) {
        for (var j = 0; j < consonants.length; j++) {
            if (str[i] === consonants[j]) {
                console.log(str[i]);


            }
            if (str[0] != consonants[j]) {
                //alert(str[0]);
                console.log(str[0]);
            }
        }
    }
}

translatePigLatin("consonant");
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:05
yeah they werent a problem
grantknaver
@grantknaver
Jan 09 2017 07:05
so this should work?
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:06
you dont get a infinite loop warning now do you?
Greg Duncan
@GregatGit
Jan 09 2017 07:06
@Cal-culator you would havve to put it in your code - but it trys to run your code block and if it can't it catches the error http://www.w3schools.com/js/js_errors.asp
grantknaver
@grantknaver
Jan 09 2017 07:06
haven't tried yet Im scared to see lol
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:06
i dont see why it would
grantknaver
@grantknaver
Jan 09 2017 07:07
nope I don't. Thank God Almighty I am free at last :)
you are my new favoriate person :)
Cal-culator
@Cal-culator
Jan 09 2017 07:07
@GregatGit so nothings wrong with the API right?
grantknaver
@grantknaver
Jan 09 2017 07:07
*favorite
Greg Duncan
@GregatGit
Jan 09 2017 07:07
@Cal-culator the api looks good
HeebieGeeBee
@HeebieGeeBee
Jan 09 2017 07:07
lol
Cal-culator
@Cal-culator
Jan 09 2017 07:08
@GregatGit do you know why the state and status output 0?
Greg Duncan
@GregatGit
Jan 09 2017 07:08
@Cal-culator i use chrome - but chrome and codepen give you lots of CORS issues - using http and https together
@Cal-culator have you thought about doing it on github?
Cal-culator
@Cal-culator
Jan 09 2017 07:10
@GregatGit Not really.
Greg Duncan
@GregatGit
Jan 09 2017 07:10
</