These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Mar 2016
M. Matthews
@mmatthews1981
Mar 17 2016 00:01
hey guys. has anyone in here successfully implemented a minimax algorithm?
Stefan Gisi
@stgisi
Mar 17 2016 00:02
@UnlimiWorks I'm almost done with them though! Never gonna give up :)
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:02
@brainyfarm I had looked at your codepen work and it is pretty sleek and unique. where do you get all this stuff from?
@meredithmatthews which challenge are you talking about?
Eric Murta
@murtinha
Mar 17 2016 00:03
can someone please come to a private room to help me???
M. Matthews
@mmatthews1981
Mar 17 2016 00:04
@sidkrip I'm working on the tic tac toe project
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:04
@meredithmatthews havent reached it yet
@murtinha what is the problem you are having?
M. Matthews
@mmatthews1981
Mar 17 2016 00:04
@sidkrip it's the only thing standing between me and my frontend cert, and it's making me crazy
Eric Murta
@murtinha
Mar 17 2016 00:05
@sidkrip I'm struggling with seek and destroy this whole afternoon
Brendan Kinahan
@BKinahan
Mar 17 2016 00:06
@meredithmatthews my tic tac toe algorithm isn't based on minimax, but on the strategy list found on the wikipedia page about TTT
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:06
@meredithmatthews I can pretty much empathize how you are feeling right now
Eric Murta
@murtinha
Mar 17 2016 00:06
function destroyer(arr) {
  // Remove all the values
  var array=[];
  var arg=[];


  for(i=1;i<arguments.length;i++){
    arg[i]=arguments[i];
    array=arr.slice([arr,arg[i]].filter(function (){return arr.indexOf(arg[i])}));

  }
  return array;


}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Maddah Anass
@unlimiworks
Mar 17 2016 00:06
@stgisi That's the spirit !
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:06
@murtinha what is it returning?
M. Matthews
@mmatthews1981
Mar 17 2016 00:07
@sidkrip thanks :)
CamperBot
@camperbot
Mar 17 2016 00:07
meredithmatthews sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
api offline
Eric Murta
@murtinha
Mar 17 2016 00:08
@sidkrip [1, 2, 3, 1, 2, 3]
M. Matthews
@mmatthews1981
Mar 17 2016 00:08
@BKinahan can I take a look at your tic tac toe?
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:10
@murtinha I guess you are not filtering properly. Try reading the arguments object documentation again
Eric Murta
@murtinha
Mar 17 2016 00:11
@sidkrip I've tried to read it a thousand times
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:13
@murtinha you know what this does?
var args = Array.prototype.slice.call(arguments);
Eric Murta
@murtinha
Mar 17 2016 00:14
@sidkrip The problem is I read and read and I cant understand what its for
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:14
it creates an array out of your arguments.
your argument will generally have three arrays considering the inputs they have provided
Eric Murta
@murtinha
Mar 17 2016 00:15
@sidkrip hmm
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:15
this statement will make a single array combining the contents of all the array provided as the argument
Brendan Kinahan
@BKinahan
Mar 17 2016 00:15
@meredithmatthews Sure. I haven't implemented the interactive website parts but the logic/algorithm is here: http://pastebin.com/3Tr4xvph
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:16
so {[1, 2, 3, 1, 2, 3], 2, 3} becomes {1, 2, 3, 1, 2, 3, 2, 3}
@murtinha
following me?
Brendan Kinahan
@BKinahan
Mar 17 2016 00:16
@meredithmatthews where you see comments like // #0, those (loosely) refer to the numbered strategy list on the wikipedia page I mentioned.
Eric Murta
@murtinha
Mar 17 2016 00:16
@sidkrip yeap
@sidkrip actually it became [[1,2,3,1,2,3],2,3]
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:18
@murtinha wait a second. this is a very messy problem. This is just a very important statement for now. We will get back to it later.
after it you splice the args argument from 0, 1
and then filter it. Here is the code which I have no idea how I worked out:
var args = Array.prototype.slice.call(arguments);
  args.splice(0,1);
  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  });
Eric Murta
@murtinha
Mar 17 2016 00:21
@sidkrip I kinda get it... but Im still confused with filter
Collin
@collinferry
Mar 17 2016 00:21
Here's a riddle if anyone has a clue or a resource. I need to return every possible 3-character permutation from an array of integers of varied length. I've found plenty of solutions for returning all the permutations of the array, but no length specific ways. Any ideas?
Eric Murta
@murtinha
Mar 17 2016 00:21
@sidkrip I'm gonna keep trying, thanks a lot man
Pete
@petegarvin1
Mar 17 2016 00:22
evening all
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:22
@murtinha filter is easier to understand. you see, in the above coe, args=[1, 2, 3, 1, 2, 3]
M. Matthews
@mmatthews1981
Mar 17 2016 00:22
@BKinahan thanks!
Eric Murta
@murtinha
Mar 17 2016 00:22
@sidkrip I dont understand the arguments you pass, like, whats element?
@sidkrip element=arr=[1,2,3,1,2,3] ?
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:23
@murtinha element is just a variable which will assume the values of an array which will be filtered through
Pete
@petegarvin1
Mar 17 2016 00:23
can anyone help me find out why this code doesn't return true for the test case? As far as I can see, the total isn't adding up past 1... but if i check each incidence of collection ([0], 1, [2] etc) they return true, so not sure why...
function every(collection, pre) {

  var total = 0;

  for (var i = 0; i < collection.length; i++) {
   if (collection[i].hasOwnProperty(pre)) {
     total ++;
   } 

   if (total == collection.length) {
     return true;
   }
    else {
     return false;
  }
 }
}

every([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Ray S
@hjcodes182
Mar 17 2016 00:23
Newbie here. Why is it better to use CSS instead of inline style?
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:23
have you seen this variation of for loop: for(var i in array)? this is i traversing the whole array elements one by one
@murtinha
Eric Murta
@murtinha
Mar 17 2016 00:24
@sidkrip I think I'm using indexOf the wrong way them, I was using it like [1,2,3,1,2,3]indexOf(1)
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:24
yep
you forgot the dot operator and except that, it is pretty much correct
Daniel Adams
@MisterMan123
Mar 17 2016 00:25
Hey all, was wondering if someone could look at a bit of my regexp for the phone number bonfire. Why is it that this snippet here: ^1\s(\d{3})\s\d{3}-\d{4}$ is not capturing "1 (555) 555-5555"?
Eric Murta
@murtinha
Mar 17 2016 00:25
@sidkrip I can deal with loops well I think, I just get confused with the returns on filter functions. This one will return true if they dont match?
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:26
it will return the value if it doesnt find a match for it
Eric Murta
@murtinha
Mar 17 2016 00:26
@sidkrip thats ver smart, I was trying to find a way to do it, didnt think of === -1. I was trying to use NOT or something like that but I never worked, because these are the elements that you wanna keep so its easier to deal with
@sidkrip thanks for the pacience man!!!
CamperBot
@camperbot
Mar 17 2016 00:26
murtinha sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
api offline
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:27
well, that's what happens when you look at other people's code
try this www.freecodecamp/<profile name> for example www.freecodecamp/sidkrip
you are welcome :)
Daniel Adams
@MisterMan123
Mar 17 2016 00:27
Never mind, didn't realize parentheses need escapes in regex
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:28
@murtinha forgot to add ".com" in the end before the slash
Eric Murta
@murtinha
Mar 17 2016 00:28
@sidkrip I know it helps a lot but I just like to look at them after doing my own
ctal
@ctal
Mar 17 2016 00:28
@hjcodes182 By using CSS instead of inline styles, you can separate your webpage's content (HTML) from its styling/formatting (CSS). This makes it easier to read your code, and also allows you to reuse CSS for multiple elements instead of adding repeated inline styles. This stack overview question does a pretty good job of giving more info: https://stackoverflow.com/questions/3142710/inline-styles-vs-classes
Ray S
@hjcodes182
Mar 17 2016 00:28
@ctal Thanks
CamperBot
@camperbot
Mar 17 2016 00:28
hjcodes182 sends brownie points to @ctal :sparkles: :thumbsup: :sparkles:
Eric Murta
@murtinha
Mar 17 2016 00:29
@sidkrip I'm gonna add you on facebook hahaha
CamperBot
@camperbot
Mar 17 2016 00:29
:star: 292 | @ctal | http://www.freecodecamp.com/ctal
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:29
@MisterMan123 almost every character needs to be escaped. You can work without it as well in some cases but escaping is safe.
@murtinha sure :)
Pete
@petegarvin1
Mar 17 2016 00:33
can anyone help me with the everything be true bonfire?
CamperBot
@camperbot
Mar 17 2016 00:33
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Sidharth Kriplani
@sidkrip
Mar 17 2016 00:33
@Spacecamel100 sure paste your code
Ricco
@riccochapa
Mar 17 2016 00:35
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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

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

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



// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");
I'm stuck. I can pass the if statement or the else if statements but not both. I know I need to use hasOwnProperty but I don't know how. Can anyone assist?
Pete
@petegarvin1
Mar 17 2016 00:38
@sidkrip not sure why how to make the below cover all test cases where the property exists, but the value of it is either an empty string, null, undefined of NaN:
function every(collection, pre) {

  var total = 0;

  for (var i = 0; i < collection.length; i++) {
   if (collection[i].hasOwnProperty(pre) && collection[i][pre] !== "" ) {
     total++;
   } 
  }

   if (total == collection.length) {
     return true;
   }
    else {
     return false;
  }

}

every([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
feel like I'm very close, just need to edit the end of my first if to encompass all the undefined values possible
Danny McCollins
@dmccollins
Mar 17 2016 00:46
Hi all. Will some one tell me if I’m off to a good start here? Currently working on Profile Lookup, this is what I’ve got so far:
for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) ) {
      return contacts[i][prop];
    }      
  }
Ricco
@riccochapa
Mar 17 2016 00:47
hi @dmccollins that is what I currently have. ```
  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].firstName !== firstName) {return "No such contact";}

              else if (prop !== contacts[i].hasOwnProperty(prop)) {return "No such property";}
I got the if statements working or the else if. but not both :(
Danny McCollins
@dmccollins
Mar 17 2016 00:48
Same here.
Juwdohr
@Juwdohr
Mar 17 2016 00:49
on the wiki one, trying to figure out how to change the magnifying glass to a input text box.
Danny McCollins
@dmccollins
Mar 17 2016 00:49
I’m a little confused about how return is supposed to work in this case. It seems like that’s the thing tripping both of us up.
Ricco
@riccochapa
Mar 17 2016 00:50
agreed. I feel like I need to change something to a variable to work around that, but my brain won't let me figure it out.
Matthew Shaver
@RazzaFrazza
Mar 17 2016 00:52
Can someone tell me why this doesn't do anything at all...
function lookUp(firstName, prop){
// Only change code below this line
if(firstName == contacts[firstName]){
if(prop == contacts[prop]) {
return contacts[firstName][prop];
}
else {
return "No such contact";
}
}
bitgrower
@bitgrower
Mar 17 2016 00:53
@riccochapa -- try just checking for firstName in one if , then do the .hasOwnProperty check ... you cannot determine no such contact until you've checked ALL the members of the array (which means you cannot "return" that error message from within your loop)
Andrew Charlebois
@andrewchar
Mar 17 2016 00:53
This message was deleted
gezz bit, pop out of no where
Juwdohr
@Juwdohr
Mar 17 2016 00:54
Does anyone know how to change an icon (once clicked on) into a input box?
bitgrower
@bitgrower
Mar 17 2016 00:55
sorry @Jarvis-327 ... try the frontend room, maybe ?
Matthew Shaver
@RazzaFrazza
Mar 17 2016 00:55
@Jarvis-327 That should be easy to do with jQuery.
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 00:55
Hey I have been working on the counting cards challenge for a while may someone please help me?
bitgrower
@bitgrower
Mar 17 2016 00:55
@RazzaFrazza ...
help profile lookup
CamperBot
@camperbot
Mar 17 2016 00:55

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName 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"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Danny McCollins
@dmccollins
Mar 17 2016 00:55
@bitgrower sorry about the other day. Was feeling frustrated about life stuff + not being able to figure out a problem. My apologies.
Andrew Charlebois
@andrewchar
Mar 17 2016 00:55
@JoshuaJerrick post code
bitgrower
@bitgrower
Mar 17 2016 00:56
apologies accepted ... code can be that way ... :)
Matthew Shaver
@RazzaFrazza
Mar 17 2016 00:56
@bitgrower that doesn't really help me... I already know what it's asking me to do. I don
't understand what my code is currently doing because it just shows a black screen
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 00:56
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++;
  return "5 Bet";
  break;


  // 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');
Juwdohr
@Juwdohr
Mar 17 2016 00:56
@bitgrower tried there. no response.
Andrew Charlebois
@andrewchar
Mar 17 2016 00:57
@JoshuaJerrick whats wrong?
Ricco
@riccochapa
Mar 17 2016 00:57
@bitgrower I'm trying to wrap my head around what you are saying... my mind is currently buffering...
bitgrower
@bitgrower
Mar 17 2016 00:57
@RazzaFrazza -- I am emphasizing those instructions because the key is RIGHT in the very first line of the instructions ... wouldn't you agree, @dmccollins ... ?
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 00:57
It just won't work
Andrew Charlebois
@andrewchar
Mar 17 2016 00:58
@JoshuaJerrick your not done yet
@JoshuaJerrick there are more cards then just 2 to 6
Matthew Shaver
@RazzaFrazza
Mar 17 2016 00:58
I know it's an array that's why I'm trying to access the array using bracket notation. Is it necessary to use a loop versus just simple bracket notation?
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 00:58
ok let me make them and I will post it
bitgrower
@bitgrower
Mar 17 2016 00:58
...because you had that problem y'day, as I recall -- I didn't realize there was an easier way to point out the "secret" that may people miss ... which is in determining WHAT kind of data structure you are using, and adapt your data access (aka addressing) appropriately ...
Danny McCollins
@dmccollins
Mar 17 2016 00:58
@bitgrower most definitely
Andrew Charlebois
@andrewchar
Mar 17 2016 00:58
@JoshuaJerrick you'll need to move your count as well\
bitgrower
@bitgrower
Mar 17 2016 00:59
@RazzaFrazza -- brackets can be used for both ARRAY indexes, as well as for OBJECT access ... you need to use BOTH
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 00:59
where do I move my count statement
bitgrower
@bitgrower
Mar 17 2016 00:59
so ... walk down the data structure ... you have an ARRAY ... of ... ? of OBJECTS ...
Andrew Charlebois
@andrewchar
Mar 17 2016 01:00
@JoshuaJerrick inside your function
bitgrower
@bitgrower
Mar 17 2016 01:00
so you can access the value of any array property via myvarname[arrayIndex][propname]
Andrew Charlebois
@andrewchar
Mar 17 2016 01:00
no nvm im wrong
you can keep the count as it is. but for your switch, you need to add all cases
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 01:00
Thanks @andrewchar
CamperBot
@camperbot
Mar 17 2016 01:00
joshuajerrick sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
Matthew Shaver
@RazzaFrazza
Mar 17 2016 01:00
@bitgrower gotcha, thanks for that info. :)
CamperBot
@camperbot
Mar 17 2016 01:00
razzafrazza sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 361 | @andrewchar | http://www.freecodecamp.com/andrewchar
:star: 877 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 17 2016 01:01
...now, it does get a little more interesting when the value you are accessing is an array -- but then you just pop another index onto it ...
Matthew Shaver
@RazzaFrazza
Mar 17 2016 01:02
@Jarvis-327 You can use a jquery replaceWith function inside of a jQuery click event to do what you're trying to do.
bitgrower
@bitgrower
Mar 17 2016 01:02
it gets VERY helpful when getting into the challenges with objects and arrays and mixtures (and JSON) to FIRST look at the data structure you have ... this will ALSO help you when you get to the front-end projects where you are making calls to 3rd party websites and getting JSON in return ...
joyam09
@joyam09
Mar 17 2016 01:04
what am i missing in my code for quoting strings with single quotesvar myStr = "<a href=\"http://'www.example.com' 'target=''_blank\''>Link</a>";
bitgrower
@bitgrower
Mar 17 2016 01:07
got one after the 2nd equals sign you need to fix ... :)
Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:07
5 equal signs is better
bitgrower
@bitgrower
Mar 17 2016 01:08
you also have a spare single quote
Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:08
the more equal signs the more precise the comparison
bitgrower
@bitgrower
Mar 17 2016 01:08
LOL @Jordanmeyer89 ... 5?!?
Ezra Keddell
@ezy
Mar 17 2016 01:08
Having a strange output from my for loop for Caesar's Cipher. Out put is 'F8EEC5DECAM6' rather than 'FREE CODE CAMP'
Any ideas why some are shifting correctly but not others??
joyam09
@joyam09
Mar 17 2016 01:09
it's still not working
bitgrower
@bitgrower
Mar 17 2016 01:09
yup ... you need to bound your characters by upper and lower SIMULTANEOUSLY
but it would also help to see your code -- then the advice can be more specific
--and you need to pass thru any non-alphas
Ezra Keddell
@ezy
Mar 17 2016 01:10
function rot13(str) { // LBH QVQ VG!
  var result = '';
  var charcode;

  for (i = 0; i < str.length; i++) {
    charcode = (str[i].charCodeAt() - 13);
    result += String.fromCharCode(charcode);
  }
  console.log(result);

  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
bitgrower
@bitgrower
Mar 17 2016 01:10
right now you seem to be throwing them away (not handling them)
Ezra Keddell
@ezy
Mar 17 2016 01:11
Cheers bitgrower. So use a toUpperCase() and then regex the spaces etc?
bitgrower
@bitgrower
Mar 17 2016 01:11
so ... what letter is E-13 ?
no -- the test cases are all uppercase ...
Ezra Keddell
@ezy
Mar 17 2016 01:12
:facepalm: It's 8...
bitgrower
@bitgrower
Mar 17 2016 01:12
think you don't have to worry about lower/upper case at all ...
hmmm funny how that works ... how ya gonna fix it ?
bitgrower @bitgrower congratulates, thanks @ezy for "researching" ... :)
CamperBot
@camperbot
Mar 17 2016 01:12
bitgrower sends brownie points to @ezy :sparkles: :thumbsup: :sparkles:
:star: 96 | @ezy | http://www.freecodecamp.com/ezy
Juwdohr
@Juwdohr
Mar 17 2016 01:13
@RazzaFrazza anywhere I can see an example of that code? thank you for your help
CamperBot
@camperbot
Mar 17 2016 01:13
jarvis-327 sends brownie points to @razzafrazza :sparkles: :thumbsup: :sparkles:
:star: 274 | @razzafrazza | http://www.freecodecamp.com/razzafrazza
Ezra Keddell
@ezy
Mar 17 2016 01:13
@bitgrower suppose I'm going to have to limit the range of the charCodeAt in a custom array...
dkennell
@dkennell
Mar 17 2016 01:14
Hey, everyone. I'm having trouble with the 'Title Case a Sentence' algorithm challenge. The point is just to capitalize the first letter of every word in a string. My code thus far:
function titleCase(str) {
  var splitString = str.split(" ");
  var upCaseWords = [];
  for (i = 0; i < splitString.length + 1; i++) {
    upCaseWords.push(splitString[i].charAt(0).toUpperCase + splitString[i].slice(1));
  }
  return upCaseWords.join(" ");
}

titleCase("I'm a little tea pot");
bitgrower
@bitgrower
Mar 17 2016 01:14
and @ezy - no need to worry about regex either ... you know what range the character codes are ... just add anything which doesn't fall within that character code range to your string ...
@ezy -- shouldn't need to ...
dkennell
@dkennell
Mar 17 2016 01:15
I keep getting the following type error: 'cannot read property "charAt" ofundefined'
joyam09
@joyam09
Mar 17 2016 01:15
Quoting Strings with Single Quotes. can anyone tell me what's wrong with my code var myStr = "<a href=\"http://www.example.com\" target='_blank'>Link</a>";
bitgrower
@bitgrower
Mar 17 2016 01:16
if ( myChar >= 'A'.charCodeAt() && myChar <= 'Z'.charCodeAt() ) <-- I think that should work ...
This message was deleted
This message was deleted
Ezra Keddell
@ezy
Mar 17 2016 01:17
@bitgrower thanks for the help :)
gloriousjob
@gloriousjob
Mar 17 2016 01:17
@dkennell Why are you doing length + 1?
bitgrower
@bitgrower
Mar 17 2016 01:17
you're welcome ... happy coding!
gloriousjob
@gloriousjob
Mar 17 2016 01:18
help Quoting Strings with Single Quotes
CamperBot
@camperbot
Mar 17 2016 01:18

:point_right: challenge quoting strings with single quotes [wiki]

Quoting Strings with Single Quotes

String values in JavaScript may be written with single or double quotes, so long as you start and end with the same type of quote. Unlike some languages, single and double quotes are functionally identical in Javascript.

"This string has \"double quotes\" in it"

The value in using one or the other has to do with the need to escape quotes of the same type. If you have a string with many double quotes, this can be difficult to read and write. Instead, use single quotes:

'This string has "double quotes" in it. And "probably" lots of them.'

:pencil: read more about challenge quoting strings with single quotes on the FCC Wiki

dkennell
@dkennell
Mar 17 2016 01:18
@gloriousjob Oh, I guess it should be minus? I'm never sure when it comes to iterating.
Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:19
whats the deal with .reduce
don't get it
gloriousjob
@gloriousjob
Mar 17 2016 01:19
@dkennell Should just be up to the length
Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:19
can't you just add them all
dkennell
@dkennell
Mar 17 2016 01:19
@bitgrower Oh cool, interesting. I'll give it a shot.
gloriousjob
@gloriousjob
Mar 17 2016 01:20
@dkennell like an array with [0, 1] is length 2 so you want to run as long as the var is less than 2
dkennell
@dkennell
Mar 17 2016 01:20
@gloriousjob But the length is one longer than the maximum index, right? Since we start counting at zero?
gloriousjob
@gloriousjob
Mar 17 2016 01:20
array[0] = 0; array1 =1; what would array2 be?
Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:20
camperbot what is array.reduce
help array.reduce
CamperBot
@camperbot
Mar 17 2016 01:21
no wiki entry for: arrayreduce
Chris Dalton
@manwithgills
Mar 17 2016 01:21

I am working on the Chunky Monkey Bonfire. I am stumped. I searched and found the solution but do not really understand the logic behind it. I understand the loop, I understand the push method. I guess I am still confused a bit by the slice. Here is the line I am referring to:

 temp.push(arr.slice(i, i += size));

why did the author use i+=size?

Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:21
help reduce array
CamperBot
@camperbot
Mar 17 2016 01:21
no wiki entry for: reduce array
Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:21
help me
CamperBot
@camperbot
Mar 17 2016 01:21

:point_right: adding environment variables [wiki]

In Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

:pencil: read more about adding environment variables on the FCC Wiki

Jordan Meyer
@Jordanmeyer89
Mar 17 2016 01:21
keeps teasing me
gloriousjob
@gloriousjob
Mar 17 2016 01:21
@dkennell Right, so you don't want to get the index of the value at length since we're starting at 0
@dkennell Are you following the array example?
joyam09
@joyam09
Mar 17 2016 01:23
i did what they told me and i still didn't get the green checks
var myStr = "<a href=\http://www.example.com\" target='"_blank'">Link</a>";
gloriousjob
@gloriousjob
Mar 17 2016 01:23
@joyam09 Your string needs to be in single quotes but yours is in double
dkennell
@dkennell
Mar 17 2016 01:24
@gloriousjob Hm, not quite. If we're iterating with an int i, the max index is always one less than the length of the array, right? .length just counts the numbers of values in an array, as far as I understand.
gloriousjob
@gloriousjob
Mar 17 2016 01:25
Right, so array = [0,1]
What's the length of that?
bitgrower
@bitgrower
Mar 17 2016 01:25
why are you escaping the h in http, @joyam09
gloriousjob
@gloriousjob
Mar 17 2016 01:25
Then, how does the for loop go through it?
Run through each iteration if you need to
The loop stops when the exit condition is met
So in your case, it would do i = 0, i = 1, i = 2... then i = 3 would break the condition because it wouldn't be less than length+1 (3)
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 01:27
So here is what I got for the counting cards challenge how do I do the rest ```
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++;
    return "5 Bet";
    break;
    case 7:
    case 8:
    case 9:
    return "0 Hold";
    break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
    count--;
    return "-5 Hold";
    break;
    case 3:
    case 7:
    case 'Q':
    case 8:
    case 'A':
    return "-1 Hold";
    break;
    case 2:
    case 'J':
    case 9:
    case 2:
    case 7:
    count++;
    return "1 Bet";
    break;
    case 3:
    case 2:
    case 'A':
    case 10:
    case 'K':
    count--;
    return "-1 Hold";
    break;
  }
  // 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');
dkennell
@dkennell
Mar 17 2016 01:28
@gloriousjob Wait, no, it would break on i = 2, because there are only indices 1 and 2.
@dkennell 0 and 1, I mean. Sorry
gloriousjob
@gloriousjob
Mar 17 2016 01:29
@dkennell well, the code's going to do what you tell it to do, not what you think it's doing. It's a hard lesson to learn :) Your concept is right on where it should break
@dkennell What's your condition? array.length + 1, right? In this case, array.length is 2 so it would break when (i < 3) is not met
dkennell
@dkennell
Mar 17 2016 01:30
@bitgrower So hey, I'm not quite sure how to use your code. It looks like it works for checking to see if a character is an uppercase letter, but not for checking to see if it's the first letter of a word, and capitalizing it.
gloriousjob
@gloriousjob
Mar 17 2016 01:30
@dkennell but 2 is less than 3 so that would run in the for loop
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 01:30
Does anyone have a suggestion about my code for counting cards challenge?
gloriousjob
@gloriousjob
Mar 17 2016 01:31
@JoshuaJerrick Why do you have repeated cases after the first three? Once it breaks, it doesn't look at the following cases
Chris Dalton
@manwithgills
Mar 17 2016 01:31
Good evening campers.
gloriousjob
@gloriousjob
Mar 17 2016 01:31
@JoshuaJerrick after the first three breaks
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 01:32
Delete the code after the first three break?
bitgrower
@bitgrower
Mar 17 2016 01:33
@dkennell -- the code I posted was for use with the Caesar's Cipher challenge
gloriousjob
@gloriousjob
Mar 17 2016 01:33
@JoshuaJerrick Probably won't solve your problem but I'm just saying that it's dead code (it'll never get to those lines)
Chris Dalton
@manwithgills
Mar 17 2016 01:33
Is there anyone familiar with the .slice combined with the .push for arrays?
gloriousjob
@gloriousjob
Mar 17 2016 01:33
@JoshuaJerrick I get the feeling that you might be thinking it'll keep going to the cases again, which it won't
bitgrower
@bitgrower
Mar 17 2016 01:34
I'm not even sure which challenge you've been working on, @dkennell ...
Andrew Charlebois
@andrewchar
Mar 17 2016 01:34
@JoshuaJerrick 1 case per card buddy
bitgrower
@bitgrower
Mar 17 2016 01:34
to do what, @manwithgills
dkennell
@dkennell
Mar 17 2016 01:34
@bitgrower It's the 'Title Case Sequence' algorithm problem.
gloriousjob
@gloriousjob
Mar 17 2016 01:35
@JoshuaJerrick Other thing is you're supposed to be keeping count, not hard coding values
dkennell
@dkennell
Mar 17 2016 01:35
@bitgrower Sorry, 'title case a sentence'
Chris Dalton
@manwithgills
Mar 17 2016 01:35
@bitgrower What I want to know is if I slice an array and push it to a new array does the index after or at the slice become index 0.
gloriousjob
@gloriousjob
Mar 17 2016 01:35
@dkennell Still not understanding the issue?
bitgrower
@bitgrower
Mar 17 2016 01:36
oh ... you want to know order of operation ?
dkennell
@dkennell
Mar 17 2016 01:36
@gloriousjob No, it's independent of the iteration issue.
Joshua Jerrick
@JoshuaJerrick
Mar 17 2016 01:36
@gloriousjob I had incremented them not hard coded the values
What do I do from there
bitgrower
@bitgrower
Mar 17 2016 01:36
myArray.slice().push() ... or myArray.push().slice() -- it will depend on how you write it, @manwithgills
if it's a new array, arrays ALWAYS start with index 0
dkennell
@dkennell
Mar 17 2016 01:37
This message was deleted
@gloriousjob It has something to do with my charAt method
Chris Dalton
@manwithgills
Mar 17 2016 01:38
@bitgrower the second example. push followed by slice. So once the slice occurs and is pushed to a new array the portion of the old array that was sliced no longer exists in the old array. Is this accurate?
bitgrower
@bitgrower
Mar 17 2016 01:38
@dkennell -- the things to know about Title Case are ...
  1. strings are immutable ... you can't go str.charAt(0).upperCase() and change str ...
gloriousjob
@gloriousjob
Mar 17 2016 01:38
@dkennell Well, that's issue one
bitgrower
@bitgrower
Mar 17 2016 01:39
  1. if you do myNewStr = str.charAt(0).upperCase() ... myNewStr will only contain 1 character ...
dkennell
@dkennell
Mar 17 2016 01:39
@bitgrower Oooooooh, I need to reaasign the variables
gloriousjob
@gloriousjob
Mar 17 2016 01:39
@dkennell I think the other issue is your uppercase needs parentheses since it's a method
Kevin Behlmaier
@KevinBehlmaier
Mar 17 2016 01:39
I dont know if anyone can help but im having trouble with Global scope and functions, just not really sure whats going on here.
gloriousjob
@gloriousjob
Mar 17 2016 01:40
@dkennell Yes, because what happens when you try to grab array2 and there's only 2 elements? It's going to be a non-string
Chris Dalton
@manwithgills
Mar 17 2016 01:40
@bitgrower in the example temp.push(arr.slice(i, i += size)); the slice occurs first because its in parenthesis. Once the slice is done it is pushed to the new array. Am I understanding the Order of Ops?
Federico Marcos
@marcosfede
Mar 17 2016 01:40
hi guys , is there anything similar in javascript to the python .get(x,default) method for objects/dictionaries?
how do I modify an object’s properties or set them to a default value if that property doesn’t exist in the object yet?
dkennell
@dkennell
Mar 17 2016 01:40
@gloriousjob I fixed the array. Same error
bitgrower
@bitgrower
Mar 17 2016 01:41
yeah, but temp is something different than arr ... that code doesn't really make sense ...
Andrew Charlebois
@andrewchar
Mar 17 2016 01:41
@KevinBehlmaier just need to declare your variables where they tell you to and set them to a certain value
bitgrower
@bitgrower
Mar 17 2016 01:41
@marcosfede -- look up prototype functions
gloriousjob
@gloriousjob
Mar 17 2016 01:41
@dkennell I just tested it in Codepen and it seems to work... not sure what's going on with your case
Chris Dalton
@manwithgills
Mar 17 2016 01:41
the temp was what the author called the array.
bitgrower
@bitgrower
Mar 17 2016 01:42
so are you doing chunky monkey ?
Kevin Behlmaier
@KevinBehlmaier
Mar 17 2016 01:42
exactly what i did. my global variable is outside the function and my local is inside.
Andrew Charlebois
@andrewchar
Mar 17 2016 01:43
@KevinBehlmaier code please
Kevin Behlmaier
@KevinBehlmaier
Mar 17 2016 01:43
var myGlobal ="10"; oopsGlobal ="5";
}

var myGlobal ="10";
function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal ="5";
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Andrew Charlebois
@andrewchar
Mar 17 2016 01:43
wheres your function
if you are setting a value of a number you dont need quotations
right now your setting the value to a string
bitgrower
@bitgrower
Mar 17 2016 01:44
@manwithgills -- I couldn't really tell you for sure -- you might want to try it out in this cool visualization tool (I need to send them a donation or something) ... pythontutor.com/javascript.html
Kevin Behlmaier
@KevinBehlmaier
Mar 17 2016 01:44
oh, excsuse me there
thanks for your time
Chris Dalton
@manwithgills
Mar 17 2016 01:44
@bitgrower yes
Rex Smith Jr.
@rsmith731
Mar 17 2016 01:45
does freecodecamp cover javascript libraries or just the javascript basics?
bitgrower
@bitgrower
Mar 17 2016 01:45

@KevinBehlmaier ... you can get cool syntax coloring like this ...

  1. type in, on one line, with nothing else: ```
  2. paste your code in
  3. add another line with just this on the line: ```

then shift-enter ... (if you are in edit mode, you may need to change the edit box back to chat mode -- icon on the upper right)

dkennell
@dkennell
Mar 17 2016 01:46
@gloriousjob I figured it out. And you were right about the toUpperCase, thanks for the help!
CamperBot
@camperbot
Mar 17 2016 01:46
dkennell sends brownie points to @gloriousjob :sparkles: :thumbsup: :sparkles:
:star: 326 | @gloriousjob | http://www.freecodecamp.com/gloriousjob
bitgrower
@bitgrower
Mar 17 2016 01:46
@rsmith731 -- front end -- some jQuery, some bootstrap
backend .. node.js ... not sure what else ...
gloriousjob
@gloriousjob
Mar 17 2016 01:46
@dkennell Glad you got it :D
bitgrower
@bitgrower
Mar 17 2016 01:48
I would say that if you get thru all the js challenges on the front end ... AND understand them, you'll be doing pretty well -- but they don't really cover constructors in depth, and I don't think they cover prototyping at all ...
Andrew Charlebois
@andrewchar
Mar 17 2016 01:48
javascript resource
merp
bitgrower
@bitgrower
Mar 17 2016 01:49
gotta say the magic word, @andrewchar (not please in this case) ... and js was right
like this
help js resource
Andrew Charlebois
@andrewchar
Mar 17 2016 01:49
This message was deleted
Rex Smith Jr.
@rsmith731
Mar 17 2016 01:49
@bitgrower oh ok gotcha! :+1:
bitgrower
@bitgrower
Mar 17 2016 01:50
help javascript resource
CamperBot
@camperbot
Mar 17 2016 01:50
no wiki entry for: javascript resource
bitgrower
@bitgrower
Mar 17 2016 01:50
dumb
Andrew Charlebois
@andrewchar
Mar 17 2016 01:50
help javascript
CamperBot
@camperbot
Mar 17 2016 01:50

:point_right: advantages and disadvantages of javascript [wiki]

Advantages & Disadvantages of JavaScript

Like all computer languages, JavaScript has certain advantages and disadvantages. Many of the pros and cons are related to being a client-side language.

:pencil: read more about advantages and disadvantages of javascript on the FCC Wiki

bitgrower
@bitgrower
Mar 17 2016 01:50
ALSO dumb -- imnsho
Andrew Charlebois
@andrewchar
Mar 17 2016 01:51
disadvantages?
bitgrower
@bitgrower
Mar 17 2016 01:51
yeah, like it's a language that was initially written in a few days ...
that's why you have experts writing things like "Javascript: The Good Parts"
Andrew Charlebois
@andrewchar
Mar 17 2016 01:52
hey theres that word again
security
bitgrower
@bitgrower
Mar 17 2016 01:55
hahahahahahaha yeah ...

some years ago I was sitting on a chat for Leo LaPorte's show and commented on people turning off javascript ... to which the response was ... "turn off js and you break the web" ...

...and THAT was before ES6 ... and a few other things ...

Zer0trip
@zer0trip
Mar 17 2016 02:04
help Access MultiDimensional Arrays With Indexes
CamperBot
@camperbot
Mar 17 2016 02:04
no wiki entry for: access multidimensional arrays with indexes
Zer0trip
@zer0trip
Mar 17 2016 02:04
I just do not understand this concept, the explanation in thr FCC lesson is way too vague
bitgrower
@bitgrower
Mar 17 2016 02:05
what are the challenges you've done just prior to that one, @SAdamsKY01 ?
Zer0trip
@zer0trip
Mar 17 2016 02:06
All of them up to that
I understand the other concepts.
dkennell
@dkennell
Mar 17 2016 02:06
Hey, so I'm looking at this code example for a min function in JS. I can't figure out what's going on in the third line of code here.
function arrayMin(arr) {
  return arr.reduce(function (p, v) {
    return ( p < v ? p : v );
  });
Rex Smith Jr.
@rsmith731
Mar 17 2016 02:06
does anyone know a good place (rather a book or youtube tutorial) to follow to learn angular or react….majority of the jobs i apply to ask for those two
bitgrower
@bitgrower
Mar 17 2016 02:07
@dkennell -- I don't think that's an FCC challenge ?
bitgrower
@bitgrower
Mar 17 2016 02:07
I'm not sure I've seen a ternary operator used in any FCC challenges
Josh Fisk
@JoshFisk
Mar 17 2016 02:07
@bitgrower It probably should be in one of them though
Dayne Wright
@daynewright
Mar 17 2016 02:08
@dkennell Think of it as a compact if statement
dkennell
@dkennell
Mar 17 2016 02:08
@bitgrower No, it's just a code example I'm using to understand the 'return largest numbers in an array' challenge.
Rex Smith Jr.
@rsmith731
Mar 17 2016 02:08
@JoshFisk thanks!
CamperBot
@camperbot
Mar 17 2016 02:08
rsmith731 sends brownie points to @joshfisk :sparkles: :thumbsup: :sparkles:
:star: 382 | @joshfisk | http://www.freecodecamp.com/joshfisk
Dayne Wright
@daynewright
Mar 17 2016 02:09
if( p < v) { return p; } else { return v; }
bitgrower
@bitgrower
Mar 17 2016 02:09

oh man ... have you done the section on functional programming , @dkennell ..

...lol no need to think of it as .. it IS a compact if statement ... :)

dkennell
@dkennell
Mar 17 2016 02:09
@Daynewr @bitgrower Ooooh, I know what you all are talking about, I learned this when I was learning ruby. I've got it now, thanks!
CamperBot
@camperbot
Mar 17 2016 02:09
dkennell sends brownie points to @daynewr and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 317 | @daynewr | http://www.freecodecamp.com/daynewr
:star: 878 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 17 2016 02:09
yeah, ternary operators are in a lot of languages ...
samamsam
@samsamam
Mar 17 2016 02:10
Hi Coders I am getting a weird error one output is displayed but other do not satisfy the requirements.
here is my code help would be appreciated
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
Its from Using Objects for Lookups
bitgrower
@bitgrower
Mar 17 2016 02:12
what have you changed in the provided code, @samsamam ?
samamsam
@samsamam
Mar 17 2016 02:13
I changed from switch case to object form @bitgrower
bitgrower
@bitgrower
Mar 17 2016 02:13
ahh .... I see ... you put the result in there ... hmmm .. okay... that's the HARD WAY of doing it ...
I think there's an example in the challenge instructions ?
Dayne Wright
@daynewright
Mar 17 2016 02:13
I don’t think you can have an assignment in an object like that..can you?
bitgrower
@bitgrower
Mar 17 2016 02:14
@Daynewr -- it's an expression ... I'm not sure what it would do, but I think you can put expressions nearly anywhere ...
Dayne Wright
@daynewright
Mar 17 2016 02:14
hmmm..interesting
samamsam
@samsamam
Mar 17 2016 02:14
I followed the instruction but it has no variable like in this example which requires result
bitgrower
@bitgrower
Mar 17 2016 02:15
yeah, welcome to the world of not very much interpreter checking ... LOL ... means get REALLY good at js debugging .. :)
help using objects for lookup
CamperBot
@camperbot
Mar 17 2016 02:15

:point_right: challenge using objects for lookups [wiki]

Challenge: Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

:pencil: read more about challenge using objects for lookups on the FCC Wiki

bitgrower
@bitgrower
Mar 17 2016 02:15
so ... that's a very nice little example ...
samamsam
@samsamam
Mar 17 2016 02:15
yes i followed this
Eric Stermer
@estermer
Mar 17 2016 02:15
I was wondering if anyone can look at my code?
samamsam
@samsamam
Mar 17 2016 02:16
but here there is no result variable example
Eric Stermer
@estermer
Mar 17 2016 02:16

function destroyer(arr) {
// Remove all the values

var newArr = arr.filter(function (value, index, array){
for (var i = 1; i < arguments.length; i++){
return value == arguments[i];
}
});

return newArr;

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Andrew Charlebois
@andrewchar
Mar 17 2016 02:16
This message was deleted
bitgrower
@bitgrower
Mar 17 2016 02:16
you can use any string to "index" into an object ... those values ... 1,2,3 etc are called properties, properties of the object, also known as "keys"
Eric Stermer
@estermer
Mar 17 2016 02:16
for some reason this keeps giving me a blank array
Matthew Shaver
@RazzaFrazza
Mar 17 2016 02:16

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

for (var i = 0; i < contacts.length; i++) {
if(contacts[i].hasOwnProperty(firstName) && contacts[i][firstName].hasOwnProperty(prop)) {
return contacts[i][firstName][prop];
}

}

// Only change code above this line
}```

bitgrower
@bitgrower
Mar 17 2016 02:16
all you need to do to get the value of an object's property is to use the property as an index...
Eric Stermer
@estermer
Mar 17 2016 02:17
@andrewchar thanks for your help
CamperBot
@camperbot
Mar 17 2016 02:17
estermer sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 362 | @andrewchar | http://www.freecodecamp.com/andrewchar
bitgrower
@bitgrower
Mar 17 2016 02:17
@estermer -- you need to understand the arguments object ...
Eric Stermer
@estermer
Mar 17 2016 02:17
@bitgrower i kept looking over it but I am not sure what I am missing
i am trying to compare the value in the array with the first and second argument with the for loop
Mike Short
@mikeshort10
Mar 17 2016 02:18
Question for anyone that's out there. I had written a code where I had an if-else statement. At first the condition for if was true. However, after adjusting the else statement, the if condition became false and the else was true. Any ideas as to why? I thought if-else read from top to bottom
MikeBeers
@MikeBeers
Mar 17 2016 02:19
when I comment out my return on my else statement I get part of my code to work. When I uncomment it parts that worked before now no longer pass.
function fearNotLetter(str) {
  var result = [];
  var newArr = str.split("");
  var numbArr = [];



  for (var i = 0; i < newArr.length; i++) {
    numbArr.push(String.charCodeAt(newArr[i]));
  } //for
  var index = numbArr[0]-1 ;




  for (var j = 0; j < numbArr.length; j++) {

     if (numbArr[j] - numbArr[j-1]  != 1) {
       result = String.fromCharCode(numbArr[j] - 1);
      //result = numbArr[j] - 1;

     } else  {
       result = undefined;
     }

 } 



  console.log (result);



} 
fearNotLetter("abce");
jw1540
@jw1540
Mar 17 2016 02:19
hey guys, i'm doing the intermediate algorithm challenges, and finding them incredibly difficult. what level would these equate to on a professional scale, would you say?
MikeBeers
@MikeBeers
Mar 17 2016 02:20
looking for a little push in the right direction
bitgrower
@bitgrower
Mar 17 2016 02:20
here's what you need to know ...
  1. you can pass any number of parameters to a javascript function (99% true, true for our purposes)
  2. you can have "named" parameters ... if someone passed 3 parameters to a function, but in the code defining the function, only one is named, you have to find the other objects...
  3. you use the arguments object, an array like object, to do this ...
  4. to make good use of values in the arguments object, it makes sense to create named variables...
  5. AND ... whenever you open a new scope in js (call a new function) -- the arguments object CHANGES
Mas hary
@mas212
Mar 17 2016 02:21
Truncate a string::
truncate("A-tisket a-tasket A green and yellow basket", 11) should return "A-tisket...". ??
@bitgrower
truncate("A-tisket a-tasket A green and yellow basket", 11) should return "A-tisket...". ?
bitgrower
@bitgrower
Mar 17 2016 02:22
folks .. without seeing your code (preferably formatted) and without knowing the name of the challenge, it can be hard to help you ...
Andrew Charlebois
@andrewchar
Mar 17 2016 02:22
@jw1540 0.1 out of 10
Dayne Wright
@daynewright
Mar 17 2016 02:23
@bitgrower what he said.. :)
bitgrower
@bitgrower
Mar 17 2016 02:23

:point_up: March 16, 2016 7:18 PM

questions like this ... there's just no universal answer to -- gotta see the code ... and also know what you are trying to do ...

jw1540
@jw1540
Mar 17 2016 02:23
@andrewchar so these are far easier than what you would anticipate encountering in a professional environment?
Eric Stermer
@estermer
Mar 17 2016 02:23
@bitgrower so if i get this straight, when I call the arguments[i] in the function callback in the filter, it is not calling the arguments from the destroyer function because it is in a new scope?
Andrew Charlebois
@andrewchar
Mar 17 2016 02:23
@jw1540 for example, face recognition algorithm's.
bitgrower
@bitgrower
Mar 17 2016 02:23
@jw1540 -- yes, they are easier than what you would expect to see in a professional environment ...
@Daynewr ... ? sorry, lost the context ?
jw1540
@jw1540
Mar 17 2016 02:24
@bitgrower @andrewchar dang, is it worrying that i'm finding them really hard? or just part of the process?
Mas hary
@mas212
Mar 17 2016 02:24

@bitgrower
function truncate(str, num) {
if(num >= str.length){
return str;
}
if(num !== 0){
return "";
}
if(num <= 3){
newStr = str.slice(0, num);
newStr += "...";
return newStr;
}
newStr = str.slice(0, num-3);
newStr += "...";
return newStr;
}

truncate("A-tisket a-tasket A green and yellow basket", 11);

Eric Stermer
@estermer
Mar 17 2016 02:24
@bitgrower and it would be better also to just create a new array of the arguments to use in the comparison?
Andrew Charlebois
@andrewchar
Mar 17 2016 02:24
@jw1540 we all find it hard
bitgrower
@bitgrower
Mar 17 2016 02:24
learning to program is hard ... persistence pays off ...
Dayne Wright
@daynewright
Mar 17 2016 02:24
@andrewchar @jw1540 I think saying .01 out of 10 is a little extreme. Don’t get discouraged by that.
Andrew Charlebois
@andrewchar
Mar 17 2016 02:24
@jw1540 im doing the same, struggling. but its part of learning i guess
Eric Stermer
@estermer
Mar 17 2016 02:25
@bitgrower thanks again for your help
CamperBot
@camperbot
Mar 17 2016 02:25
estermer sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 879 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 17 2016 02:25
you'll beat your head against something ... and you may even have coded a solution ... and then a light comes on ... and you go ... OHHHHHh!!!!!!
Andrew Charlebois
@andrewchar
Mar 17 2016 02:25
@jw1540 tell me something, when is the last time you had to learn a language
bitgrower
@bitgrower
Mar 17 2016 02:25
it's like learning any foreign language ... in fact, in some ways easier ... because software is consistent ... LOL ...
Dayne Wright
@daynewright
Mar 17 2016 02:26

@bitgrower I was agreeing with this:

folks .. without seeing your code (preferably formatted) and without knowing the name of the challenge, it can be hard to help you ...

jw1540
@jw1540
Mar 17 2016 02:26
i've worked as a junior developer mostly in PHP/Laravel MVC frameworks, but I'm finding JS much harder. Not sure if that's the case for most people - I'm also self taught in PHP but found that surprisingly easier
bitgrower
@bitgrower
Mar 17 2016 02:26
ahhh .. okay ...
MikeBeers
@MikeBeers
Mar 17 2016 02:26
Looking for help with missing letters
jw1540
@jw1540
Mar 17 2016 02:27
I'm mostly learning JS so that I can apply it to learning AngularJS and React etc but the learning curve is feeling steep & i'm looking at hints more and more often
bitgrower
@bitgrower
Mar 17 2016 02:27
  1. post formatted code
  2. post challenge name
MikeBeers
@MikeBeers
Mar 17 2016 02:27
function fearNotLetter(str) {
  var result = [];
  var newArr = str.split("");
  var numbArr = [];



  for (var i = 0; i < newArr.length; i++) {
    numbArr.push(String.charCodeAt(newArr[i]));
  } //for
  var index = numbArr[0]-1 ;




  for (var j = 0; j < numbArr.length; j++) {

     if (numbArr[j] - numbArr[j-1]  != 1) {
       result = String.fromCharCode(numbArr[j] - 1);
      //result = numbArr[j] - 1;

     } else  {
       result = undefined;
     }

 } 



  return result;



} 
fearNotLetter("abcdefghjklmno");
bitgrower
@bitgrower
Mar 17 2016 02:27
awesome ... thank you @MikeBeers
CamperBot
@camperbot
Mar 17 2016 02:27
bitgrower sends brownie points to @mikebeers :sparkles: :thumbsup: :sparkles:
:star: 283 | @mikebeers | http://www.freecodecamp.com/mikebeers
bitgrower
@bitgrower
Mar 17 2016 02:28
is this before or after Caesar's Cipher ?
Andrew Charlebois
@andrewchar
Mar 17 2016 02:28
@jw1540 dont take my comment to literally, ive only been learning to code for 3 months
"what do i know, right?" :P
MikeBeers
@MikeBeers
Mar 17 2016 02:29
when i mment out the undined portion i get the correct letter
@bitgrower after
jw1540
@jw1540
Mar 17 2016 02:29
@andrewchar haha, no no don't worry! i appreciate the discussion/information :)
@andrewchar I just hope the learning curve is similar for all, you know? so i feel like it is a genuine curve and not poor understanding :P
bitgrower
@bitgrower
Mar 17 2016 02:31
hmmm .. I'm not sure you need all those String calls, @MikeBeers
Andrew Charlebois
@andrewchar
Mar 17 2016 02:31
@jw1540 i seen an example i enjoyed the other day, kinda went like.. when is the last time you had to learn a new language... and when did you perfect that language? 18ish years later in college? i kinda like that in reference to learning code where we wanna be good right away but it doesnt happen that way
MikeBeers
@MikeBeers
Mar 17 2016 02:32
hmmm. i am changing letters into array so i can get the numbers. Then trying to change it back after I find the missing number
Andrew Charlebois
@andrewchar
Mar 17 2016 02:32
@jw1540 i will bet its the same, if not similar
Eric Stermer
@estermer
Mar 17 2016 02:32
how do you post the formatted code?
Andrew Charlebois
@andrewchar
Mar 17 2016 02:32
help format
CamperBot
@camperbot
Mar 17 2016 02:32

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

bitgrower
@bitgrower
Mar 17 2016 02:32
dang I'm a lazy cuss ...
Andrew Charlebois
@andrewchar
Mar 17 2016 02:33
eh?!@
a lazy what
jw1540
@jw1540
Mar 17 2016 02:33
@andrewchar yeah absolutely, just got to keep at it - it's rewarding though!
Eric Stermer
@estermer
Mar 17 2016 02:33
function destroyer(arr) {
  // Remove all the values
  var args = [];

  for (var j = 1; j < arguments.length; j++){
    args.push(arguments[j]);
  }

  var newArr = arr.filter(function (value, index, array){
   for (var i = 0; i < args.length; i++){
      return value != args[i];
   }
  });

  return newArr;

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Andrew Charlebois
@andrewchar
Mar 17 2016 02:33
@jw1540 it took me like 6 hours, with help.. lots of help to get where art thou done
Eric Stermer
@estermer
Mar 17 2016 02:33
ok that didnt work hahaha
MikeBeers
@MikeBeers
Mar 17 2016 02:34
@bitgrower do you think i am going t this prob in the wrong direction?
Andrew Charlebois
@andrewchar
Mar 17 2016 02:34
@estermer you can edit your posts to try that again instead of re-posting
Coy Sanders
@coymeetsworld
Mar 17 2016 02:34
you don't need a forloop in your filter function @estermer , filter will go through everything in the array
bitgrower
@bitgrower
Mar 17 2016 02:34
I just created an array with the letters of the alphabet in it ... then if I looped thru the parameter and found that the letter found in my array wasn't the letter in the corresponding index, I knew I found the missing letter and just returned it ...
Kurt Johnson
@pompan129
Mar 17 2016 02:35
@estermer put 3 backticks (```)on the line b4 and after your code
bitgrower
@bitgrower
Mar 17 2016 02:35
no messy arithmetic ...
and no messy charCodeAt or charCodeFrom calls, either ...
Josh Fisk
@JoshFisk
Mar 17 2016 02:35
@bitgrower I checked that the char code of the last thing in the array was one higher then the last
MikeBeers
@MikeBeers
Mar 17 2016 02:36
i was using the helpfull links. lol
bitgrower
@bitgrower
Mar 17 2016 02:36
LOL ... yeah, I know ... seemed like too much work ...
Kurt Johnson
@pompan129
Mar 17 2016 02:36
@estermer backticks(```) have to be on their own line
bitgrower
@bitgrower
Mar 17 2016 02:36
so I just used arrays, which I know and love ... :)
and some day @andrewchar will be helping others figure out how to solve where art thou ... but maybe not quite yet ... LOL ...
Mike Short
@mikeshort10
Mar 17 2016 02:37
Can someone explain why the return for this is "No such contact" rather than contacts[1]["likes"]?
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Harry", "likes");
Andrew Charlebois
@andrewchar
Mar 17 2016 02:37
"maybe some day" @bitgrower
Kurt Johnson
@pompan129
Mar 17 2016 02:37
@estermer thats it
Eric Stermer
@estermer
Mar 17 2016 02:38
@pompan129 thanks man
CamperBot
@camperbot
Mar 17 2016 02:38
estermer sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 17 2016 02:38
@mikeshort10 ... first start with firstName ... :)
CamperBot
@camperbot
Mar 17 2016 02:38
:star: 433 | @pompan129 | http://www.freecodecamp.com/pompan129
MikeBeers
@MikeBeers
Mar 17 2016 02:38
@bitgrower where art thou is crazy hard
Eric Stermer
@estermer
Mar 17 2016 02:38
i copy and pasted your backticks because I couldn't find them on my keyboard
Juwdohr
@Juwdohr
Mar 17 2016 02:39
Anyone know what e.which == 10 means; I know it specifically what kepress that is?
Kurt Johnson
@pompan129
Mar 17 2016 02:39
@estermer upper left corner with the tilda ~
Eric Stermer
@estermer
Mar 17 2016 02:39
@pompan129 haha i just found it just as you told me haha
bitgrower
@bitgrower
Mar 17 2016 02:39
actually, once you get it, see you see the symmetry -- and I suspect is very useful type of coding in many places ...
Eric Stermer
@estermer
Mar 17 2016 02:39
of course a key I have like never used before haha
Kurt Johnson
@pompan129
Mar 17 2016 02:39
:)
Mike Short
@mikeshort10
Mar 17 2016 02:40
@bitgrower I changed it and I'm still getting the same thing
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Harry", "likes");
Reynnan Viktor
@reynnanviktor
Mar 17 2016 02:40
Someone can help me with that? "Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed." I know is very good explained but I really don't figure out how to do this
bitgrower
@bitgrower
Mar 17 2016 02:40
@estermer -- you are pushing onto the one array starting at index 1, but you are examining it starting at index 0
Rex Schrader
@SaintPeter
Mar 17 2016 02:41
@Jarvis-327 That does not seem to be a valid keycode that I can find.
bitgrower
@bitgrower
Mar 17 2016 02:41
@reynnanviktor -- for Stand In line there are 4 really handy challenges on array functions you may want to review to help you ... on .push .pop .shift and .unshift ... the answer lies within !!!
Dayne Wright
@daynewright
Mar 17 2016 02:41
@mikeshort10 the issue in with the contact[i]
cannelflow
@cannelflow
Mar 17 2016 02:42
This message was deleted
Rex Schrader
@SaintPeter
Mar 17 2016 02:42
@mikeshort10 Note that you cannot return "no such contact" from within you loop. The only way to say that it is NOT in the loop is once you are done searching the whole list.
bitgrower
@bitgrower
Mar 17 2016 02:42
LOL ... I didn't say it's the ONLY thing that needed fixing ... but it's where you should start ... :)
Rex Schrader
@SaintPeter
Mar 17 2016 02:42
@Daynewr :wave:
MikeBeers
@MikeBeers
Mar 17 2016 02:42
does my result to undefined look correct or does it need to be adjusted some how?
for (var j = 0; j < numbArr.length; j++) {

     if (numbArr[j] - numbArr[j-1]  != 1) {
       result = String.fromCharCode(numbArr[j] - 1);
      //result = numbArr[j] - 1;

     }// else  {
      // result = undefined;
    // }

 }
Juwdohr
@Juwdohr
Mar 17 2016 02:43
@SaintPeter Same but trying to get rid of the <input type='submit'> so you just press enter and it submits the form.
bitgrower
@bitgrower
Mar 17 2016 02:43
when you look at your object, first you want to check for firstName ... @MikeBeers .. .
cannelflow
@cannelflow
Mar 17 2016 02:43
Write a function queue which takes an array (arr) and a number (item) as arguments which is
function queue(arr,item){
now you have to Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed."
}
@reynnanviktor
Eric Stermer
@estermer
Mar 17 2016 02:43
@bitgrower right that is the point i only want the new array to have the two arguments since the first argument is technically the arr.
Dayne Wright
@daynewright
Mar 17 2016 02:43
@SaintPeter Ahh…yes. So it is making answer the last run through the loop, right?
Rex Schrader
@SaintPeter
Mar 17 2016 02:43
@Jarvis-327 Enter key is 13
Eric Stermer
@estermer
Mar 17 2016 02:43
@bitgrower but then i examine the new array called args starting at index 0
Rex Schrader
@SaintPeter
Mar 17 2016 02:44
@Daynewr Oh, I was just waving hi :D
Juwdohr
@Juwdohr
Mar 17 2016 02:44
@SaintPeter I know that.
Rex Schrader
@SaintPeter
Mar 17 2016 02:44
@Jarvis-327 Oh, I see. Well, if you can capture 13, I think you can just do a $('#formID').submit() with jQuery
Dayne Wright
@daynewright
Mar 17 2016 02:45
@SaintPeter Yep! I did see that :) HELLO!! Long time! Still learning.. Still studying..actually things are getting easier but just until I start looking at angular/node/express/react/ yikes…
Mike Short
@mikeshort10
Mar 17 2016 02:45
@SaintPeter but it is returning "No such contact"; that's the issue
Dayne Wright
@daynewright
Mar 17 2016 02:45
and then trying to understand data structures and d3 stuff...
bitgrower
@bitgrower
Mar 17 2016 02:46
@estermer -- sorry, my bad .. the point is, you are returning in your for loop, so your for loop never completes execution ...
Rex Schrader
@SaintPeter
Mar 17 2016 02:46
@mikeshort10 Precisely. Right now if the first contact does not match, it always returns "no such contact". Think about it: If you only look at the first contact can you say it's not found? Nope. Nor for the second nor the third. You have to have looked at ALL of the contacts before you can return that.
Dayne Wright
@daynewright
Mar 17 2016 02:46
@mikeshort10 I think the issue is you are returning answer after it changes it every time through the loop. So whatever the last run is, that is your value
Eric Stermer
@estermer
Mar 17 2016 02:47
@bitgrower ok I was suspecting that
Juwdohr
@Juwdohr
Mar 17 2016 02:47
@SaintPeter What do you mean if i capture 13? This is what I have
$(function() {
$("#search").each(function(){
$(this).find('input).keydown(funtion(e) {
//Enter pressed?
if (e.keycode == 13) {
this.input.submit.();
}
});
});
});
Eric Stermer
@estermer
Mar 17 2016 02:47
@bitgrower my problem is how I can test the value against the multiple elements of args
Reynnan Viktor
@reynnanviktor
Mar 17 2016 02:48
@bitgrower Thank you sir,I had forgotten it
CamperBot
@camperbot
Mar 17 2016 02:48
reynnanviktor sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 880 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 17 2016 02:48
....well, there's an answer I could give you .. but you might like the challenge of finding it yourself ... :) @estermer
Eric Stermer
@estermer
Mar 17 2016 02:48
haha i have been searching that for a few days
Stefan Gisi
@stgisi
Mar 17 2016 02:49
Can someone please help me write this with if statements instead of using the ? operator??
Eric Stermer
@estermer
Mar 17 2016 02:49
as I throw my head back lol
Stefan Gisi
@stgisi
Mar 17 2016 02:49
arr[n % 2 ? 0 : i] = [arr[n - 1], arr[n - 1] = arr[n % 2 ? 0 : i]][0];
Mike Short
@mikeshort10
Mar 17 2016 02:49
Ahhhhh thank you @SaintPeter and @Daynewr!!!!! I added break; after each if-else statement and it ran perfectly! Been working on this for two days now! Thanks so much!
CamperBot
@camperbot
Mar 17 2016 02:49
mikeshort10 sends brownie points to @saintpeter and @daynewr :sparkles: :thumbsup: :sparkles:
:star: 318 | @daynewr | http://www.freecodecamp.com/daynewr
:star: 2661 | @saintpeter | http://www.freecodecamp.com/saintpeter
Mike Short
@mikeshort10
Mar 17 2016 02:49
Also thank you @bitgrower !!!!
CamperBot
@camperbot
Mar 17 2016 02:49
mikeshort10 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 881 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 17 2016 02:49
yw @mikeshort10
Eric Stermer
@estermer
Mar 17 2016 02:49
@bitgrower i can definitely try
Dayne Wright
@daynewright
Mar 17 2016 02:50
@SaintPeter 2661 ??? :clap:
Eric Stermer
@estermer
Mar 17 2016 02:50
@bitgrower i can keep pressing through the problem
Rex Schrader
@SaintPeter
Mar 17 2016 02:50
@Daynewr :D - I'm not at the top anymore, though. @rphares has me way outpaced.
about @rphares
CamperBot
@camperbot
Mar 17 2016 02:50
:star: 3325 | @rphares | http://www.freecodecamp.com/rphares
Eric Stermer
@estermer
Mar 17 2016 02:51
@bitgrower thanks for bantering with me
CamperBot
@camperbot
Mar 17 2016 02:51
estermer sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: estermer already gave bitgrower points
bitgrower
@bitgrower
Mar 17 2016 02:51
well .. the easiest way would be to do a call to array.filter with a different value -- so you would call array.filter from within a for loop ... (it's not the coolest answer -- for that, check out the FCC solutions...)
Dayne Wright
@daynewright
Mar 17 2016 02:52
geez…that is crazy.
rphares
@rphares
Mar 17 2016 02:52
lol, not true, @SaintPeter !
Dayne Wright
@daynewright
Mar 17 2016 02:52
you guys are the real deal.
Alaena VanderMost
@westernmassive
Mar 17 2016 02:52
hey everyone...could someone help with with 'return early pattern for functions'? I'm hitting a wall and I think its probably just a syntax thing
Rex Schrader
@SaintPeter
Mar 17 2016 02:52
@rphares Also, you're awesome ;)
rphares
@rphares
Mar 17 2016 02:52
i only have brownies, my profiles locked so i have no project points... you are still number one on the leaderboard :blush:
bitgrower
@bitgrower
Mar 17 2016 02:52
for ( var i = 0; i < testArgs.length; i++) {
arr.filter( ...
}
rphares
@rphares
Mar 17 2016 02:52
Aww, thanks, @SaintPeter !! You, too! :blush: :)
CamperBot
@camperbot
Mar 17 2016 02:52
rphares sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2662 | @saintpeter | http://www.freecodecamp.com/saintpeter
Eric Stermer
@estermer
Mar 17 2016 02:53
@bitgrower so your saying put the filter inside the scope of the for loop?
Rex Schrader
@SaintPeter
Mar 17 2016 02:53
@westernmassive Sure, can do
bitgrower
@bitgrower
Mar 17 2016 02:53
sure, why not ?
Rex Schrader
@SaintPeter
Mar 17 2016 02:53
@westernmassive Share your code?
cannelflow
@cannelflow
Mar 17 2016 02:53
@westernmassive tried something?
Darrel Adams
@dadams-510
Mar 17 2016 02:54
Can anyone help me work out the "Seek and Destroy" challenge?
Alaena VanderMost
@westernmassive
Mar 17 2016 02:54

function abTest(a, b) {
// Only change code below this line

if (a < 0) || (b < 0);
return undefined
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));

bitgrower
@bitgrower
Mar 17 2016 02:54
oh dang ... what's the link to the leaderboard ... ?
@dadams-510 -- meet @estermer . ... @estermer meet @dadams-510
Eric Stermer
@estermer
Mar 17 2016 02:54
would it return multiple filtered arrays?
Alaena VanderMost
@westernmassive
Mar 17 2016 02:54
I know its a syntax error. something just doesn't look right...but am I way off?
Rex Schrader
@SaintPeter
Mar 17 2016 02:54
@westernmassive You can't/shouldn't have a semicolon after your if statement. Also, always use curley braces.
cannelflow
@cannelflow
Mar 17 2016 02:54
@westernmassive if(){}
Darrel Adams
@dadams-510
Mar 17 2016 02:55
Hi @estermer
Rex Schrader
@SaintPeter
Mar 17 2016 02:55
if (a < 0) || (b < 0); // <--- No semicolon here
Eric Stermer
@estermer
Mar 17 2016 02:55
@dadams-510 yeah man I am working on that very challenge with bitgrower right now
Darrel Adams
@dadams-510
Mar 17 2016 02:55
oh snap!
haha
bitgrower
@bitgrower
Mar 17 2016 02:55
@estermer -- would depend on how you code it, I would guess ...
Eric Stermer
@estermer
Mar 17 2016 02:55
lol
Darrel Adams
@dadams-510
Mar 17 2016 02:55
nice @estermer
Let's work together on this.
Eric Stermer
@estermer
Mar 17 2016 02:55
@bitgrower gotcha
@dadams-510 ok what is your question
Darrel Adams
@dadams-510
Mar 17 2016 02:56
First off, I don't think I understand the Arguments object very well.
Juwdohr
@Juwdohr
Mar 17 2016 02:56
@SaintPeter is name and ID similar ?
bitgrower
@bitgrower
Mar 17 2016 02:56
sheesh ... I was higher up before ... must be a ton of active campers ... :(
Darrel Adams
@dadams-510
Mar 17 2016 02:56
I don't think I've seen examples of it in FreeCodeCamp. What is it used for?
cannelflow
@cannelflow
Mar 17 2016 02:56
if(cond){
return
}
@westernmassive
Eric Stermer
@estermer
Mar 17 2016 02:56
give me like 5 minutes ok i gotta step into the other room for a second
Darrel Adams
@dadams-510
Mar 17 2016 02:56
alright.
Alaena VanderMost
@westernmassive
Mar 17 2016 02:57
thanks guys! I was focusing so hard on if I had the right solution that I was totally messing up the way it should be written
Eric Stermer
@estermer
Mar 17 2016 02:57
from what I understand it that you can call upon arguments given within a function
Rex Schrader
@SaintPeter
Mar 17 2016 02:57
@Jarvis-327 Similar but NOT identical. A name attribute is for when a form is submitted - that is the "variable name" that will be assigned to the value of the input will be assigned to. An id is a unique identifier for a single HTML element. You can use IDs to find an element in the DOM to do javascripty stuff. You can also use them to apply CSS.
bitgrower
@bitgrower
Mar 17 2016 02:58
@dadams-510 -- it's used for the fact that MOST js functions can take ANY number of arguments ... so, if you don't know how many are passed, you have to use the arguments object to find out!
Eric Stermer
@estermer
Mar 17 2016 02:58
so say you have the function they give that has 3 arguments which is the array[], 2, and 3
Dayne Wright
@daynewright
Mar 17 2016 02:58
@dadams-510 even if it is not written in the function. ^
Eric Stermer
@estermer
Mar 17 2016 02:58
the arguments object can distinguish between those different values
Darrel Adams
@dadams-510
Mar 17 2016 02:59
Ah @bitgrower
bitgrower
@bitgrower
Mar 17 2016 02:59
that thing ... those "arguments" you see in the function definition are NAMED parameters ... but you can have UNNAMED parameters as well, and that is the case with seek and destroy ...
Eric Stermer
@estermer
Mar 17 2016 02:59
so when you call arguments1 in the case of the function they give you it would be the value of 2
bitgrower
@bitgrower
Mar 17 2016 03:00
you use the arguments object to find them ALL ...
Juwdohr
@Juwdohr
Mar 17 2016 03:02
@SaintPeter So what does the e.which == 10 mean with in the following:
$(function() {
  $('form').each(function() {
    $(this).find('input').keypress(function(e) {
      // Enter pressed?
      if(e.which == 10 || e.which == 13) {
        this.form.submit();
      }
    });

    $(this).find('input[type=submit]').hide();
  });
});
Rex Schrader
@SaintPeter
Mar 17 2016 03:03
@Jarvis-327 My guess: 10 is the ASCII code for linefeed. My bet is that some systems (cough, Mac, cough) use 10 rather than 13 (Carriage Return)
@Jarvis-327 e.which is the keycode
Juwdohr
@Juwdohr
Mar 17 2016 03:06
@SaintPeter ok so i got it to work on a "test" pen but it won't work when I put it into the code for my Wikipedia Viewer.
codepen.io/Jarvis-327/pen/JXEYaQ
Rex Schrader
@SaintPeter
Mar 17 2016 03:08
@Jarvis-327 ooookay, sorry, different problem here. You do not want to submit a form at all. There is no server-side code there to recieve it.
@Jarvis-327 And there shouldn't be. What you want to do is just this:
 $('#searchBox').keypress(function(e) {
      // Enter pressed?
      if(e.which == 10 || e.which == 13) {
          e.preventDefault(); // Prevent form from submitting
        // Do something here to make a query against Wikipeidia
        // Using Javascript and AJAX
      }
    });
@Jarvis-327 Also, you need an input box:
<input type="text" id="search"></input>
Juwdohr
@Juwdohr
Mar 17 2016 03:16
@SaintPeter So what do I need? This is what I have:
$("#search").click(function() {
  $("<input id='search' type='text'></input>").replaceAll(this);

  $(function() {
    $('input').each(function() {
      $(this).keypress(function(e) {
        // Enter pressed?
        if(e.which == 10 || e.which == 13) {
          e.preventDefault();

        }
      });
    });
  });
});
Malcolm
@noinkling
Mar 17 2016 03:16
Instead of waiting on a keypress you can also just attach it to the form's submit event instead Never mind that way requires a form wrapper around the input
Rex Schrader
@SaintPeter
Mar 17 2016 03:18
@Jarvis-327 Um
@Jarvis-327 If you want to use enter to do the search, all you need (generally speaking) is the code I listed above. You'll need to fill in the "do something here" part.
toddgithub
@toddgithub
Mar 17 2016 03:19

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

testArr.push(item);
testArr.shift();

return item; // Change this line
}

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

Rex Schrader
@SaintPeter
Mar 17 2016 03:23
@toddgithub You are not capturing the element which is shifted off
toddgithub
@toddgithub
Mar 17 2016 03:24
hmm ok
Rex Schrader
@SaintPeter
Mar 17 2016 03:24
@toddgithub Remember that shift returns the element it removes ;)
Juwdohr
@Juwdohr
Mar 17 2016 03:25
@SaintPeter Thank you for all the help. Sorry for bugging you so much.
CamperBot
@camperbot
Mar 17 2016 03:25
jarvis-327 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2663 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Mar 17 2016 03:25
@Jarvis-327 LOL - it's all good :D
Chelsea M
@cgmccallum
Mar 17 2016 03:26
Hey guys! I know this is pretty basic stuff but I'm stuck on the JS lesson on increments. myVar is supposed to = 88. It sets it up so that myVar = 87, so for the solution I entered myVar = myVar++ but it's saying that myVar is still only 87. What am I doing wrong?
Rex Schrader
@SaintPeter
Mar 17 2016 03:27
@cgmccallum replace the WHOLE LINE . . .
@cgmccallum There is no =
Chelsea M
@cgmccallum
Mar 17 2016 03:28
So it just needs to be myVar++?
Rex Schrader
@SaintPeter
Mar 17 2016 03:28
@cgmccallum Correct
@cgmccallum (With a simicolon at the end ;) )
Chelsea M
@cgmccallum
Mar 17 2016 03:28
Wow. Clearly I'm overdue for a break! Haha thank you!
Steve Stout
@jessebae
Mar 17 2016 03:28
I'm not getting the gist of of "Word Blanks" in JavaScript. Appears my code is semantically correct but not functional. Any help is appreciated.
Rex Schrader
@SaintPeter
Mar 17 2016 03:29
@jessebae Sure, can help. Share your code?
Steve Stout
@jessebae
Mar 17 2016 03:30
border-style: inset;
border-width: 1px;
Yeah, I tried. Let me try again

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun = wordBlanks[0];
myAdjective = wordBlanks1;
myVerb = wordBlanks2;
myAdverb = wordBlanks3;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("My dog ", "is big ", "and runs ", "very quickly.");

Please ignore the html that was on my clipboard, not included in the javascript exercise
Rex Schrader
@SaintPeter
Mar 17 2016 03:31
@jessebae myNoun, etc, is already set for you.
@jessebae Your challenge is to link those variables together, with some spaces.
@jessebae there is no variable called wordblanks - just a function named that.
Reynnan Viktor
@reynnanviktor
Mar 17 2016 03:34
"After queue(testArr, 10), myArr4 should be 10 "
Ok now, I dont get that I create a var called myArr but I dont really know what I have to do with her, this is from the question named Stand in Line all the others task is already complete
myArr'4'*
Steve Stout
@jessebae
Mar 17 2016 03:35
I'm not getting what I'm supposed to do, I guess Something more like this
Rex Schrader
@SaintPeter
Mar 17 2016 03:35
@reynnanviktor use backticks `
Andrew Charlebois
@andrewchar
Mar 17 2016 03:35
having a hard time comprehending what DNA pairing wants to to even print out...
me to*
Rex Schrader
@SaintPeter
Mar 17 2016 03:35
@jessebae You need to concatenate strings - use the + or += operators
bitgrower
@bitgrower
Mar 17 2016 03:35
:( @andrewChar ...
Andrew Charlebois
@andrewchar
Mar 17 2016 03:36
lmao
bitgrower
@bitgrower
Mar 17 2016 03:36
think about objects as look ups ...
Andrew Charlebois
@andrewchar
Mar 17 2016 03:36
sorry i dont get it
no
not even thinking about code
Steve Stout
@jessebae
Mar 17 2016 03:36

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("My dog ", "is big ", "and runs ", "very quickly.");
what are backticks?

Andrew Charlebois
@andrewchar
Mar 17 2016 03:36
ATCGA comes out to be AT TA CG GC AT.. like what!?
Rex Schrader
@SaintPeter
Mar 17 2016 03:37
@jessebae Yes, but you need spaces :D
bitgrower
@bitgrower
Mar 17 2016 03:38
A ... matches up to T ... so you create a subarray -- A,T ... T matches up to A, so you create a subarray T,A
etc ...
Andrew Charlebois
@andrewchar
Mar 17 2016 03:38
is that a base paired DNA sequence...
Rex Schrader
@SaintPeter
Mar 17 2016 03:38
@andrewchar There are 4 base pairs, A, T, G and C (don't ask me what they stand for). A binds with T and visa versa. G with C and visa versa
bitgrower
@bitgrower
Mar 17 2016 03:39
DNA sequencing is a WHOLE 'nuther topic ... not overly relevant here ... :)
Steve Stout
@jessebae
Mar 17 2016 03:39
There are spaces in the parameters of the wordBlanks function and between my variables. var result = "myNoun + myAdjective + myVerb + my Adjective;
bitgrower
@bitgrower
Mar 17 2016 03:40
just match up their pairs ... like girls and boys at a dance ...
Rex Schrader
@SaintPeter
Mar 17 2016 03:40
@jessebae You need to add them to the result string. Your inputs are not the only inputs considered.
Steve Stout
@jessebae
Mar 17 2016 03:42
I assigned them to the result string. I don't know what the other inputs are. I guess I just don't understand what there exercise wants me to do.
Rex Schrader
@SaintPeter
Mar 17 2016 03:42
@jessebae You need to build a sentence using the provided words. Those words will not have spaces in them. You need to add spaces when yuo build the sentence.
bitgrower
@bitgrower
Mar 17 2016 03:43
lordy, @andrewchar -- now I see what you mean about hydrogen bonding on the wiki page ... I covered DNA base pairs in so many classes and I'm pretty sure MOST of them did NOT cover hydrogen bonding ...
Andrew Charlebois
@andrewchar
Mar 17 2016 03:43
@bitgrower see
the wiki is evil
Alaena VanderMost
@westernmassive
Mar 17 2016 03:43
So, in switch cases....what exactly does the break do?
Andrew Charlebois
@andrewchar
Mar 17 2016 03:43
@bitgrower but i get what it wants now
bitgrower
@bitgrower
Mar 17 2016 03:43
hahahahaha ... maybe try khanacademy.com
Rex Schrader
@SaintPeter
Mar 17 2016 03:43
@westernmassive break means "stop checking cases, I'm done"
Andrew Charlebois
@andrewchar
Mar 17 2016 03:43
@bitgrower if its g, math c, if a match t
match*
bitgrower
@bitgrower
Mar 17 2016 03:44
yep -- it's as simple as that ... :)
Andrew Charlebois
@andrewchar
Mar 17 2016 03:44
i was overthinking it
also..
Alaena VanderMost
@westernmassive
Mar 17 2016 03:44
I noticed that I couldn't pass the tests in ' counting cards ' , then i remembered to go and add breaks, and everything passed (yay!) but I wasn't really understanding why
Andrew Charlebois
@andrewchar
Mar 17 2016 03:44
i was looking at this
A base-paired DNA sequence:
ATCGATTGAGCTCTAGCG
TAGCTAACTCGAGATCGC
so i was like. omg wth is going on here
bitgrower
@bitgrower
Mar 17 2016 03:45
hahahahahahaha ... yeah .. forget about sequences ... that's like another for loop on the outside of matching up the base pairs ...
(in fact, maybe more than one ... )
bitgrower @bitgrower scratches at her biochem, microbio class learnings ...
Andrew Charlebois
@andrewchar
Mar 17 2016 03:46
lol
i was never one for those subjects
bitgrower
@bitgrower
Mar 17 2016 03:48
wikipedia arcana ... "The total amount of related DNA base pairs on Earth is estimated at 5.0 x 1037, and weighs 50 billion tonnes." ... really ?!? ... um ... not to be rude or anything, wikipedia ... but what does that have to do with anything ...
Steve Stout
@jessebae
Mar 17 2016 03:48

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "My " + myNoun + " is " + myAdjective + " and " + myVerb + " very " + MyAdverb;

// Your code above this line
return result;
}

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

bitgrower @bitgrower decides we need to take the wikipedia challenge, combine it with the simon challenge, and create a jeopardy game ...
Rex Schrader
@SaintPeter
Mar 17 2016 03:49
@jessebae That looks correctish
bitgrower @bitgrower swipes "correctish" ... I've needed that word .. thanks, @SaintPeter
CamperBot
@camperbot
Mar 17 2016 03:49
bitgrower sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2664 | @saintpeter | http://www.freecodecamp.com/saintpeter
Steve Stout
@jessebae
Mar 17 2016 03:50
It doesn't work.
Francis
@Francis-p
Mar 17 2016 03:50
anyone can help me with string.fromCharCode()?
Rex Schrader
@SaintPeter
Mar 17 2016 03:50
@jessebae In what way? Do all the tests fail?
Francis
@Francis-p
Mar 17 2016 03:50
how do you use it?
Steve Stout
@jessebae
Mar 17 2016 03:51
it passes only the first goal
Andrew Charlebois
@andrewchar
Mar 17 2016 03:51
@SaintPeter AT adenine-thymine, GC guanine - cytosine
Rex Schrader
@SaintPeter
Mar 17 2016 03:51
@andrewchar haha
Andrew Charlebois
@andrewchar
Mar 17 2016 03:52
:) lol
enjoy the knowledge friend lol
Steve Stout
@jessebae
Mar 17 2016 03:53
so it may look correctish but the UI says it's wrongish
Rex Schrader
@SaintPeter
Mar 17 2016 03:53
LOL
Andrew Charlebois
@andrewchar
Mar 17 2016 03:53
haha
what a downner ui
Rex Schrader
@SaintPeter
Mar 17 2016 03:54
@jessebae MyAdverb - case matters ;)
Steve Stout
@jessebae
Mar 17 2016 03:55
Yeah, I know case matters, but frustration blurs my vision. Thanks for catching the error! How do I give brownie points?
Rex Schrader
@SaintPeter
Mar 17 2016 03:56
Just say "thanks" and @mention me
or whoever
Steve Stout
@jessebae
Mar 17 2016 03:56
Big Thanks @SaintPeter !
CamperBot
@camperbot
Mar 17 2016 03:56
jessebae sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2665 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Mar 17 2016 03:56
@jessebae Sure thing ;)
bitgrower
@bitgrower
Mar 17 2016 03:57
when frustration beckons ... taking walks, ,breaks, exercise, playing a game ... do some sort of distraction for a few minutes ...
Juwdohr
@Juwdohr
Mar 17 2016 03:57
Can you have more than one id tag?
Rex Schrader
@SaintPeter
Mar 17 2016 03:57
@Jarvis-327 Elements may only have one ID tag and each id tag should be globally unique.
bitgrower
@bitgrower
Mar 17 2016 03:57
technically, yes ... will it work correctly, no
Francis
@Francis-p
Mar 17 2016 03:58
wiki Caesars Cipher
Rex Schrader
@SaintPeter
Mar 17 2016 03:58
@Jarvis-327 and they're technically "attributes" - the HTML element name is the "tag" (IE: img, a, etc)
@Francis-p Sorry, gonna need human help for that one.
bitgrower @bitgrower had a bad experience with a page builder which would use the same id whenever you added a box ... nearly pulled my hair out on that one
Rex Schrader
@SaintPeter
Mar 17 2016 03:59
wiki caesar's
CamperBot
@camperbot
Mar 17 2016 03:59

:point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program. :busts_in_silhouette: Write your own code. :memo:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Francis
@Francis-p
Mar 17 2016 04:00
@SaintPeter it is hard to understand how to go about doing it..
Rex Schrader
@SaintPeter
Mar 17 2016 04:01
@Francis-p You'll probably want to start with codeAt, which is going to give you the ASCII code for each letter. You can then do math and/or comparisons to add/subtrack 13.
@Francis-p You will need to loop through the letters in the string. You'll also need to decide which are "letters" and which are non-letters.
Francis
@Francis-p
Mar 17 2016 04:05
@SaintPeter got it! i will try it out!
Sourav Karanjai
@souravkaranjai
Mar 17 2016 04:31
I just can't understand what is the formula(for orbital period) for this problem. THe wikipedia link given doesnt seem to help much... could somebody please hep me...

Return a new array that transforms the element's average altitude into their orbital periods.

The array will contain objects in the format {name: 'name', avgAlt: avgAlt}.

You can read about orbital periods on wikipedia.

The values should be rounded to the nearest whole number. The body being orbited is Earth.

The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418

CamperBot
@camperbot
Mar 17 2016 04:31
no wiki entry for: link httpsenwikipediaorgwikiorbital_period
Sourav Karanjai
@souravkaranjai
Mar 17 2016 04:32

@souravkaranjai
I just can't understand what is the formula(for orbital period) for this problem. THe wikipedia link given doesnt seem to help much... could somebody please hep me...
Return a new array that transforms the element's average altitude into their orbital periods.

The array will contain objects in the format {name: 'name', avgAlt: avgAlt}.

You can read about orbital periods on wikipedia.

The values should be rounded to the nearest whole number. The body being orbited is Earth.

The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418
wiki link https://en.wikipedia.org/wiki/Orbital_period

Vũ Quốc Đạt
@datvimaru50
Mar 17 2016 04:42
function lookUp(firstName, prop){
// Only change code below this line
var i = 0;
while(i < contacts.length) {
if(contacts[i].firstName == firstName & contacts[i][prop] !== undefined) {
return contacts[i][prop];
}
if (contacts[i].firstName !== firstName) {
return "No such contact";
}
if (contacts[i][prop] === undefined) {
return "No such property";
}
i++;
}
Greg D
@mosaic-greg
Mar 17 2016 04:42
@souravkaranjai i believe the lower the altitude the faster the orbital period
Sidharth Kriplani
@sidkrip
Mar 17 2016 04:43
@datvimaru50 what is the problem with it?
Vũ Quốc Đạt
@datvimaru50
Mar 17 2016 04:43
Hi, I do challenge 227 and am stuck
Sidharth Kriplani
@sidkrip
Mar 17 2016 04:43
@datvimaru50 challenge name is?
Vũ Quốc Đạt
@datvimaru50
Mar 17 2016 04:44
profile lookup
I checked, It only work with the firs contact
Mike Olo
@michaelolo24
Mar 17 2016 04:44
what's your code?
Sidharth Kriplani
@sidkrip
Mar 17 2016 04:45
@Spacecamel100 sorry I had dozed off and it seems very easy. mention the challenge please?
Vũ Quốc Đạt
@datvimaru50
Mar 17 2016 04:46
function lookUp(firstName, prop){
// Only change code below this line
var i = 0;
while(i < contacts.length) {
if(contacts[i].firstName == firstName & contacts[i][prop] !== undefined) {
return contacts[i][prop];
}
if (contacts[i].firstName !== firstName) {
return "No such contact";
}
if (contacts[i][prop] === undefined) {
return "No such property";
}
i++;
}
function lookUp(firstName, prop){
// Only change code below this line
var i = 0;
while(i < contacts.length) {
if(contacts[i].firstName == firstName & contacts[i][prop] !== undefined) {
return contacts[i][prop];
}
if (contacts[i].firstName !== firstName) {
return "No such contact";
}
if (contacts[i][prop] === undefined) {
return "No such property";
}
i++;
}
I am sory
Sidharth Kriplani
@sidkrip
Mar 17 2016 04:46
@datvimaru50 is it profile lookup?
Vũ Quốc Đạt
@datvimaru50
Mar 17 2016 04:47
that's my code
@sidkrip ýe
Sidharth Kriplani
@sidkrip
Mar 17 2016 04:47
function lookUp(firstName, prop){
// Only change code below this line
var i = 0;
while(i < contacts.length) {
if(contacts[i].firstName == firstName & contacts[i][prop] !== undefined) {
return contacts[i][prop];
}
if (contacts[i].firstName !== firstName) {
return "No such contact";
}
if (contacts[i][prop] === undefined) {
return "No such property";
}
i++;
}
function lookUp(firstName, prop){
// Only change code below this line
var i = 0;
while(i < contacts.length) {
if(contacts[i].firstName == firstName & contacts[i][prop] !== undefined) {
return contacts[i][prop];
}
if (contacts[i].firstName !== firstName) {
return "No such contact";
}
if (contacts[i][prop] === undefined) {
return "No such property";
}
i++;
}
@datvimaru50 wiki Profile Lookup
try out this first
wiki Profile Lookup
CamperBot
@camperbot
Mar 17 2016 04:48

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName 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"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Vũ Quốc Đạt
@datvimaru50
Mar 17 2016 04:48
many thanks
I will try it out
Mike Olo
@michaelolo24
Mar 17 2016 04:48
yea, and your probably going to want to use some else if statements in place of the sequential if statmeents
statements*
you're*
Danny McCollins
@dmccollins
Mar 17 2016 05:12
wiki Record Collection
CamperBot
@camperbot
Mar 17 2016 05:12

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint record collection on the FCC Wiki

Mahak Narayan Singh
@makkBit
Mar 17 2016 05:31

Help plz.
Program to title case a sentence.
Here is my code :

function titleCase(str) {

  var strLo = str.toLowerCase(); //  i'm a little  tea pot

  //turns the first char of the string to upper case
  var result = [];
  result =str[0].toUpperCase();

  for(i=0;strLo.length;i++){

    //if a space is found, turns the char next to space to Upper case
    if( strLo[i].charCodeAt(0) === 32){     

      result = strLo[i+1].toUpperCase();

    }
      result = strLo[i];

  }

 return result;

}

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

Really confused. Thanks in advance.

CamperBot
@camperbot
Mar 17 2016 05:31
no wiki entry for: plzprogram to title case a sentencehere is my code function titlecasestr var strlo strtolowercase im a little tea pot turns the first char of the string to upper case var result result str0touppercase fori0strlolengthi if a space is found turns the char next to space to upper case if strloicharcodeat0 32 result strloi1touppercase result strloi return result titlecaseim a little tea potreally confused thanks in advance
justoy
@wordhardqi
Mar 17 2016 05:33
<!DOCTYPE html>
<html>
<head>
 <script src="//code.jquery.com/jquery-1.12.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>
<p>s1</p>
<p>s2</p>
<p>s3</p>
</body>
</html>
why does it not work if I copy the code into a local html file and open it with chrome?
uriznik
@uriznik
Mar 17 2016 05:39
@wordhardqi it's probably looking for file://code.jquery.com/etc. so need to specify https/http
or run a simple web server so you can browse localhost
justoy
@wordhardqi
Mar 17 2016 05:40
@uriznik It is solved. The link is not legal. THanks.
CamperBot
@camperbot
Mar 17 2016 05:40
wordhardqi sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 343 | @uriznik | http://www.freecodecamp.com/uriznik
justoy
@wordhardqi
Mar 17 2016 05:43
Thanks you good guys.
uriznik
@uriznik
Mar 17 2016 05:49
hi @makkBit, you have a few problems there :)
Mahak Narayan Singh
@makkBit
Mar 17 2016 05:50
like what ? :)
tried console.log() , but still can't figure it out! :worried: @wordhardqi
uriznik
@uriznik
Mar 17 2016 05:50
@makkBit you haven't used the variable i before so you should declare it - `for (var i=0; ... )
You then have strLo.length as the loop test but you should really be comparing your i var to that
Mahak Narayan Singh
@makkBit
Mar 17 2016 05:52
oh ..I didnright!!
god! dumb mistakes by me !! ..thank you for figuring it out !! @uriznik :smile:
CamperBot
@camperbot
Mar 17 2016 05:53
makkbit sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 344 | @uriznik | http://www.freecodecamp.com/uriznik
uriznik
@uriznik
Mar 17 2016 05:57
@makkBit there are of course a few ways to solve the problem and you can step through each character, but as strings are immutable (can't be modified in place like an array) you'll need some way to build a new string
Mahak Narayan Singh
@makkBit
Mar 17 2016 05:59
@uriznik yeah, that's why I have used to a new string ( result ) for the modified string
uriznik
@uriznik
Mar 17 2016 06:00
@makkBit try running console.log(result) in the loop and check the console
if anyone can help me with this please
Andrew Charlebois
@andrewchar
Mar 17 2016 06:08
help Missing letters
CamperBot
@camperbot
Mar 17 2016 06:08

:point_right: algorithm missing letters [wiki]

Problem Explanation:

  • You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
:pencil: read more about algorithm missing letters on the FCC Wiki
Shivam Arora
@shivamarora13
Mar 17 2016 06:08
how do I check the firstName of contacs
help Profile Lookup
CamperBot
@camperbot
Mar 17 2016 06:09

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName 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"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Andrew Charlebois
@andrewchar
Mar 17 2016 06:13
@shivamarora13 you would look to use dot notation or bracket notation
ottomahn
@ottomahn
Mar 17 2016 06:26
@ottomahn
heckCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]) should return [["QUARTER", 0.50]]. guys I am not sure about this test case?
has anyone solved this challenge?
help Exact change
CamperBot
@camperbot
Mar 17 2016 06:30

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have
    enough cash or will have no cash after the transaction. Other than that it
    needs to return an array of the change in the form of an array, so that will
    be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Olawale Akinseye
@brainyfarm
Mar 17 2016 06:44
@shivamarora13, could you share your code?
williamquan
@williamquan
Mar 17 2016 06:44
Has anyone completed the Counting Cards Challenge, help me walk through the problem?
Olawale Akinseye
@brainyfarm
Mar 17 2016 06:47
Could you share your code @williamquan?
williamquan
@williamquan
Mar 17 2016 06:49
Not sure i understand the problem fully:

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 = count + card;
return count + " bet";

}

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

Coy Sanders
@coymeetsworld
Mar 17 2016 07:04
you need to put statements between your case statements
@williamquan
so what will happen in your switch statement is say card=3
code will continue executing at case 3:
case 2: does not get run
and it will keep going down the list until the end of the switch statement, so it will go to case 4, case 5, etc
you can stop that by putting a break; command when you want to exit out of the switch
so something like
switch (card) {
  case 2: 
    // do stuff for when card =2 
   break;
 case 3:
   // do stuff for when card = 3 (card = 2 won't do anything since we put the break above)
  break
...
williamquan
@williamquan
Mar 17 2016 07:08
I think I'm confused about fulfilling all conditions of the problem to execute, not sure what to do? Do I set count to increment count++ within each case? And how do I have a Bet or Hold for certain cases since that seems like 2 conditions
Coy Sanders
@coymeetsworld
Mar 17 2016 07:09
your "count" depends on what card you pass to the cc function
you want to increment on small cards, middle cards do nothing, high cards decrement
just like if you were really counting cards in blackjack
Arun Kumar
@arunk38
Mar 17 2016 07:11
@williamquan your code looks so far so good with little mistake
see the table before changing count
count increases by 1, not by card value in that range
I think that's the problem.
Bil
@thebiltheory
Mar 17 2016 07:12
Salam from Dubai Peeps
Coy Sanders
@coymeetsworld
Mar 17 2016 07:12
yes thats true too @arunk38
williamquan
@williamquan
Mar 17 2016 07:14
nothing is returned to the console though?
Arun Kumar
@arunk38
Mar 17 2016 07:15
@williamquan bcz you still have to handle all cases
console will only show latest call return
if you are using the default test case which is: cc(2); cc(3); cc(7); cc('K'); cc('A');
latest call card is "A" which is not handled, and returns nothing i.e.. blank console
Shivam Arora
@shivamarora13
Mar 17 2016 07:24
help Make Object Properties Private
CamperBot
@camperbot
Mar 17 2016 07:24

:point_right: challenge make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

Another example:

:pencil: read more about challenge make object properties private on the FCC Wiki

Ian
@myseven
Mar 17 2016 07:26
[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, currentIndex, array) {

    var a = [0,1]
    for (var i = 0; i < a.length; i++) {
      // typeof a[i]  is number
    }

    for (var i = 0; i < array.length; i++) {
      // typeof array[i] is object 
    };

    return previousValue + currentValue;
  });
Who can help me
Why the type is not the same
I want to compare the element with two arrays
williamquan
@williamquan
Mar 17 2016 07:28
How do I share code?
I think I almost got it...
Ian
@myseven
Mar 17 2016 07:29
You can write markdown
williamquan
@williamquan
Mar 17 2016 07:31
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++;
    return count + " bet";
    case 7:
    case 8:
    case 9:
    count = count;
    return count + " Hold";
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
    count--;
    return count + " 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');
am i close?
Coy Sanders
@coymeetsworld
Mar 17 2016 07:32
getting there @williamquan
Niko Salonen
@nikosalonen
Mar 17 2016 07:32
@williamquan bet/hold depends on the count, not on the current card
Coy Sanders
@coymeetsworld
Mar 17 2016 07:32
and yes @nikosalonen is right
you don't want return statements in your switch
you want to modify the count variable there only
then after that, look at the count variable and determine if you're going to print bet or hold
williamquan
@williamquan
Mar 17 2016 07:35
what would i use instead of return? break statement instead?
Niko Salonen
@nikosalonen
Mar 17 2016 07:39
yeah break and after switch you do return
Manikanth
@manikanth1024
Mar 17 2016 07:43
How to solve Find the Longest Word in a String?

function findLongestWord(str) {
str.split(" ");
return str.length;
}

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

function findLongestWord(str) {

return str.split(" ").length;
}

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

Niko Salonen
@nikosalonen
Mar 17 2016 07:48
you need to loop through the str since it's array
williamquan
@williamquan
Mar 17 2016 07:50
@nikosalonen if bet/hold depends on the count and not the current card, does that mean i need an if/else statement in there?
Niko Salonen
@nikosalonen
Mar 17 2016 07:50
kinda yeah :D
williamquan
@williamquan
Mar 17 2016 07:53
@nikosalonen i think im making the code worse, but if i remove the return statements and put a break and outside of the switch statement before the closing " } " I would put a an if/else with a return statement for the count Bet and Hold in the else condition?
Niko Salonen
@nikosalonen
Mar 17 2016 07:55
how is it making worse? of course you could put the if/else inside the switch but then you're repeating yourself and that's something you generally want to avoid
williamquan
@williamquan
Mar 17 2016 07:55
@nikosalonen Nvm, I got it to work finally after 3 hours on this problem, thanks
CamperBot
@camperbot
Mar 17 2016 07:55
williamquan sends brownie points to @nikosalonen :sparkles: :thumbsup: :sparkles:
:star: 346 | @nikosalonen | http://www.freecodecamp.com/nikosalonen
Niko Salonen
@nikosalonen
Mar 17 2016 07:55
okay good :)
Humphrey
@Humphreto
Mar 17 2016 07:57
Hello world
CamperBot
@camperbot
Mar 17 2016 07:57

welcome to FreeCodeCamp @Humphreto!

ManBearPigg
@ManBearPigg
Mar 17 2016 07:57

code // Setup
function phoneticLookup(val) {
var result = "";

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

result = lookup;

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

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

Humphrey
@Humphreto
Mar 17 2016 07:57
Can some one explain what Is jade
ManBearPigg
@ManBearPigg
Mar 17 2016 07:58
How can I set result to the value of whatever one I enter into phoneticLookup?
I can do specifically result=lookup.alpha for example, but having a hard time with a more general solution
Niko Salonen
@nikosalonen
Mar 17 2016 08:00
@Humphreto do you mean the templating language?
Manikanth
@manikanth1024
Mar 17 2016 08:00
help Return Largest Numbers in Arrays
CamperBot
@camperbot
Mar 17 2016 08:00

:point_right: algorithm return largest numbers in arrays [wiki]

Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

:pencil: read more about algorithm return largest numbers in arrays on the FCC Wiki

Manikanth
@manikanth1024
Mar 17 2016 08:01
find Return Largest Numbers in Arrays
CamperBot
@camperbot
Mar 17 2016 08:01

find return largest numbers in arrays

:zero: algorithm return largest numbers in arrays

Niko Salonen
@nikosalonen
Mar 17 2016 08:02
@ManBearPigg you could use the bracket notation
ManBearPigg
@ManBearPigg
Mar 17 2016 08:02
result=lookup[]
I’m not sure what to even look for
@nikosalonen
Niko Salonen
@nikosalonen
Mar 17 2016 08:03
well the function has one parameter which is passed so try that
ManBearPigg
@ManBearPigg
Mar 17 2016 08:04
lookup.val returns nil
Niko Salonen
@nikosalonen
Mar 17 2016 08:04
with brackets
lookup[val]
ManBearPigg
@ManBearPigg
Mar 17 2016 08:04
Why did it work with brackets?
and not the dot format?
jovbe
@jovbe
Mar 17 2016 08:05
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

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

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

I've done the preceding challenges more than once now, but don't even know how to start

Niko Salonen
@nikosalonen
Mar 17 2016 08:05
@ManBearPigg because the property name is string
ManBearPigg
@ManBearPigg
Mar 17 2016 08:05
@jovbe I can help
@jovbe I did that one
You do have to use stuff from challenges before
push
and shift
push appends an item to the end of the array
shift removes from the front
This is the first time you actually have to write your own code and be tricky
@jovbe what’s the challenge called I’ll go to it with you?
Dmytro Bondarenko
@gonardfreeman
Mar 17 2016 08:08
@jovbe use push and shift
@jovbe inside function
33ndgr
@33ndgr
Mar 17 2016 08:09
Well guys, I'm int he Seek and Destroy algorithms challenge and I know the way to do it's solution but not in a general way. The question is. is there any way to have a filter function with one or more checkings, I mean, to do a loop or something instead of &&
function destroyer(arr) {
  // Remove all the values
  var data = arguments;
  var arrToFilter = data[0];

  function arrKiller(tester) {
    return tester != data[1] && tester != data[2] && tester != data[3];
  }

  return arrToFilter.filter(arrKiller);
}
Dmytro Bondarenko
@gonardfreeman
Mar 17 2016 08:09
guys what i've miss in golftest? 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 "not equal";
}
ManBearPigg
@ManBearPigg
Mar 17 2016 08:10
@nikosalonen Thanks for the help
CamperBot
@camperbot
Mar 17 2016 08:10
manbearpigg sends brownie points to @nikosalonen :sparkles: :thumbsup: :sparkles:
:star: 347 | @nikosalonen | http://www.freecodecamp.com/nikosalonen
ManBearPigg
@ManBearPigg
Mar 17 2016 08:10
@gonardfreeman looks perfect to me what’s your output
kirbyedy
@kirbyedy
Mar 17 2016 08:10
@gonardfreeman why this line ? return "not equal";
Niko Salonen
@nikosalonen
Mar 17 2016 08:10
@gonardfreeman what's the error
williamquan
@williamquan
Mar 17 2016 08:10
I'm confused on Accessing Objects Properties with Variables
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[Montana];       // Change this Line
var player = testObj[16];   // Change this Line
Dmytro Bondarenko
@gonardfreeman
Mar 17 2016 08:11
golfScore(4, 1) should return "Hole-in-one!"
but it returns
williamquan
@williamquan
Mar 17 2016 08:11
How do i get playerNumber being a number?
ManBearPigg
@ManBearPigg
Mar 17 2016 08:11
@williamquan playerNumber = 16;
Humphrey
@Humphreto
Mar 17 2016 08:11
@nikosalonen I don't know if that is the one but some coding geeks are talking about. so I thought it was a good Idea if I know what is it and how it works. probably it is the templating language.
ManBearPigg
@ManBearPigg
Mar 17 2016 08:12
@gonardfreeman but it returns what
Dmytro Bondarenko
@gonardfreeman
Mar 17 2016 08:12
@ManBearPigg on test of 4,1 and 1,1, error, but output returns what i need
@ManBearPigg "hole-in-one"