These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Mar 2016
Matthew Stettner
@mstettner
Mar 05 2016 00:00
or technincally myNoun, myAdjective, myVerb, myAdverb) {
Blauelf
@Blauelf
Mar 05 2016 00:00
@mstettner As long as you use all of the arguments, yes, and they have to appear as words in the final sentence, separated. Any order, just have to be contained.
E
@efhjones
Mar 05 2016 00:00
@moigithub a quarter is 3 months I think (quarter of a year)
So he's saying he can evaluate the US GDP in chunks of 3 months, over time
OK I gotta go. See you soon everyone...
Moisés Man
@moigithub
Mar 05 2016 00:03
@efhjones ok ty :)
scharla
@scharla
Mar 05 2016 00:06
function translate(str) {
  var vowels = ["a", "e", "i", "o", "u", "y"];
var arr = str.split("");

  for (var x = 0; x < vowels.length; x++) {


  if (arr.indexOf(vowels[x]) === 0) 
    {
      str2 = str + "way";
      break;
      }

    if (arr.indexOf(vowels[x]) === 1) {
      str2 = str.substr(1,str.length) + str.substr(0,1) + "ay";
    }
      else if (arr.indexOf(vowels[x]) === 2) {
      str2 = str.substr(2,str.length) + str.substr(0,2) + "ay";


      }

  }
  return str2;
}

translate("california") ;
Hey, this seems to have worked, but does anyone know how to shorten/ loop the last two conditions? Did you do this through a array instead of string?
Also doesn't take into account admittedly rare instances of three + consonants at the beginning of a word
Matthew Stettner
@mstettner
Mar 05 2016 00:08
@Blauelf any closer?
var myStr = "Have you seen my " + myNoun + "who is " + myAdjective + "and has" + myVerb + "by you" + myAdverb + ", becuase he is crazy!";
Blauelf
@Blauelf
Mar 05 2016 00:10
Have you looked at the output?
Pedro Abel Díaz Sánchez
@coderHook
Mar 05 2016 00:10
Is there any way to store reGex into an array so for one string i can chech if it match with any of the array[i] ?
Matthew Stettner
@mstettner
Mar 05 2016 00:11
@Blauelf there is no out put
where would the output be?
Im super confused and dont know what is supposed t be happening
Blauelf
@Blauelf
Mar 05 2016 00:11
"Have you seen my dogwho is bigand hasranby youquickly, becuase he is crazy!"
Matthew Stettner
@mstettner
Mar 05 2016 00:12
@Blauelf is that how it is being read
by JS
Blauelf
@Blauelf
Mar 05 2016 00:12
There are some spaces missing, don't you think?
That's what would be constructed using the big-dog-ran-quickly sample.
Matthew Stettner
@mstettner
Mar 05 2016 00:12
@Blauelf to be honest it looks completly fine to me
but evidently it needs more pace
space*
@Blauelf so I just need to add more spacing between dogwho
etc
Blauelf
@Blauelf
Mar 05 2016 00:15
Those are a few, but, yes.
Matthew Stettner
@mstettner
Mar 05 2016 00:15
yeah I dunno what to do. I added spaces and no luck. What else am I missing
Is there something you can reference online that would show me how this is supposed to be done
Blauelf
@Blauelf
Mar 05 2016 00:16
Dumb question: Do you return that string?
Matthew Stettner
@mstettner
Mar 05 2016 00:16
not sure what that means
how do I return the string?
Blauelf
@Blauelf
Mar 05 2016 00:17
Do you have a return statement inside the function, that returns the string?
Matthew Stettner
@mstettner
Mar 05 2016 00:18
do i need a reciept lol?
No I do not and I dont know what that means
oh god I am struggling
Blauelf
@Blauelf
Mar 05 2016 00:18
var str = "Foo Bar";
return str;

or

return "Foo Bar";

Something like that

Matthew Stettner
@mstettner
Mar 05 2016 00:18
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

 var myStr = "Have you seen my " + myNoun +  "who is "  + myAdjective +  "and has" + myVerb +  "by you"  + myAdverb + ", becuase he is crazy!";






  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly")
I have this ^
what is foo bar?
Blauelf
@Blauelf
Mar 05 2016 00:19
You assign to myStr, but are returning result. Change that to result = "Have...
Matthew Stettner
@mstettner
Mar 05 2016 00:20
like this
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

 var myStr = "Have you seen my " + myNoun +  "who is "  + myAdjective +  "and has" + myVerb +  "by you"  + myAdverb + ", becuase he is crazy!";






  // Your code above this line
  return result "Have you seen my " + myNoun +  "who is "  + myAdjective +  "and has" + myVerb +  "by you"  + myAdverb + ", becuase he is crazy!";
 ;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Blauelf
@Blauelf
Mar 05 2016 00:20
It's just a sample string. I used that to show a pattern, which I found in a wrong way in your code, not assigning to and returning the same variable.
No.
Matthew Stettner
@mstettner
Mar 05 2016 00:20
I dont know if I am following you
Blauelf
@Blauelf
Mar 05 2016 00:20
You are not meant to change the line after // Your code above this line.
Matthew Stettner
@mstettner
Mar 05 2016 00:21
oky
should this be so hard??
Brandon Lee
@brandonlee781
Mar 05 2016 00:21
So a couple people tried helping me earlier with this but I had to leave before I figured it out. I'm stuck on the Profile Lookup challenge. The task is to create a function that looks through an array of objects for a specific name, if it finds that name, and that name has a given property to display the properties values. What I have written though never makes it past the first if statement
function lookUp(firstName, prop){
// Only change code below this line
  for (var i = 0;i < contacts.length;i++) {
    if (contacts[i].firstName !== firstName) {
      return "No such contact";
    } else if (contacts[i][prop] === "") {
      return "No such property";
    } else if (contacts[i].firstName === firstName && contacts[i][prop] !== "") {
      return contacts[i][prop];
    }
  }
// Only change code above this line
}
Blauelf
@Blauelf
Mar 05 2016 00:21
@mstettner You assign to one variable, return another. The name of the variable to return is given, so assign to that one instead of myStr.
Matthew Stettner
@mstettner
Mar 05 2016 00:23
var myResult?
Blauelf
@Blauelf
Mar 05 2016 00:23
@brandonlee781 First, remember hasOwnProperty from another challenge?
@mstettner result. The variable is named result. No my.
Brandon Lee
@brandonlee781
Mar 05 2016 00:23
@Blauelf Oh my gosh, thank you! I completely forgot about that
CamperBot
@camperbot
Mar 05 2016 00:23
brandonlee781 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1352 | @blauelf | http://www.freecodecamp.com/blauelf
Matthew Stettner
@mstettner
Mar 05 2016 00:23
does it still need var
result = "Have you seen my " + myNoun + "who is " + myAdjective + "and has" + myVerb + "by you" + myAdverb + ", becuase he is crazy!";
Alan Campos
@AlphaSpectrum
Mar 05 2016 00:24
What's wrong with this? Challenge name => Profile Lookup
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

    for (var j = 0; j < contacts.length; j++){
    if (contacts[j].firstName === firstName && contacts[j][prop]) {

      return contacts[j][prop];

    } else if (!contacts[j][firstName]) {

      return "No such contact";

    } else if (!contacts[j][prop]) {

      return "No such property";
    }

  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "likes");
Blauelf
@Blauelf
Mar 05 2016 00:24
@brandonlee781 Then, it's not a good idea to return "No such contact" before you have checked all names. Return that outside the loop.
@AlphaSpectrum Just read what I wrote to @brandonlee781, same mistakes, plus a few other.
Matthew Stettner
@mstettner
Mar 05 2016 00:25
@Blauelf this looking better?
result = "Have you seen my " + myNoun + "who is " + myAdjective + "and has" + myVerb + "by you" + myAdverb + ", becuase he is crazy!";
Blauelf
@Blauelf
Mar 05 2016 00:26
@mstettner Much better, but I guess it still needs a few space characters inside the strings. Do you now see one output when running the tests?
Matthew Stettner
@mstettner
Mar 05 2016 00:27
oh yes I do!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Blauelf
@Blauelf
Mar 05 2016 00:27
:)
Matthew Stettner
@mstettner
Mar 05 2016 00:27
so i gotta figure out some spacing
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:27
can someone help
function largestOfFour(arr) {
  // You can do this!
  var result = [];

  for (var i = 0; i < arr.length; i++){
  var largestNumber = 0;
    for(var j=0; j < arr.length; j++){
      if(largestNumber<arr[i][j]){
        result=arr[i][j];
        }
    }
    result.push(largestNumber);
   return result;

}


}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
theres an error saying result.push is not a function what do i do?
Blauelf
@Blauelf
Mar 05 2016 00:28
@mstettner If you do not want to rely on the FCC console, you can use console.log() to print to your browser's console (usually accessed by Ctrl+Shift+I or F12)
Matthew Stettner
@mstettner
Mar 05 2016 00:28
@Blauelf okay forst of all thank you very much for sticking with me there
CamperBot
@camperbot
Mar 05 2016 00:28
mstettner sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1353 | @blauelf | http://www.freecodecamp.com/blauelf
Matthew Stettner
@mstettner
Mar 05 2016 00:29
now i have a couple quetsions @Blauelf
is that control+ shift + i
or l
Blauelf
@Blauelf
Mar 05 2016 00:30
@Mahin2k Several problems. j should be < arr[i].length, then you assign to result instead of largestNumber, then move your return statement out of the loop, as it ends the function.
Matthew Stettner
@mstettner
Mar 05 2016 00:30
where do I out this?
console.log()
Blauelf
@Blauelf
Mar 05 2016 00:31
@mstettner Uppercase i (my keyboard has uppercase letters printed on it, so I assume keys are referenced using those)
Matthew Stettner
@mstettner
Mar 05 2016 00:31
@Blauelf
when I hit control+ shift + I nothing happens
Snowysun
@Snowysun
Mar 05 2016 00:31

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

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

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

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

Matthew Stettner
@mstettner
Mar 05 2016 00:32
@Blauelf i want to see my browsers console
i have a mac
DJ
@qualitymanifest
Mar 05 2016 00:32
@mstettner try f12
Blauelf
@Blauelf
Mar 05 2016 00:32
@mstettner Tried F12? What is your browser?
For using this: You could insert some line console.log(result);, and look at the result on the browser console. It will show outputs for all the tests, too. If you want only one test, use repl.it.
Matthew Stettner
@mstettner
Mar 05 2016 00:33
whoa I hit option command c
Andrew Vanboxel
@avanbox
Mar 05 2016 00:34
any JSON experts have a minute to explain something to me?
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:34
@Blauelf thats not the problem
Matthew Stettner
@mstettner
Mar 05 2016 00:34
@Blauelf that is how to access the browser console on a mac i guess
Blauelf
@Blauelf
Mar 05 2016 00:34
@Mahin2k Which one of the three? The first one is the only one with no consequences.
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:34
the problem is result.push is not recognized as a function
@Blauelf
Matthew Stettner
@mstettner
Mar 05 2016 00:35
what is the benefit of seeing all this? @Blauelf maybe i am not looking at the correct thing
Blauelf
@Blauelf
Mar 05 2016 00:36

@Mahin2k And

you assign to result instead of largestNumber

does not point you to the problem?

Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:38
@Blauelf nope
@Blauelf the problem is .push is not being recognized as a function
Blauelf
@Blauelf
Mar 05 2016 00:38
@mstettner It's just another way of getting information on what is going on in your function. FCC console output is pretty unreliable, especially when it comes to arrays.
@Mahin2k Do you even read what I wrote? You assign to result instead of largestNumber, resulting in result not being an array any more. Fix that line and you will find push.
alpox
@alpox
Mar 05 2016 00:39
Soo... just done with my wiki viewer... any review?
http://codepen.io/alpox/full/qZOVwK/
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:39
@Blauelf yes i did read it
Blauelf
@Blauelf
Mar 05 2016 00:40
Did you go fix the line where you assign to result while you should assign to largestNumber?
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:41
@Blauelf i dont really understand tha
t
@Blauelf assign what?
Blauelf
@Blauelf
Mar 05 2016 00:41
It's largestNumber = arr[i][j];, not result = arr[i][j]; (= is the assignment operator, when doing variable = value, you assign value to variable)
Alan Campos
@AlphaSpectrum
Mar 05 2016 00:41
I still can't solve this challenge
Andrew Vanboxel
@avanbox
Mar 05 2016 00:42
@alpox I havent gotten that far so I dont know the requirements of that project but I love the styling.
@AlphaSpectrum which one? post your code?
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:42
@Blauelf thanks
CamperBot
@camperbot
Mar 05 2016 00:42
mahin2k sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1354 | @blauelf | http://www.freecodecamp.com/blauelf
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 00:42
i get it
but i have another question
Davide
@DavOnGit
Mar 05 2016 00:43
@alpox really nice congrat :clap:
alpox
@alpox
Mar 05 2016 00:43
@avanbox Thanks :D
CamperBot
@camperbot
Mar 05 2016 00:43
alpox sends brownie points to @avanbox :sparkles: :thumbsup: :sparkles:
:star: 286 | @avanbox | http://www.freecodecamp.com/avanbox
alpox
@alpox
Mar 05 2016 00:43
@DavOnGit Thank you too :-)
Alan Campos
@AlphaSpectrum
Mar 05 2016 00:43
@avanbox Challenge Name: Profile Lookup
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][prop]) {
      return "No such property";

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

// Only change code above this line
}
alpox
@alpox
Mar 05 2016 00:44
It seems that i'm in the wrong chat though. it showed me that one even though the codereview was selected o.O weird behaviour today.,..
Blauelf
@Blauelf
Mar 05 2016 00:45
@AlphaSpectrum Use hasOwnProperty. And you cannot return "No such contact" on first name mismatch, as you can only say that after all names were mismatches.
@alpox Happens to me all the time. Have to switch back and forth to get all those things in sync again.
alpox
@alpox
Mar 05 2016 00:46
@Blauelf Well i pressed both buttons many times but both showed the same chat :D
Alan Campos
@AlphaSpectrum
Mar 05 2016 00:46
@Blauelf So two loops?
Blauelf
@Blauelf
Mar 05 2016 00:46
Then a page refresh usually helps.
@AlphaSpectrum No. Return "No such contact" after your loop. If it does not return inside the loop, there obviously was no name match.
Andrew Vanboxel
@avanbox
Mar 05 2016 00:47
@AlphaSpectrum heres what i did

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

  }


// Only change code above this line
}
Blauelf
@Blauelf
Mar 05 2016 00:49
@avanbox First, if (!contacts[i].hasOwnProperty(prop)) is redundant, can be removed. Then, move the line return "No such contact"; to after your loop and you don't have to mess around with some i==contacts.length-1.
Also, that code fails for an empty contacts array, it would return nothing, as the loop would not be executed at least once.
Andrew Vanboxel
@avanbox
Mar 05 2016 00:49
lol i knew there was a better way
my solution usually end up with me adding more and more code until its mess but works, but could have been much simpler
thanks @Blauelf
CamperBot
@camperbot
Mar 05 2016 00:51
avanbox sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1355 | @blauelf | http://www.freecodecamp.com/blauelf
Tony
@Rogers187
Mar 05 2016 00:55
hey need some advice. Im having a real hard time with Basic Algorithm Scripting
i cant even remember how to start my code to get what they want.. Its like i forgot everything i learned in the challenges before it. Any suggestions on how to proceded? Because i can find the answer thats the easy part but its not helping me remember what im suppose to do.
Andrew Vanboxel
@avanbox
Mar 05 2016 00:56
@Rogers187 i went through the challenges a second time after doing a couple projects and it really helped. Also I try (not always successfully), after i get the gren check mark to stop and read my code line by line and making sure i really understand
Sometimes i write the steps down on paper. what should happen first, second, third etc. talk it out. Figure out what should happen for each step, then research how to make it happen.
Tony
@Rogers187
Mar 05 2016 00:58
@avanbox yeah just crazy how some seem to be real easy then i just go blank.
Blauelf
@Blauelf
Mar 05 2016 00:58
@Rogers187 When doing challenges of the Basic Algorithm Scripting style, I try to read the task carefully and imagine how I would do that manually (even test this a bit), break it down into computer-chewable bits, translate it to code. Now for JS, I don't do that on paper any more (used to do that when learning BASIC and PASCAL 20 years ago).
Andrew Vanboxel
@avanbox
Mar 05 2016 00:58
for me its repetition
 json.forEach(function(val) {
var keys = Object.keys(val);
html += "<div class = 'cat'>";
keys.forEach(function(key) {
html += "<b>" + key + "</b>: " + val[key] + "<br>";
});
html += "</div><br>";
});
i really dont understand what line 2 and 4 are doing here....
Snowysun
@Snowysun
Mar 05 2016 01:01
Can someone help me on "Using Objects for Lookups"? This is my first time using the help so I'm not sure how to put my code on here other then pasting it..
Blauelf
@Blauelf
Mar 05 2016 01:01
@avanbox You mean Object.keys and keys.forEach?
Andrew Vanboxel
@avanbox
Mar 05 2016 01:01
yes
@Snowysun put 3``` then hold down shift and press return and paste your code in the middle
omit the #3
Tony
@Rogers187
Mar 05 2016 01:03
@Blauelf im just wondering because ive never read or writing code before that i wont be able to pick it up.
Blauelf
@Blauelf
Mar 05 2016 01:04
@avanbox Object.keys(val) returns the keys of the object val, that is its enumerable own properties. So for {foo:47,bar:11}, it would be an array ["foo","bar"]. Array.forEach calls the callback for each element, but unlike map does not expect the callback to have any return value that it uses, it simply calls the callback.
Snowysun
@Snowysun
Mar 05 2016 01:05

Thanks.

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

  // Only change code below this line
  var lookup = {
    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("alpha");

It keeps returning "Frank" instead of "Adams".

Andrew Vanboxel
@avanbox
Mar 05 2016 01:05
ooook, i think im getting it
Susan Winters
@susanwinters214
Mar 05 2016 01:06
I need help. I've got 3 out of 4 green checkmarks. The 1 wrong says "You should use bracket notation to access the testObj. - - But I did.

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

// Only change code below this line;

var player = testObj[16]; // Change this Line
var playerNumber = Number(testObj[16]); // Change this Line

blackbuddha88
@blackbuddha88
Mar 05 2016 01:07
hi
question
how do i get 0.50 to print out as 0.50 and not as 0.5?
oh, AND keep the number as type 'number' NOT 'string'?
Blauelf
@Blauelf
Mar 05 2016 01:09
@Rogers187 I think most part is breaking things down into clear instructions which can help reproduce a run. Computer is stupid, cannot do complex things on its own, and the good and bad thing is that it will do what you tell it. While the frameworks and libraries are different for each language, the concepts are usually similar (though Pythonians might tell you about the Pythonian way to do things ;)).
@blackbuddha88 Is not possible, but also is not needed, as 0.5===0.50
Alan Campos
@AlphaSpectrum
Mar 05 2016 01:10
@Blauelf I would have assumed JS would have a way to format the output like C++ and Java, no?
blackbuddha88
@blackbuddha88
Mar 05 2016 01:11
@Blauelf thanks.
CamperBot
@camperbot
Mar 05 2016 01:11
blackbuddha88 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1356 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Mar 05 2016 01:12
@AlphaSpectrum Formatted output is a string, as we can read only text, no binary (maybe a text representation of binary).
Andrew Vanboxel
@avanbox
Mar 05 2016 01:12
@AlphaSpectrum seems like toFixed() is the only way but it converts to string i believe
scharla
@scharla
Mar 05 2016 01:13
function pair(str) {
  var arr = str.split("");
  var newArr = [];
  var newArr2 =[];
  obj = {
    A : "T",
    T : "A",
    G : "C",
    C : "G",
  };

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

      var z = obj[arr[x]];
    newArr.push(arr[x]);
    newArr.push(z);  

    }

  return newArr;
}

pair("GCG");
Norman Dela Cruz
@dcnr
Mar 05 2016 01:13
@blackbuddha88 you can try the toFixed number method but it also converts your output to string.
0.5.toFixed(2);
// '0.50'
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 01:13
function end(str, target) {
  var result = "";

  if(str.match(target)){
    return true;

}
  else {
    return false;
  }


}

end("Bastian", "n");
scharla
@scharla
Mar 05 2016 01:13
So, I am getting the right answer - not sure how to format it as a series of arrays though
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 01:13
can someone help?
im not returning false
its only reading the if
Alan Campos
@AlphaSpectrum
Mar 05 2016 01:14
@Blauelf C++ has stringstream(int) that doest the trick. I bet there is a function that can be made in JS that does't the formatting from 0.5 to 0.50
stringstream(string) **
Blauelf
@Blauelf
Mar 05 2016 01:14
@Mahin2k str.match is probably not the way to go. You could use slice or substr to get the last few characters and compare those using string compare.
Alan Campos
@AlphaSpectrum
Mar 05 2016 01:14
Does JS support passing by reference by the way?
Khademul Islam Mahin
@Mahin2k
Mar 05 2016 01:15
@Blauelf thats too much work lol
Blauelf
@Blauelf
Mar 05 2016 01:15
@AlphaSpectrum It probably won't attach a format to a number and leave that number?
scharla
@scharla
Mar 05 2016 01:15
@Mahin2k if (str === target) ??? What are you trying to do?
Norman Dela Cruz
@dcnr
Mar 05 2016 01:15
@AlphaSpectrum you can try toFixed for formatting. Also objects are almost always referenced.
Blauelf
@Blauelf
Mar 05 2016 01:16
@scharla Confirm the Ending challenge
scharla
@scharla
Mar 05 2016 01:16
@Blauelf pair("ATCGA") should return [["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]].
Blauelf
@Blauelf
Mar 05 2016 01:17
    newArr.push([arr[x],z]);
Alan Campos
@AlphaSpectrum
Mar 05 2016 01:17

in C++ you can create a variable reference, therefore you are not making a copy of a variable.

void printcar (cars &car)
{
    cout << car.model << "\n";
    cout << car.year;
}

Is there such option in JS?

&car points to the memory location
scharla
@scharla
Mar 05 2016 01:18
@Blauelf Thank you! I could have thought of that
CamperBot
@camperbot
Mar 05 2016 01:18
scharla sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1357 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Mar 05 2016 01:19
That's not what we are talking about. The problem was that the OP was confused about the number literal 0.50 not being output as 0.50, but as 0.5, where he would not have control over the output.
Alan Campos
@AlphaSpectrum
Mar 05 2016 01:20
I was aware of that, I just wanna know if there are certain limitations to JS
scharla
@scharla
Mar 05 2016 01:20
Can you not specify number of decimal places?
Snowysun
@Snowysun
Mar 05 2016 01:21
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    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("alpha");
Posting this again..I've been stuck on this for around an hour and I can't really find my mistake. Challenge: Using Objects for Lookups, the problem is that it always returns the last line in lookup, instead of others.
Blauelf
@Blauelf
Mar 05 2016 01:21
I can use (0.5).toFixed(2), which would result in a string "0.50", but that's a string. A float cannot have formatting information.
scharla
@scharla
Mar 05 2016 01:22
I see
Blauelf
@Blauelf
Mar 05 2016 01:22
@Snowysun Remove the result= inside lookup, put a result= after the lookup initialization (and use lookup in that line, similar to the example in the task description).
scharla
@scharla
Mar 05 2016 01:24
@Mahin2k What are the instructions?
Blauelf
@Blauelf
Mar 05 2016 01:27
For the lazy people ES6 has introduced a new function: String.endsWith :P
But it is also really easy with ES5, for example using String.slice, String.substr, or as I've learnt a few hours ago, String.indexOf.
Snowysun
@Snowysun
Mar 05 2016 01:32
@Blauelf
Oops, accidently pressed enter.
I don't understand what you mean by putting the result= after the lookup initialization.
DJ
@qualitymanifest
Mar 05 2016 01:33
@Blauelf wouldn't using indexOf for that cause problems if target occurred more than once in str? or am i missing something?
Blauelf
@Blauelf
Mar 05 2016 01:35
var lookup = {
  some: values
};
result = your code; // and here, use lookup
@qualitymanifest indexOf has a second parameter, and if you set that to the difference of the string lengths, it will start searching at the point where target would have to begin:
  return str.indexOf(target, str.length - target.length) !== -1;
Snowysun
@Snowysun
Mar 05 2016 01:37
Doesn't work, all it returns is ```
Oops again.
DJ
@qualitymanifest
Mar 05 2016 01:38
@Blauelf oh nice! didn't know that. tax
CamperBot
@camperbot
Mar 05 2016 01:38
qualitymanifest sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1358 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Mar 05 2016 01:38
@Snowysun Shift+Return for inserting line breaks here in chat?
Snowysun
@Snowysun
Mar 05 2016 01:40
I'm not sure what I did wrong.. but it just returns everything inside lookup.
Blauelf
@Blauelf
Mar 05 2016 01:41
@Snowysun You used lookup and val?
Snowysun
@Snowysun
Mar 05 2016 01:41
Oh, I forgot val, I put it in and now it works, thanks.
scharla
@scharla
Mar 05 2016 01:42
Haha the Boo Who was a bit silly
Jonathan David Forrider
@jd4rider
Mar 05 2016 01:44
@Snowysun remove the 'result =' in all the properties it should read '"alpha" : "Adams", and so on. Don't forget the double quotes around the name of the property.
Tyler Moeller
@TylerMoeller
Mar 05 2016 01:48
Why am I getting undefined for these last two lines?
  var arr2 = arr, value = arr2[0];
  console.log(arr);                   // [ 1, 4, 2, 3, 0, 5 ]
  console.log(arr2);                  // [ 1, 4, 2, 3, 0, 5 ]
  console.log(arr2[0]);               // 1
  console.log(arr.indexOf(1));        // 0
  console.log(arr.indexOf[arr2[0]]);  // undefined
  console.log(arr.indexOf[value]);    // undefined
expecting to see 0...but maybe time for the weekend
Mariya
@mariyadiminsky
Mar 05 2016 01:51
Just a head's up all courses are FREE on https://www.codeschool.com for the next 55hours, until Sunday 11:59PM. I'm not affiliated with them, I just got this in my email. Woohhoo! Take their courses and get better at HTML/CSS, JavaScript, and I also recommend taking the regex course, in the electives. That's what I'm doing now. Enjoy!!
Blauelf
@Blauelf
Mar 05 2016 01:54
@TylerMoeller indexOf has no property "1" (function calls require (), not [])
Tyler Moeller
@TylerMoeller
Mar 05 2016 02:04
Thanks @Blauelf don't know why I couldn't see that typo... :)
CamperBot
@camperbot
Mar 05 2016 02:04
tylermoeller sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1359 | @blauelf | http://www.freecodecamp.com/blauelf
Ryan Park
@rpark4
Mar 05 2016 02:07
//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
  c=0;
  b=0;
  a=0;
  while (a <3 && firstName !== contacts[a].firstName){
    a++ ;
  }
  if (a === 3 && firstName !== contacts[a].firstName){
      return "No such contact";
  }
  else {
    while (c <3 && prop !== contacts[a][c]){
    c++ ;
  }
  if (c === 3 && prop !== contacts[a][c]){
      return "No such property";
  }
  else {
    return contacts[a][c];
  }}}

// Only change code above this line


// Change these values to test your function
lookUp("Akira", "likes");
hi guys
I'm having a hard time with this one. I'm trying to use contacts[a][c], and it's clearly not doing what I think it should be doing
how do I target a specific item in an object using bracket notation with variables?
Davide
@DavOnGit
Mar 05 2016 02:15
@rpark4 contacts[0]['firstName'] gives you 'Akira'
scharla
@scharla
Mar 05 2016 02:15
@rpark4 You need to 1st loop through the contacts to see if there is a contact named Akira and then you can use the index to display her likes.
Ryan Park
@rpark4
Mar 05 2016 02:16
index?
scharla
@scharla
Mar 05 2016 02:17
the number of the entry, in this case 0
ie contacts[0][likes]
Ryan Park
@rpark4
Mar 05 2016 02:19
ok, but in this case, a does equal 0, so why does contacts[a][c] mean the same thing as contacts[0][3]?
why doesn't*
scharla
@scharla
Mar 05 2016 02:19
you can't use a number for a propery I believe, you have to put the name in
so contacts[0][prop]
Ryan Park
@rpark4
Mar 05 2016 02:20
oh!
that changes things
thanks @scharla and @DavOnGit
CamperBot
@camperbot
Mar 05 2016 02:20
rpark4 sends brownie points to @scharla and @davongit :sparkles: :thumbsup: :sparkles:
:star: 392 | @davongit | http://www.freecodecamp.com/davongit
:star: 282 | @scharla | http://www.freecodecamp.com/scharla
Alex
@artitudinale1
Mar 05 2016 02:21
Hi guys , I'm aware this is not good code and the challenge is quite basic....but what I don't understand is that I got at least first result right , but it doesn't turn green - so something I did is wrong but I have no feedback...........I don't want the solution....just a hint...
function rot13(str) { // LBH QVQ VG!
 var increment = 13;

  var myArray = [];
  str.split(" ").map(function(obj){ 
    for (var i =0; i < obj.length; i++){
            if (obj.charCodeAt(i) + increment >= 65 && obj.charCodeAt(i) + increment <= 90){
             myArray.push(String.fromCharCode(obj.charCodeAt(i) + increment).toUpperCase());

      }else if (obj.charCodeAt(i) + increment >= 90 ){
        increment = increment + 6;
        myArray.push(String.fromCharCode(obj.charCodeAt(i) + increment).toUpperCase());
        increment = 13;

      }else{

      }
    }
    myArray.push(' ');
  });
  return  myArray.join('');
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Davide
@DavOnGit
Mar 05 2016 02:22
@rpark4 contacts[0]['prop'] is the same of contacts[0].prop
alpox
@alpox
Mar 05 2016 02:28
@artitudinale1 Why do you add just 6 to increment if the number gets bigger than 90? what sense does that make? :D
scharla
@scharla
Mar 05 2016 02:29
@artitudinale1 what kind of outputs are you getting?
Alex
@artitudinale1
Mar 05 2016 02:31
@alpox I know I didn't take care of that yet .....try to work it out lil by lil; @scharla The first output I have is FREE CODE CAMP and suppose
be right
scharla
@scharla
Mar 05 2016 02:32
@artitudinale1 how about the rest? Are you having problems with any particular characters? It seems like it's just a case of fixing the math in the if statements
Alex
@artitudinale1
Mar 05 2016 02:34
I didn't take care of the ! and the ? that are supposed to show up in the following sting - but I wanted to set right the first result ....and the logic! :P @scharla
*strings
jlcsuf22
@jlcsuf22
Mar 05 2016 02:37
Hello! I need help on Accessing Objects Properties with Bracket Notation
this is what i put and its not working

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj["an entree"]; // hamburger
testObj['the drink']; // water
var entreeValue = "hamburger"
var drinkValue = "water"

these are the requirements
entreeValue should be a string
The value of entreeValue should be "hamburger"
drinkValue should be a string
The value of drinkValue should be "water"
You should use bracket notation twice
can u guys help me out what i did wrong?
or missing?
alpox
@alpox
Mar 05 2016 02:38
@artitudinale1 Btw. map returns an array with the computed returns of the given function. You don't need a special array to store the values
Alex
@artitudinale1
Mar 05 2016 02:40
ok @alpox I thought of that - even because putting bk space with myArray.push(' '); sounds kind of really wrong - nop?
alpox
@alpox
Mar 05 2016 02:41

@jlcsuf22 Well... you have to assign the values from the accessing to the variables.

testObj["an entree"]; // hamburger
testObj['the drink']; // water

You don't store any values here

Sidharth Kriplani
@sidkrip
Mar 05 2016 02:41
wiki Boo Who
CamperBot
@camperbot
Mar 05 2016 02:41

:point_right: algorithm boo who [wiki]

Problem Explanation:

  • This program is very simple, the trick is to understand what a boolean primitive is. The programs requires a true or false answer.

:pencil: read more about algorithm boo who on the FCC Wiki

alpox
@alpox
Mar 05 2016 02:41
@artitudinale1 Well if you need to store it in an array its not so wrong but here you really don't need one
Alex
@artitudinale1
Mar 05 2016 02:43
@alpox ok - I will try to work I lil more on this and try it without the array
jlcsuf22
@jlcsuf22
Mar 05 2016 02:44
oh i see @alpox , but when i hit run it shows like this
testObj["an entree"]; // hamburger
testObj['the drink']; // water
testObj["an entree"]; // hamburger
testObj['the drink']; // water
drinkValue = '[object Object]'
apparently, the
drinkValue should be a string
The value of drinkValue should be "water"
does not work
scharla
@scharla
Mar 05 2016 02:47
@artitudinale1 I'm unfortunately no expert, having just solved that one yesterday, but you can simplify things by converting the entire string to uppercase first. This gives you less characters to work with
If this helps what I've done is push all the numbers in
alpox
@alpox
Mar 05 2016 02:49
@jlcsuf22 drinkValue = '[object Object]' what are you doing there?
scharla
@scharla
Mar 05 2016 02:49
into an array, then filter through the numbers (some go up 13, some go down 13, some stay the same, and then pushed the updated array into a string. There are probably more elegant solutions though.
alpox
@alpox
Mar 05 2016 02:49
@jlcsuf22 You are still not assigning the values to any variable!
Alex
@artitudinale1
Mar 05 2016 02:50
@scharla Thanks! yep that helps - I will try
CamperBot
@camperbot
Mar 05 2016 02:50
artitudinale1 sends brownie points to @scharla :sparkles: :thumbsup: :sparkles:
:star: 283 | @scharla | http://www.freecodecamp.com/scharla
scharla
@scharla
Mar 05 2016 02:52
@artitudinale1 also, I see you are trying to pass letters into an array as you're going along - this makes it harder. Keep your array numbers only and once you have the right values you can just convert it into a string with String.fromCharCode(array values)
Alex
@artitudinale1
Mar 05 2016 02:53
@scharla yep! make sense :P
scharla
@scharla
Mar 05 2016 02:54
Good luck :)
Alex
@artitudinale1
Mar 05 2016 02:55
Thanks much needed! :)
Sidharth Kriplani
@sidkrip
Mar 05 2016 02:58
anyone done with the bonfire Boo Who?
sigursiguros
@sigursiguros
Mar 05 2016 03:17
@sigursiguros
Hi guys, my pen is working property on a desktop but when I move to an iphone, the hyperlinks, scroll spy don't work. Any ideas?
http://codepen.io/Sigursiguros/pen/wGaEdg
David Weedmark
@DavidWeedmark
Mar 05 2016 03:29
grrr this is happening far too often. why is it ignoring the "else" part of my else if statement and performing both actions instead of one?
  for (var j=0; j<availMoves.length+1; j++) 
    if (availMoves[j] == 5) {document.getElementById("5").innerHTML = autoClick}

     else if (corners.length > 0) {rand = corners[Math.floor(Math.random() * corners.length)]}
NaifAlrashed
@NaifAlrashed
Mar 05 2016 03:31
@DavidWeedmark that's because your for loop needs to have curly braces
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:32
@NaifAlrashed can you help me with a RegExp problem?
NaifAlrashed
@NaifAlrashed
Mar 05 2016 03:35
@sidkrip Which part is that problem in?
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:36
cant replace spaces with hyphen
this is my code:
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  var stringer;
  stringer=str.toLowerCase();
  var newStr;
  newStr=stringer.replace(/ /g, '-');
  newStr=stringer.replace(/_/g, '-');
  return newStr;
}
it works for underscores but not for "thisIsSpinalTap"
NaifAlrashed
@NaifAlrashed
Mar 05 2016 03:38
@sidkrip spaces use \s and not " "
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:38
or for any case other than "The_Andy_Griffith_Show"
should I modify the code like this:
newStr=stringer.replace(/\s/g, '-');
David Weedmark
@DavidWeedmark
Mar 05 2016 03:40
@NaifAlrashed you mean like this?
  for (var j=0; j<availMoves.length+1; j++) {
    if (availMoves[j] == 5) {document.getElementById("5").innerHTML = autoClick}

     else if (corners.length > 0) {rand = corners[Math.floor(Math.random() * corners.length)]}
  };
NaifAlrashed
@NaifAlrashed
Mar 05 2016 03:40
@DavidWeedmark yes but without the semicolon at the end
DJ
@qualitymanifest
Mar 05 2016 03:41
@sidkrip
  newStr=stringer.replace(/ /g, '-');
  newStr=stringer.replace(/_/g, '-'); // your problem lies here
@sidkrip with the second replace, you're getting rid of the value you got with your first replace. since you're reassigning newStr and giving it a different value, which is stringer with ONLY underscores replaced
you won't need to replace / /g with /\s/g
Norman Dela Cruz
@dcnr
Mar 05 2016 03:42

@sidkrip stringer is your lowercased string, you're replacing the spaces with

newStr=stringer.replace(/ /g, '-');

and assigning the value to newStr but on your next line, you are doing

newStr=stringer.replace(/_/g, '-');

you are taking stringer again (with the spaces intact), and just replacing the the _ and then assigning it to newStr. That's why when you return newStr; you're only getting the replaced underscores.

David Weedmark
@DavidWeedmark
Mar 05 2016 03:42
@NaifAlrashed no, that's not it
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:43
so how do I combine both the results? @qualitymanifest
DJ
@qualitymanifest
Mar 05 2016 03:43
@sidkrip after you do the first replace of stringer, where you get rid of spaces, you want to replace the underscores on newStr
bitgrower
@bitgrower
Mar 05 2016 03:43
just fyi -- codeschool.com is having a free weekend ...
Norman Dela Cruz
@dcnr
Mar 05 2016 03:43
heya @bitgrower :cake:
bitgrower
@bitgrower
Mar 05 2016 03:44
hi @dcnr ...
DJ
@qualitymanifest
Mar 05 2016 03:44
newstr -> stringer with spaces replaced. then, newstr -> newstr with underscores replaced
bitgrower
@bitgrower
Mar 05 2016 03:45
I've been going thru their jQuery section ... my brain is :boom:
DJ
@qualitymanifest
Mar 05 2016 03:45
it's a bit verbose still, but that will work for those cases
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:45
oh, yes. Then there is this last case of "thisIsSPinalTap"
  • "thisIsSpinalTap"
DJ
@qualitymanifest
Mar 05 2016 03:47
yep. you'll probably want to toLowerCase() AFTER you add your dashes, so you can see where you want to add the dashes in (before the uppercased letters)
Alex Mancheno
@alexmancheno
Mar 05 2016 03:48
Can someone help me out with the "Escape Sequences in Strings" challenge?
bitgrower
@bitgrower
Mar 05 2016 03:48
help Escape Sequences
CamperBot
@camperbot
Mar 05 2016 03:48

:point_right: challenge escape sequences in strings [wiki]

Escape Sequences in Strings

Quotes are not the only characters that can be escaped inside a string. Here is a table of common escape sequences:

Code Output
\' single quote
\" double quote
\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed

Note that the backslash itself must be escaped in order to display as a backslash.

:pencil: read more about challenge escape sequences in strings on the FCC Wiki

bitgrower
@bitgrower
Mar 05 2016 03:49
oh @dcnr ... what's the url to your seek & destroy info ?
Norman Dela Cruz
@dcnr
Mar 05 2016 03:50
@bitgrower arguments object wiki?
Vik
@vvang044
Mar 05 2016 03:50
hello everyone!
bitgrower
@bitgrower
Mar 05 2016 03:50
I guess ? whichever page that was where you took some of my suggestions and added them ... (I'm creating a compendium of help links)
evening @vvang044
LuciusR11
@LuciusR11
Mar 05 2016 03:51

How do I get the function to count all the cards in the counting cards challenge instead of just reading the last card? My code: switch(card){
case (card < 6):
count += 1;
break;
case (card < 9):
count += 0;
break;
case (card === [10, 'J', 'Q', 'K', 'A']):
count -= 1;
break;
}
if (count > 0){
return count + " Bet";
}else{
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(4); cc(5); cc(6);

Vik
@vvang044
Mar 05 2016 03:51
evening
Norman Dela Cruz
@dcnr
Mar 05 2016 03:51
@bitgrower here's my arguments object one and the accessing objects with dot and bracket one.
Vik
@vvang044
Mar 05 2016 03:51
i need help as usual.....i am working on palindrome.....i managed to write it for a word but couldnt get it for a sentence or special characters
bitgrower
@bitgrower
Mar 05 2016 03:51
@LuciusR11 -- you have to have separate case statements for each value
Alex Mancheno
@alexmancheno
Mar 05 2016 03:52
Still need hep with "Escape Sequences in Strings" challenge :/
bitgrower
@bitgrower
Mar 05 2016 03:52
@vvang044 -- then use a regex ahead of time to clean up the string before applying your working algo ...
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:52
@qualitymanifest oh, yes.
still, how should I use RegExp to insert dashes before the capital letters?
bitgrower
@bitgrower
Mar 05 2016 03:52
@alexmancheno ... what do you have (post your code, please)
Alex Mancheno
@alexmancheno
Mar 05 2016 03:53
var myStr = \ \t \t \r \n;
bitgrower
@bitgrower
Mar 05 2016 03:53
well -- it helps to put quotes around your stings, for one ... :)
Vik
@vvang044
Mar 05 2016 03:53
the helpful hint was string.replace()......
Alex Mancheno
@alexmancheno
Mar 05 2016 03:54
@bitgrower right!
var myStr = " \ \t \t \r \n ";
this is what I have now, still won't work
bitgrower @bitgrower adds to her list of desirable traits in programmers: first we had humility -- next, I'll add patience ... :)
bitgrower
@bitgrower
Mar 05 2016 03:55
what are the instructions, @alexmancheno ?
Alex Mancheno
@alexmancheno
Mar 05 2016 03:56
@bitgrower "Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr"
bitgrower
@bitgrower
Mar 05 2016 03:56
so all of those are "characters" which need to be escaped
how do you escape a backslash ?
Alex Mancheno
@alexmancheno
Mar 05 2016 03:57
I am not sure :/
bitgrower
@bitgrower
Mar 05 2016 03:58
@vvang044 -- so, have you brushed up on using string.replace() ?
@alexmancheno -- how do you escape any character ?
Sidharth Kriplani
@sidkrip
Mar 05 2016 03:58
@bitgrower can you help me with Spinal Tap Case?
Alex Mancheno
@alexmancheno
Mar 05 2016 03:58
\' \'?
bitgrower
@bitgrower
Mar 05 2016 03:58
@sidkrip -- not sure I can tonight ... :(
hmmm ... okay, I like the thinking ... but how do you escape ANY character ? what is the meta character used to indicate the next character is "special"
Vik
@vvang044
Mar 05 2016 04:00
@bitgrower a little.....still quite dont get it why we are using
bitgrower
@bitgrower
Mar 05 2016 04:01
@vvang044 -- to create a string which doesn't have characters we don't want -- or ... conversely -- only has the characters we want ...
Alex Mancheno
@alexmancheno
Mar 05 2016 04:01
@bitgrower is it just \?
bitgrower
@bitgrower
Mar 05 2016 04:02
string.replace -- and it's buddy regex, are a beauty and power to behold ... power to bow down in front of and stand in awe of ...
@alexmancheno ... yep
so ... normally, the \ (backslash) has a special meaning ... but if I want to REMOVE the special meaning, then I escape the backslash character ...
make sense ?
Sidharth Kriplani
@sidkrip
Mar 05 2016 04:03
wiki Finders Keepers
CamperBot
@camperbot
Mar 05 2016 04:03

:point_right: algorithm finders keepers [wiki]

Explanation:

The problem is quite simple to understand. You will check for each element in the array that is passed in the first argument, if the element plugged in to the function passed as the second argument returns true the first time. We do not care about the second or third one that is true, only the very first one if any. If there are none, then return undefined. This last bit is not explained but it is part of the tests used.

:pencil: read more about algorithm finders keepers on the FCC Wiki

LuciusR11
@LuciusR11
Mar 05 2016 04:04
@bitgrower Sorry to keep bothering you, I'm sure you're busy trying to help everyone, could you maybe just elaborate a bit more on what you said to me earlier.
bitgrower
@bitgrower
Mar 05 2016 04:04
@LuciusR11 -- remind me of what I said, please ?
Alex Mancheno
@alexmancheno
Mar 05 2016 04:04
@bitgrower so we remove the special meaning but just adding another backslash?
bitgrower
@bitgrower
Mar 05 2016 04:05
yep, @alexmancheno
Alex Mancheno
@alexmancheno
Mar 05 2016 04:05
@bitgrower ah, okay. Thanks!!
CamperBot
@camperbot
Mar 05 2016 04:05
alexmancheno sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 715 | @bitgrower | http://www.freecodecamp.com/bitgrower
LuciusR11
@LuciusR11
Mar 05 2016 04:05
You said I had to separate the case for each value, I'm not quite sure what you mean by that.
var count = 0;
switch(count){
case (cc(2)):
count += 1;
break;
case (cc(3)):
count += 1;
break;
case (cc(4)):
count += 1;
break;
case (cc(5)):
count += 1;
break;
case (cc(6)):
count += 1;
break;
case (cc(7)):
count += 0;
break;
case (cc(8)):
count += 0;
break;
case (cc(9)):
count += 0;
break;
case (cc(10)):
count -= 1;
break;
case (cc('J')):
count -= 1;
break;
case (cc('Q')):
count -= 1;
break;
case (cc('K')):
count -= 1;
break;
case (cc('A')):
count -= 1;
break;
}
if (count > 0){
return count + " Bet";
}else{
return count + " Hold";
}
bitgrower
@bitgrower
Mar 05 2016 04:06
well .. there is one thing you CAN do ...
LuciusR11
@LuciusR11
Mar 05 2016 04:06
I tried to write out each individual value, but it said I exceeded the stack size
bitgrower
@bitgrower
Mar 05 2016 04:07

which is you can stack various cases which do the same thing on top of each other ...

eg

case 'Q':
case 'K':
     <do something>
     break;
LuciusR11
@LuciusR11
Mar 05 2016 04:08
That might just work, I'll try it, thanks.
bitgrower
@bitgrower
Mar 05 2016 04:08
:) @LuciusR11 -- you are probably recursing on the function cc ... no need to call it on the case statements ...
yw
oh .. btw thanks for the links @dcnr ... (where'd you go, anyway?)
CamperBot
@camperbot
Mar 05 2016 04:09
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 757 | @dcnr | http://www.freecodecamp.com/dcnr
LuciusR11
@LuciusR11
Mar 05 2016 04:09
Yeah I thought I might be doing something wrong there but I said what the hell and tried it.
bitgrower
@bitgrower
Mar 05 2016 04:09
soak up all the info you can from the examples & instructions, @LuciusR11 -- it will make your life considerably easier ... :)
LuciusR11
@LuciusR11
Mar 05 2016 04:10
Yeah I've been looking back to see what I can do.
Norman Dela Cruz
@dcnr
Mar 05 2016 04:12
thanks too! bit busy @bitgrower aah why is there only so much time in a day :/
CamperBot
@camperbot
Mar 05 2016 04:12
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 716 | @bitgrower | http://www.freecodecamp.com/bitgrower
Sidharth Kriplani
@sidkrip
Mar 05 2016 04:12
@dcnr help me with the Spinal Tap Case?
bitgrower
@bitgrower
Mar 05 2016 04:15
well ... hope it is productive busy ... :)
Norman Dela Cruz
@dcnr
Mar 05 2016 04:15
I'm sorry @sidkrip I have to go... I suggest reading up on regex though, try this site and look up backreferences!
Sidharth Kriplani
@sidkrip
Mar 05 2016 04:16
@dcnr cant get it even then
Norman Dela Cruz
@dcnr
Mar 05 2016 04:16
bye @bitgrower have a good /night|day/ !
bitgrower
@bitgrower
Mar 05 2016 04:19
you too, @dcnr !!!
LuciusR11
@LuciusR11
Mar 05 2016 04:32
Thanks for all your help @bitgrower, it turns out I had a < instead of a <= in a few places, I guess you should never read over your code too quickly.
CamperBot
@camperbot
Mar 05 2016 04:32
luciusr11 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 717 | @bitgrower | http://www.freecodecamp.com/bitgrower
Vik
@vvang044
Mar 05 2016 04:38
who completed palindrome in here?
Catalin Scripcariu
@CatalinScr
Mar 05 2016 04:40
help Exact Change
CamperBot
@camperbot
Mar 05 2016 04:40

: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
Daniel J. Bray
@kekkerslawl
Mar 05 2016 04:48
@vvang044 I have.
Vik
@vvang044
Mar 05 2016 04:50
palindrome("0_0 (: /-\ :) 0-0") should return true......i couldnt get this to pass
nor a palindrome sentense
Daniel J. Bray
@kekkerslawl
Mar 05 2016 04:51
the '_' is throwing it off, you have to replace it as well
i had an issue with that test too
Vik
@vvang044
Mar 05 2016 04:52
ok here is my code
function palindrome(str) {
  // Good luck!

  var palindrome = str.replace(/\W/g).toLowerCase().split("").reverse().join("");

  if( palindrome=== str){

  return true;
  }
  return false;
}

palindrome("eye");
Daniel J. Bray
@kekkerslawl
Mar 05 2016 04:53
Looks good, except for the 'W' in the regex doesn't check for the '_'
you have to modify the regex to include an underscore character alo
also*
Robert Richey
@0x0936
Mar 05 2016 04:53
.replace() takes a second argument - the string with which to replace all matching first arguments
Daniel J. Bray
@kekkerslawl
Mar 05 2016 04:53
that too ^^
Vik
@vvang044
Mar 05 2016 04:54
hmmm
do i need to type _ to it?
Daniel J. Bray
@kekkerslawl
Mar 05 2016 04:56
check this site out: regexr.com
type in your string in the bottom box, and then play around with different combinations to find the correct regex to find all non alphanumeric character's and the underscore. that's what I did.
and like @0x0936 said, you have to include the second argument in the replace() method
Vik
@vvang044
Mar 05 2016 04:59
i fixed that
let me play around at regex site
bitgrower
@bitgrower
Mar 05 2016 05:01

@vvang044 ... also some of these may be helpful ...

help regex resource

help regex
CamperBot
@camperbot
Mar 05 2016 05:02

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

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

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

Vik
@vvang044
Mar 05 2016 05:02
i thought you left @bitgrower
bitgrower
@bitgrower
Mar 05 2016 05:02
room's still open -- I'm going back and forth between codeschool & here ...
CamperBot
@camperbot
Mar 05 2016 05:02

rooms

See all the FreeCodeCamp rooms at gitter.im/FreeCodeCamp/rooms
Or check this wiki article for a shortlist
bitgrower
@bitgrower
Mar 05 2016 05:03
stretching my brain on jQuery ...
Vik
@vvang044
Mar 05 2016 05:10
this palindrome is not joke....my brain is fried
bitgrower
@bitgrower
Mar 05 2016 05:11
@vvang044 ... what have you tried ?
Vik
@vvang044
Mar 05 2016 05:13
i tried this ([/W_-/g,'')
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:14
str.replace([/W_-/g,'');
?
bitgrower
@bitgrower
Mar 05 2016 05:15
um ... let's see your complete code ?
DJ
@qualitymanifest
Mar 05 2016 05:16
@vvang044 you're missing a ] in that replace
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:17
should look something like this:
str.replace(/[\W??]/g, '');
something else goes where the two '?'s are
DJ
@qualitymanifest
Mar 05 2016 05:17
This message was deleted
Vik
@vvang044
Mar 05 2016 05:19
ok here is my complete code.....
function palindrome(str) {
  // Good luck!

  var palindrome = str.toLowerCase().replace(/[\W-_]/g,'').split("").reverse().join("");

  if( palindrome === str){

  return true;
  }
  return false;
}

palindrome("eye");
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:20
the '-' is wrong after the W
Vik
@vvang044
Mar 05 2016 05:21
even if i do just the underscore....still doesnt pass
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:22
replace the dash with a \
Jonibek
@J0nibek
Mar 05 2016 05:22
Hi, I do not understand what the problem is - TypeError: arr.shift is not a function
bitgrower
@bitgrower
Mar 05 2016 05:22
@J0nibek -- it means that arr is not currently an array ...
Jonibek
@J0nibek
Mar 05 2016 05:23

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

arr = arr.push(item);
var number = arr[0];
arr = arr.shift();
return number; // Change this line
}

Vik
@vvang044
Mar 05 2016 05:24
/[\W a\ _]/g
bitgrower
@bitgrower
Mar 05 2016 05:24

whenever you get an "is not a function" -- it means the type of your variable does not have that method ...

...however, practically, it's easier to just reverse it .. it means if you are trying to use a method of a particular data type, it means the variable is not currently of that type ...

@J0nibek -- that's one way to approach the problem .. you basically have the right 2 array methods, in the right order ...

you may want to review the MDN pages on push & shift ...

Bryan Castleman
@castlemaninc
Mar 05 2016 05:25
When should I think to attempt to write a recursive function?
I'm on the Chunky Monkey (Basic Algorithm) challenge. I'm thinking this might be a good time. But, I'm a newb at this.
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:25
@vvang044 not 'a\' just '\'
Vik
@vvang044
Mar 05 2016 05:26
haha
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:26
lol
Jonibek
@J0nibek
Mar 05 2016 05:26
@bitgrower thanks!
CamperBot
@camperbot
Mar 05 2016 05:26
j0nibek sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 718 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 05 2016 05:26
@castlemaninc -- recursion would be overkill for chunky monkey ... wait until you get to the problems using factorials ...
Vik
@vvang044
Mar 05 2016 05:26
sorry i tried still no luck
bitgrower
@bitgrower
Mar 05 2016 05:26
factorials are such a nice clean way to get comfortable with recursion ... really, such a nice problem ... :)
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:26
whats your full code now @vvang044
bitgrower
@bitgrower
Mar 05 2016 05:27
recursion CAN be the answer in some cases, and it's worth knowing ... but often iterative solutions are faster both in terms of time & space ...
Vik
@vvang044
Mar 05 2016 05:27
function palindrome(str) {
  // Good luck!

  var palindrome = str.toLowerCase().replace(/[\W \ _]/g,'').split("").reverse().join("");

  if( palindrome === str){

  return true;
  }
  return false;
}

palindrome("eye");
Bryan Castleman
@castlemaninc
Mar 05 2016 05:27
@bitgrower , yeah, I've been looking at the codecademy example with factorials, but I'm not sure I quite understand when to use it.
Vik
@vvang044
Mar 05 2016 05:27
something simple can be so painful mistake.......
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:27
@vvang044 eliminate the spaces in the regex
regex is like one big run on sentence
bitgrower
@bitgrower
Mar 05 2016 05:28
@castlemaniac -- let me see if I can find the page I came across on recursion that I rather liked ... I've decided you want to think of the "bottom" first ... IOW, how are you going to exit the recursion ... then build up from there ...
Vik
@vvang044
Mar 05 2016 05:29
i did.... still a no go....:(
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:29
@bitgrower have you checked out Khan Academy's section on recursion? I thought it was pretty good.
Vik
@vvang044
Mar 05 2016 05:29
apart from regex is the rest of the code ok?
Bryan Castleman
@castlemaninc
Mar 05 2016 05:30
@bitgrower @kekkerslawl I'll take any advice I can get. I'll check the Khan Academy page too. Thanks.
CamperBot
@camperbot
Mar 05 2016 05:30
castlemaninc sends brownie points to @bitgrower and @kekkerslawl :sparkles: :thumbsup: :sparkles:
:star: 337 | @kekkerslawl | http://www.freecodecamp.com/kekkerslawl
:star: 719 | @bitgrower | http://www.freecodecamp.com/bitgrower
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:30
@vvang044 i think that 'str' is still the same, you have to run the regex through it as well
bitgrower
@bitgrower
Mar 05 2016 05:31
@kekkerslawl -- no, I haven't ... I really didn't want to go thru videos ... I wanted a basic algo that I could use to create recursion ... I understand recursion ... just have had trouble coding it ... with the ibm page, I got the tools I needed ...
this is an excellent little tutorial on regex ... they have a beginning one, and then a more advanced one that follows it (which includes making regexes for US phone numbers)
Vik
@vvang044
Mar 05 2016 05:32
@kekkerslawl sorry i dont understand
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:33
@vvang044 what your function is doing is comparing the reversed string without all the extra characters, with the original old string
bitgrower
@bitgrower
Mar 05 2016 05:33
@vvang044 -- it was passing most of the tests before, wasn't it ?
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:33
the characters have to be elimated from the old string as well
Vik
@vvang044
Mar 05 2016 05:34
@bitgrower i passes for the word palindrome but not for a sentence and special characters
palindrome("A man, a plan, a canal. Panama") should return true......it doesnt
bitgrower
@bitgrower
Mar 05 2016 05:35
well ... then, I guess that kinda answers your question ... if you pass on straight words, then your only issue is ferreting out characters you don't want in the string ...
Lê Tấn Trọng
@trongle
Mar 05 2016 05:36
@vvang044 show your full code again
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:36
because its comparing "A man, a plan, a canal. Panama" with "amanaplanacanalpanama"
Vik
@vvang044
Mar 05 2016 05:37
function palindrome(str) {
  // Good luck!

  var palindrome = str.toLowerCase().replace(/[\W\_]/g,'').split("").reverse().join("");

  if( palindrome === str){

  return true;
  }
  return false;
}

palindrome("eye");
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:37
you have to change the original string too
bitgrower
@bitgrower
Mar 05 2016 05:38
or use your cleaned up string, reverse it & compare ...
why do the work twice if you don't need to ?
Vik
@vvang044
Mar 05 2016 05:39
don't think i know how to use cleaned up string
i read it somewhere while searching for this
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:40
start off by making the original string lower case and getting rid of extra characters, then create a new string and assign it to reversal of the original string, then compare
Lê Tấn Trọng
@trongle
Mar 05 2016 05:41
yeah i think you comparing with the wrong string
bitgrower
@bitgrower
Mar 05 2016 05:43
@vvang044 -- once you have a cleaned up string, create a new variable, so you have a copy ... :)
BOOM! @kekkerslawl has the palindrome algo explained perfectly ... :)
Vik
@vvang044
Mar 05 2016 05:45
im working it....getting rid of the old code
*on
bitgrower
@bitgrower
Mar 05 2016 05:47
@vvang044 -- helps to pseudocode your code first before you write any ... and then walk thru your pseudocode ... ask yourself ... "what could go wrong here? What am I not checking for?"
Vik
@vvang044
Mar 05 2016 05:47
sorry *hint how do i compare?
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:48
you had the compare right
if (str1===str2){
return true;
} return false;
or you could use:
return str1===str2;
Chuck Adams
@chuckadams
Mar 05 2016 05:50
==, not ===
bitgrower
@bitgrower
Mar 05 2016 05:51
why, @chuckadams ?
Vik
@vvang044
Mar 05 2016 05:51
Booyeeeeeee!!!!!!
im a lousy but yet a genious.....lmfao
wait this credit goes to
@bitgrower and @kekkerslawl ......thank you
CamperBot
@camperbot
Mar 05 2016 05:52
vvang044 sends brownie points to @bitgrower and @kekkerslawl :sparkles: :thumbsup: :sparkles:
:star: 338 | @kekkerslawl | http://www.freecodecamp.com/kekkerslawl
:star: 720 | @bitgrower | http://www.freecodecamp.com/bitgrower
Daniel J. Bray
@kekkerslawl
Mar 05 2016 05:53
yw
bitgrower
@bitgrower
Mar 05 2016 05:53
yw -- keep up the great work !!!
Vik
@vvang044
Mar 05 2016 05:53
pheewww i can sleep now
thank you coders......now i need sleep....been on this for hours.....
laterz
bitgrower
@bitgrower
Mar 05 2016 05:53
before you go to sleep, or take a break or whatever -- review what you've just learned ... let your unconscious mind chew on it while you sleep ...
Vik
@vvang044
Mar 05 2016 05:54
yep im going to sleep on it
bitgrower
@bitgrower
Mar 05 2016 06:02

:point_up: March 4, 2016 9:50 PM

@chuckadams ... ??? why == and not === ?

Ryan Park
@rpark4
Mar 05 2016 06:12
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar= new Car(1,2,3);
anybody know what I'm doing whrong here?
Immad Hamid
@immad-hamid
Mar 05 2016 06:13
@bitgrower can you help me out with Exercise Profile Lookup?
This is what I am trying to satisfy the first condition but it seems like this does not work contacts[j][prop]
Here is the code:

function lookUp(firstName, prop){
// Only change code below this line
  var name;
  var j;
  for (var i = 0; i < contacts.length; i++){
    if(firstName === contacts[i].firstName){
      name = contacts[i].firstName;
      i = j;
      console.log(j);
      if(prop === contacts[j][prop]){
        return contacts[j][prop];
      }
    }
  }

// Only change code above this line
}
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:13
@rpark4 you need to change the '4' '1' and '1'
Ryan Park
@rpark4
Mar 05 2016 06:14
ha, thanks @kekkerslawl
CamperBot
@camperbot
Mar 05 2016 06:14
rpark4 sends brownie points to @kekkerslawl :sparkles: :thumbsup: :sparkles:
:star: 340 | @kekkerslawl | http://www.freecodecamp.com/kekkerslawl
CodeBabe
@CodeBabe
Mar 05 2016 06:14
Can someone direct me to some tutorials where I can get an understanding on how to solve the Profile Lookup challenge? I believe it involves the if statement and the for loop, but I can’t find enough tutorials to figure out the problem. I saw the hint statements online, but I still can’t figure it out and I don’t want to look at the answer.
Immad Hamid
@immad-hamid
Mar 05 2016 06:15
@rpark4 can you please help me out with the above mentioned problem or anyone
Ryan Park
@rpark4
Mar 05 2016 06:16
@CodeBabe That one took me a couple of hours, sorry. I just had to look up some of the old challenges.
I didn't find any tutorials
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:16
can you post your code @CodeBabe
Immad Hamid
@immad-hamid
Mar 05 2016 06:18
Can someone help me out with this Exercise Profile Lookup?
This is what I am trying to satisfy the first condition but it seems like this does not work contacts[j][prop]
@kekkerslawl
Here is the code:

function lookUp(firstName, prop){
// Only change code below this line
  var name;
  var j;
  for (var i = 0; i < contacts.length; i++){
    if(firstName === contacts[i].firstName){
      name = contacts[i].firstName;
      i = j;
      console.log(j);
      if(prop === contacts[j][prop]){
        return contacts[j][prop];
      }
    }
  }

// Only change code above this line
}
kirbyedy
@kirbyedy
Mar 05 2016 06:19
@CodeBabe think this way... you have to go through all the contacts in the array (so for that you use the for loop), and then you have to check if the first name is actually a first name (with IF), and after that you have to check if the prop has its own property
CodeBabe
@CodeBabe
Mar 05 2016 06:19
I can post it, but I don't think it makes any since because I don't understand the for loop concept.
bitgrower
@bitgrower
Mar 05 2016 06:20

so -- there are two folks who are here with issues with Profile Lookup ... I'm anxious to see what @CodeBabe has ...

@immad-hamid -- maybe you can help @Codebabe out ...

CodeBabe
@CodeBabe
Mar 05 2016 06:20
@kirbyedy . I'll try it again.
kirbyedy
@kirbyedy
Mar 05 2016 06:20
@bitgrower :wave:
CodeBabe
@CodeBabe
Mar 05 2016 06:21
I don't think I want to post it because I can't make any since out of what I wrote.
bitgrower
@bitgrower
Mar 05 2016 06:21
just based on @immad-hamid 's code & @CodeBabe 's complaints, I think @immad-hamid can be of help
Immad Hamid
@immad-hamid
Mar 05 2016 06:21
@bitgrower how when I am too looking for help...
bitgrower
@bitgrower
Mar 05 2016 06:21
@CodeBabe -- post code or no help ...
@immad-hamid -- because I think you have an understanding of the problem that @CodeBabe doesn't yet ... :)
you got the indexing right ... which many people who show up here don't get right off ... they just try to use object addressing ...
kirbyedy
@kirbyedy
Mar 05 2016 06:22
lol
Ryan Park
@rpark4
Mar 05 2016 06:23
@immad-hamid I used the hasownproperty function in mine to locate the objects for the second part. maybe you could use it too.
bitgrower
@bitgrower
Mar 05 2016 06:23
...as well, it's a sort of pair-programming exercise ... many times people get insight into how things work when helping/explaining to others ...
Ryan Park
@rpark4
Mar 05 2016 06:23
the second part being when you are trying to find prop
bitgrower
@bitgrower
Mar 05 2016 06:23
.hasOwnProperty is the indexOf of objects ... :)
CodeBabe
@CodeBabe
Mar 05 2016 06:24
Okay, but it's going to take me some time to find what I wrote because I have not work on it in a couple of weeks. I skipped it and did my Tribute page.
Immad Hamid
@immad-hamid
Mar 05 2016 06:24
Ok I'll try to help her out.
@CodeBabe please post your code, I'll try my best to help you out with the looping concept
I would suggest to reset the code and try to do that again. @CodeBabe
CodeBabe
@CodeBabe
Mar 05 2016 06:25
I'll post it when I find it.
bitgrower
@bitgrower
Mar 05 2016 06:25
@CodeBabe ... go here: http://www.freecodecamp.com -- hover to the right to bring up the right side bar ... put "Profile Lookup" into the search box ... it should pull up the challenge -- and when you click on it, your code ...
bitgrower @bitgrower isn't letting @CodeBabe off the hook ...
Matthew Stettner
@mstettner
Mar 05 2016 06:26
hey guys I got this answer correct and I thought I understood why but I dont. anyone care to eaborate?
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[2][1];
bitgrower
@bitgrower
Mar 05 2016 06:27
or.... maybe @immad-hamid can explain what his code is doing in Profile Lookup
Immad Hamid
@immad-hamid
Mar 05 2016 06:27
@bitgrower yea sure things.
bitgrower
@bitgrower
Mar 05 2016 06:27
@mstettner -- what's the objective of the exercise ?
Matthew Stettner
@mstettner
Mar 05 2016 06:27
Access MultiDimensional Arrays With Indexes
Read from myArray using bracket notation so that myData is equal to 8
@bitgrower
Surya Kiran
@suryakiran138
Mar 05 2016 06:28
Counting Cards question
Surya Kiran
@suryakiran138
Mar 05 2016 06:28
i am not undestanding question?
bitgrower
@bitgrower
Mar 05 2016 06:28
whose question, @suryakiran138 ?
Surya Kiran
@suryakiran138
Mar 05 2016 06:29
counting cards question
which i provided link
Matthew Stettner
@mstettner
Mar 05 2016 06:29
@bitgrower ugh that hard to understand
heres the example they give
var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:30
@mstettner so, [7,8,9] is myArray[2]. And 8 is myArray[2][1]
Matthew Stettner
@mstettner
Mar 05 2016 06:31
how does arr[0] // equals [1,2,3]?
Ryan Park
@rpark4
Mar 05 2016 06:31
@mstettner computers start counting with 0
bitgrower
@bitgrower
Mar 05 2016 06:31

@suryakiran138 -- take a pencil and paper out, read the instructions ... write down your interpretation of the instructions

all problems basically consist of 3 things

  1. input
  2. transform of input to give you
  3. output

so ... make sure you understand, clearly, what the input is, what your output is supposed to be ... and then work out how you transform the input to the output .. :)

@mstettner -- it might help if you expand it ...

Ryan Park
@rpark4
Mar 05 2016 06:32
so to you it seems like it should be array #1, the compy calls it array#0
bitgrower
@bitgrower
Mar 05 2016 06:32
@mstettner -- arrays can contain anything ... numbers, objects, booleans, ...and...other Arrays ...
Matthew Stettner
@mstettner
Mar 05 2016 06:32
i expanded it
so for instance
var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
bitgrower
@bitgrower
Mar 05 2016 06:32
in this particular problem, you have an array of arrays
Matthew Stettner
@mstettner
Mar 05 2016 06:33
i thought arr[0]; // equals [1,2,3] this would equal 1
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:33
thats arr[0][0]
bitgrower
@bitgrower
Mar 05 2016 06:33
arr[0] is looking at the first element in the array, which is [1,2,3]
Matthew Stettner
@mstettner
Mar 05 2016 06:33
bc computer start counting at one so wouldnt arr[0] correlate to 1
Ryan Park
@rpark4
Mar 05 2016 06:33
oh I see what you mean
Matthew Stettner
@mstettner
Mar 05 2016 06:33
@rpark4 yeah see what I mean
what am i not understanding
Ryan Park
@rpark4
Mar 05 2016 06:33
the set of brackets is the first 0,
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:33
arr[0] correlates to the first array in the multidimensional array
Surya Kiran
@suryakiran138
Mar 05 2016 06:34
@bitgrower how will we how many inputs we will get
bitgrower
@bitgrower
Mar 05 2016 06:34
mstettner ... you have an array [ element0, element1, element2, element2 ]
Surya Kiran
@suryakiran138
Mar 05 2016 06:34
?
Matthew Stettner
@mstettner
Mar 05 2016 06:34
okay which is 123
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:34
yeah
Ryan Park
@rpark4
Mar 05 2016 06:34
yep
bitgrower
@bitgrower
Mar 05 2016 06:34
it doesn't matter what TYPE the elements are ... element0 is ALWAYS going to be at [0]
Ryan Park
@rpark4
Mar 05 2016 06:34
then inside of 123, you start over at 0
Matthew Stettner
@mstettner
Mar 05 2016 06:34
so what does array [1] correlate to?
element 2?
bitgrower
@bitgrower
Mar 05 2016 06:35
@mstettner -- yep, the 2nd element in the array
Ryan Park
@rpark4
Mar 05 2016 06:35
yup, [456]
Matthew Stettner
@mstettner
Mar 05 2016 06:35
and what is the second element in that array?
bitgrower
@bitgrower
Mar 05 2016 06:35
in .... what array, specifically ?
Matthew Stettner
@mstettner
Mar 05 2016 06:35
and 2 would be 789
this array
bitgrower
@bitgrower
Mar 05 2016 06:35
yes @mstettner ... you're gettin it ...
Matthew Stettner
@mstettner
Mar 05 2016 06:35
var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
so if I have array [1][2] then how does that equal six?
456 789
does not equal six
Ryan Park
@rpark4
Mar 05 2016 06:36
ok, here is where you aren't seeing it
if you do two numbers in a row like that
Matthew Stettner
@mstettner
Mar 05 2016 06:36
yes please fill me in
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:37
array[1] is 456
bitgrower
@bitgrower
Mar 05 2016 06:37
because, once you have gotten to addressing the first array, then you are looking "inside" the 2nd element ... of higher level array
Matthew Stettner
@mstettner
Mar 05 2016 06:37
yes
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:37
then look at 456 and start over at 0
Surya Kiran
@suryakiran138
Mar 05 2016 06:37
rooms
CamperBot
@camperbot
Mar 05 2016 06:37

rooms

See all the FreeCodeCamp rooms at gitter.im/FreeCodeCamp/rooms
Or check this wiki article for a shortlist
Matthew Stettner
@mstettner
Mar 05 2016 06:37
so then its six
Ryan Park
@rpark4
Mar 05 2016 06:37
yup
Matthew Stettner
@mstettner
Mar 05 2016 06:37
okay
Ryan Park
@rpark4
Mar 05 2016 06:38
@kekkerslawl helped me explain
Matthew Stettner
@mstettner
Mar 05 2016 06:38
var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:38
array[1][0] = 4, array[1][1]=5, array[1][2]=6
Ryan Park
@rpark4
Mar 05 2016 06:38
thanks @kekkerslawl
CamperBot
@camperbot
Mar 05 2016 06:38
rpark4 sends brownie points to @kekkerslawl :sparkles: :thumbsup: :sparkles:
:warning: rpark4 already gave kekkerslawl points
Ryan Park
@rpark4
Mar 05 2016 06:38
dag bro, no dice
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:38
lol, no worries
Matthew Stettner
@mstettner
Mar 05 2016 06:38
@kekkerslawl thanks one more thing though]
CamperBot
@camperbot
Mar 05 2016 06:38
mstettner sends brownie points to @kekkerslawl :sparkles: :thumbsup: :sparkles:
:star: 343 | @kekkerslawl | http://www.freecodecamp.com/kekkerslawl
Matthew Stettner
@mstettner
Mar 05 2016 06:39
var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
bitgrower
@bitgrower
Mar 05 2016 06:39
ya got it, @mstettner ???
Matthew Stettner
@mstettner
Mar 05 2016 06:39
how do I get into [10,11,12] and where are 13,14
Shakib Hossain
@shakib609
Mar 05 2016 06:39
I am doing this with static data for now.. but it seems to be not rendering a col-md-3 column correctly.. http://codepen.io/shakib609/pen/qZOYwe
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:39
that would be the arr[3][0][1] line
Shakib Hossain
@shakib609
Mar 05 2016 06:40
Can anyone help?
Matthew Stettner
@mstettner
Mar 05 2016 06:40
well i know it 11 bc it says so but im trying to think about it
Stephen Antony
@Stephen-antony
Mar 05 2016 06:40
so if we print arr[0] , would it show [1,2,3] or if we add 1+arr[0] , What would be the answer?
Matthew Stettner
@mstettner
Mar 05 2016 06:40
@Stephen-antony no idea
oh wait
2?
CamperBot
@camperbot
Mar 05 2016 06:41

:point_right: world language chat rooms [wiki]

The following are our language-specific chat rooms.

Please note that all chat rooms listed here are publicly accessible and indexed by search engines, so only share email addresses or other sensitive information in private messages.

bitgrower
@bitgrower
Mar 05 2016 06:41
it's like Russian dolls, @mstettner ... you are opening up each array ...
@Stephen-antony -- sorry ... :(
Matthew Stettner
@mstettner
Mar 05 2016 06:41
@Stephen-antony is 2 correct?
Daniel J. Bray
@kekkerslawl
Mar 05 2016 06:41
so arr[3][1] = 13, and arr[3][2] = 14
arr[3][0]=[10 11 12]
Stephen Antony
@Stephen-antony
Mar 05 2016 06:42
arr[0]=[3,4,5] , What would be arr[0]+1
Ryan Park
@rpark4
Mar 05 2016 06:42
each set of brackets is acting exactly like a number, so if you have a bracket next to a number inside of another set of brackets, think of them as the same. So [10, 11, 12] 13 and 14 are all parts of one element. so [10, 11, 12] is 0, 13 is 1, and 14 is 2.
bitgrower
@bitgrower
Mar 05 2016 06:42
who are you asking, @Stephen-antony ?
Matthew Stettner
@mstettner
Mar 05 2016 06:42
would it be 3+4+5+1?
Stephen Antony
@Stephen-antony
Mar 05 2016 06:42
anyone ? :)
I am just curious
bitgrower
@bitgrower
Mar 05 2016 06:43
no ... each element is just something in the array ...
Matthew Stettner
@mstettner
Mar 05 2016 06:43
@rpark4 I need to spend more time to understand this
Ryan Park
@rpark4
Mar 05 2016 06:43
alright boss, just keep at it.
it'll come to you
bitgrower
@bitgrower
Mar 05 2016 06:43

well ... it would be an expression without a home ...

now ... if you want to ask something like this ...

myVar = arr[0] + 1; then I can tell you that myVar would be 4

Matthew Stettner
@mstettner
Mar 05 2016 06:43
if I dont wrap my head around this now ill be lost forever
I get what you guys are saying up til a certain point then I lose it
bitgrower
@bitgrower
Mar 05 2016 06:44
give it time ... sometimes other parts of your brain has to put the pieces together ....
awesome ... you're making progress !!!!
go review the image I posted ... :)
Matthew Stettner
@mstettner
Mar 05 2016 06:45
@bitgrower id have to have someone verbally go over that with me. doesnt make sense right now just looking at it
to me its just a bunch of arrows pointing at different things
i cant rememebr what i++ means
bitgrower
@bitgrower
Mar 05 2016 06:46
I understand ...
Stephen Antony
@Stephen-antony
Mar 05 2016 06:46
@bitgrower arr[0] ={3,4,5} , and if we add arr[0]+1 the your saying the answer will be just 4
Surya Kiran
@suryakiran138
Mar 05 2016 06:46
i am stuck in counting cards from 1 hr ............. i am not undestanding how many cards they will pass
?
Stephen Antony
@Stephen-antony
Mar 05 2016 06:46
@mstettner i++ is like i=i+1
bitgrower
@bitgrower
Mar 05 2016 06:46
@Stephen-antony -- you didn't ask where you were putting the result of the addition, so that's going to make a difference ...
Matthew Stettner
@mstettner
Mar 05 2016 06:46
yeah that right hahahaha and I forget what that even pertains too
Right now it dont understand what any of this JS lingo really pertains to. I dont know how its going to be used in the future
bitgrower
@bitgrower
Mar 05 2016 06:47
if you want to ask what arr looks like after you say arr[0] += 1; ... then that's a question I can answer ... :)
Stephen Antony
@Stephen-antony
Mar 05 2016 06:47
@bitgrower consider result stored in a two dimensional array
Matthew Stettner
@mstettner
Mar 05 2016 06:48
its like learning the alphbet but not know that there are words and then realizing there is sentences
bitgrower
@bitgrower
Mar 05 2016 06:48
you would have to give me the 2-D array, @Stephen-antony
Stephen Antony
@Stephen-antony
Mar 05 2016 06:48
@bitgrower ok what about a single dimenionsal array
Matthew Stettner
@mstettner
Mar 05 2016 06:48
var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
the last arr[3][0][1]; // equals 11 how is it equal to 11 again?
Stephen Antony
@Stephen-antony
Mar 05 2016 06:49
var c[10]= arr[0]+1
Matthew Stettner
@mstettner
Mar 05 2016 06:49
3 represents 789?
Stephen Antony
@Stephen-antony
Mar 05 2016 06:49
where arr[0]={ 4 5 6}
Ryan Park
@rpark4
Mar 05 2016 06:49
nope
remember to start at 0
bitgrower
@bitgrower
Mar 05 2016 06:49
then c[10] = 5
Matthew Stettner
@mstettner
Mar 05 2016 06:50
hmmmm
bitgrower
@bitgrower
Mar 05 2016 06:50
oh wait ... you have an object there, not an array -- so you'd get a parse error of some sort
Stephen Antony
@Stephen-antony
Mar 05 2016 06:50
@bitgrower just 5? what about the rest ?
bitgrower
@bitgrower
Mar 05 2016 06:51
c[10] is the variable in which you are putting the value ...
Jayanth Kanive
@jkanive
Mar 05 2016 06:51
Can someone help my how Closures work in javascript ?
Robert Uivarosi
@URobert
Mar 05 2016 06:52
@jkanive yes
Jayanth Kanive
@jkanive
Mar 05 2016 06:52
I am having difficulty solving "Arguments Optional" problem
Ryan Park
@rpark4
Mar 05 2016 06:52
@mstettner if i where you i'd get out a piece of paper and label each of these guys. [123] - 0 [456] -1 [789] - 2 [[10,11,12]13,14] - 3
Matthew Stettner
@mstettner
Mar 05 2016 06:53
@rpark4 okay that makes sense
Robert Uivarosi
@URobert
Mar 05 2016 06:53
@jkanive Watch this video: https://www.youtube.com/watch?v=CQqwU2Ixu-U . You`ll get how closures work in less than 8min
Matthew Stettner
@mstettner
Mar 05 2016 06:53
so the first [] represents one of those arrays
@rpark4
Stephen Antony
@Stephen-antony
Mar 05 2016 06:53
@bitgrower so you are saying when you add a multidimenional array with a number only a single value gets changed
V Arun Kumar
@arunvkumr
Mar 05 2016 06:53
@mstettner
arr[3] = [[10,11,12],13,14] => arr[3][0]=[10,11,12] => arr[3][0][1] =11
Stephen Antony
@Stephen-antony
Mar 05 2016 06:54
@arunkumrv Thanks man
CamperBot
@camperbot
Mar 05 2016 06:54
:star: 301 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Ryan Park
@rpark4
Mar 05 2016 06:54
yes it does and then go one level deeper. 1-0, 2-1, 3-2
CamperBot
@camperbot
Mar 05 2016 06:54
stephen-antony sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
Matthew Stettner
@mstettner
Mar 05 2016 06:54
[0][0] does the first [0] represent something different from the second [0] or doe they both represent the same thing
bitgrower
@bitgrower
Mar 05 2016 06:54
@Stephen-antony -- I am saying you can only access one element of an array and use it ...
Stephen Antony
@Stephen-antony
Mar 05 2016 06:55
@bitgrower unless we are adding two multidimenional array ?
bitgrower
@bitgrower
Mar 05 2016 06:55
how you subsequently use it will determine what, if anything, is changed ...
@Stephen-antony -- that's not a defined operation in js ...
if you want to do linear algebra -- js is probably not the best language to do it in ...
Stephen Antony
@Stephen-antony
Mar 05 2016 06:56
@bitgrower yea thought so :+1:
@bitgrower Thanks for clearing that up :smile:
CamperBot
@camperbot
Mar 05 2016 06:57
stephen-antony sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 721 | @bitgrower | http://www.freecodecamp.com/bitgrower
Ryan Park
@rpark4
Mar 05 2016 06:57
@mstettner first 0 represents 123, second one represents 1 from 123
Matthew Stettner
@mstettner
Mar 05 2016 06:57
@arunkumrv @rpark4 thanks guys i finally got it
CamperBot
@camperbot
Mar 05 2016 06:57
mstettner sends brownie points to @arunkumrv and @rpark4 :sparkles: :thumbsup: :sparkles:
:star: 249 | @rpark4 | http://www.freecodecamp.com/rpark4
:star: 302 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Matthew Stettner
@mstettner
Mar 05 2016 06:57
@rpark4 yes
Ryan Park
@rpark4
Mar 05 2016 06:58
wooohooo!
bitgrower
@bitgrower
Mar 05 2016 06:58
awesome !!!!! I am so happy for you @mstettner ... !!!!
Matthew Stettner
@mstettner
Mar 05 2016 06:58
now how do I remember all this five minutes from now lol
Ryan Park
@rpark4
Mar 05 2016 06:58
practice
Matthew Stettner
@mstettner
Mar 05 2016 06:58
@bitgrower thanks
CamperBot
@camperbot
Mar 05 2016 06:58
mstettner sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Ryan Park
@rpark4
Mar 05 2016 06:58
thats how
CamperBot
@camperbot
Mar 05 2016 06:58
:star: 722 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 05 2016 06:58
go see if that image makes more sense to you now ... :)
Ryan Park
@rpark4
Mar 05 2016 06:58
its the secret
bitgrower
@bitgrower
Mar 05 2016 06:58
^^^ yep
Matthew Stettner
@mstettner
Mar 05 2016 06:59
how would what i just leanred be applied in everyday JS coding?
btw sorry for my typos I know english I just suck at typing.
Stephen Antony
@Stephen-antony
Mar 05 2016 06:59
@mstettner array within in array we are just going one more level deep like the movie inception , and we add the index of the element with that array to access deeper :smile:
bitgrower
@bitgrower
Mar 05 2016 07:00
Russian dolls ... it's like Russian dolls ... each level of your data structure is like one level of your Russian dolls ...
Ryan Park
@rpark4
Mar 05 2016 07:02
@mstettner I'm not really qualified to answer that one bro. I'm just getting started myself . I just know that in math I used to be the same way. I'd learn something and instantly forget it. I learned that if I actually do practice problems, I never forget the stuffs.
Aled Wassell
@aledwassell
Mar 05 2016 07:02
okay so the javascript convert celsius is hard?
Ryan Park
@rpark4
Mar 05 2016 07:02
later
bitgrower
@bitgrower
Mar 05 2016 07:02

so ... if I have an array ...

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

I can simplify things by saying ...

mySubArray = myArray[0]; /// which is [[3,2,1],[4,5,6]];

and then I can access go deeper ...

mySubSubArray = mySubArray[0]; /// which is [3,2,1]

and so on

rwils83
@rwils83
Mar 05 2016 07:03
can i ask a quick question about the Increment a Number with Javascript?
Jayanth Kanive
@jkanive
Mar 05 2016 07:03
@URobert I was able to get what Closures are from the video you linked and from the Mozilla MDN
bitgrower
@bitgrower
Mar 05 2016 07:04
woot ... awesome job, @URobert ... and @jkanive !!!
Jayanth Kanive
@jkanive
Mar 05 2016 07:04
@URobert but still unable to solve the problem in hand
Stephen Antony
@Stephen-antony
Mar 05 2016 07:04
@rwils83 you can store the value in a variable and increment the variable
Jayanth Kanive
@jkanive
Mar 05 2016 07:04
:(
Stephen Antony
@Stephen-antony
Mar 05 2016 07:04
@rwils83 like var i=6 ; i=i+1;
rwils83
@rwils83
Mar 05 2016 07:05

this is what i have for the challenge solution
var myVar = 87;
myVar = myVar ++;

It continues to fail the test, saying myVar=87

am i misunderstanding the syntax?
Jayanth Kanive
@jkanive
Mar 05 2016 07:06
@rwils83 it should be just plain myVar++;
bitgrower
@bitgrower
Mar 05 2016 07:06

@rwils83 ... you can increment this way

i++

or this way

++i

Stephen Antony
@Stephen-antony
Mar 05 2016 07:06
@rwils83 yea myVar++;
bitgrower
@bitgrower
Mar 05 2016 07:06

if you do it this way: i++

it takes the value FIRST and performs any operation, then increments the value ...

so whatever you set myVar++ to is going to be 87 ...
but if you did this
Jayanth Kanive
@jkanive
Mar 05 2016 07:07
@rwils83 or myVar += 1;
bitgrower
@bitgrower
Mar 05 2016 07:07

myVar = ++myVar;

then myVar would be 88

yeah, @jkanive -- that solves some messy pre/post increment issues that peeps have ...
Meghana
@meghanasarikonda
Mar 05 2016 07:08
@rwils83 yes the same difference mentioned by bitgrower
rwils83
@rwils83
Mar 05 2016 07:09
ok that makes sense.
@jkanive that makes sense as well, but it won't work on this challenge.
Meghana
@meghanasarikonda
Mar 05 2016 07:09
u can use ++myVar
Jayanth Kanive
@jkanive
Mar 05 2016 07:09
@bitgrower sorry, I must have tried to answer out of context
Stephen Antony
@Stephen-antony
Mar 05 2016 07:10
@rwils83 Increment comes in two forms pre-increment ++I and post increment i++ ;
Jayanth Kanive
@jkanive
Mar 05 2016 07:10
@URobert do you think you can help me with the Arguments Optional problem
rwils83
@rwils83
Mar 05 2016 07:10
changed it to ++ myVar, now it fails on the second rule, which is you must use the ++ operator...
V Arun Kumar
@arunvkumr
Mar 05 2016 07:11
@rwils83 i used to remember post/pre like this..
++myVar -> first add 1 to myVar as ++ is before myVar so first add 1.
myVar++ -> first use the value then add 1 to myVar as ++ is after myVar.
Meghana
@meghanasarikonda
Mar 05 2016 07:11
@rwils83 can u paste your code
Stephen Antony
@Stephen-antony
Mar 05 2016 07:12
@rwils83 did you try myVar=myVar+1 ;
iamlimo
@iamlimo
Mar 05 2016 07:13

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

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

bitgrower
@bitgrower
Mar 05 2016 07:13
@jkanive ... can you post your code ... ?
CamperBot
@camperbot
Mar 05 2016 07:13
no wiki entry for: with my codefunction multiplyallarr var product 1 only change code below this line forvar i 0 i arrlength i for var j 0 arrilength j only change code above this line return product modify values below to test your codemultiplyall1234567
Jayanth Kanive
@jkanive
Mar 05 2016 07:14
@bitgrower

@bitgrower function add() {

if(arguments.length == 1){
var x = arguments[0];
var sumVal = function(y){
return x+y;
};
}else{
return arguments[0]+arguments[1];
}
//return arguments.length;

return sumVal;
}

add(2,3);

bitgrower
@bitgrower
Mar 05 2016 07:14
@jkanive -- basically -- first solve the challenge for the various numbers of arguments except for when you are handed just 1 argument ...
@jkanive -- you have to make sure the arguments you are being handed are numbers ... :) and not undefined ...
Stephen Antony
@Stephen-antony
Mar 05 2016 07:15
@iamlimo what do you want to change in that code ?
Jayanth Kanive
@jkanive
Mar 05 2016 07:15
@bitgrower I was getting to it once I was able to solve the single argument case
Aled Wassell
@aledwassell
Mar 05 2016 07:16

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

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

// Change the inputs below to test your code
convert(30);
I've hit a brick wall

bitgrower
@bitgrower
Mar 05 2016 07:16
:) ... well, sometimes it makes sense to solve the parts of the problem you know how to do easily, first ... :)
Stephen Antony
@Stephen-antony
Mar 05 2016 07:16
@iamlimo in j loop j<arr is missing
bitgrower
@bitgrower
Mar 05 2016 07:16
@jkanive -- go back and copy the instructions for what you are supposed to do if you get only one argument ... :)
iamlimo
@iamlimo
Mar 05 2016 07:17
@Stephen-antony ; I really do not know but I was instructed to :Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
bitgrower
@bitgrower
Mar 05 2016 07:18
dang ... we should have @mstettner help @aledwassell
:)
Jayanth Kanive
@jkanive
Mar 05 2016 07:18
@bitgrower if(arguments.length == 1){
var x = arguments[0];
total = function(y){
return x+y;
};
}
Stephen Antony
@Stephen-antony
Mar 05 2016 07:18
@iamlimo can you tell me the excercise name
iamlimo
@iamlimo
Mar 05 2016 07:18
@Stephen-antony It's nesting for loops
bitgrower
@bitgrower
Mar 05 2016 07:18
@jkanive -- doesn't it say something about returning a function ?
Jayanth Kanive
@jkanive
Mar 05 2016 07:20
@bitgrower you mean I need to return total variable
bitgrower
@bitgrower
Mar 05 2016 07:20
no ... you return a function ...
Stephen Antony
@Stephen-antony
Mar 05 2016 07:20

@iamlimo function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0;i<arr.length;i++) {

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

}

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

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

iamlimo
@iamlimo
Mar 05 2016 07:21
@Stephen-antony oh thanks
CamperBot
@camperbot
Mar 05 2016 07:21
iamlimo sends brownie points to @stephen-antony :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 05 2016 07:21
"If only one argument is provided, then return a function "
CamperBot
@camperbot
Mar 05 2016 07:21
:star: 236 | @stephen-antony | http://www.freecodecamp.com/stephen-antony
Stephen Antony
@Stephen-antony
Mar 05 2016 07:21
you were missing the j from the loop
bitgrower
@bitgrower
Mar 05 2016 07:21
wtg, @Stephen-antony -- :)
Stephen Antony
@Stephen-antony
Mar 05 2016 07:21
and product also
Jayanth Kanive
@jkanive
Mar 05 2016 07:22
@bitgrower how do you IM formated code ?
bitgrower
@bitgrower
Mar 05 2016 07:22
explain format
iamlimo
@iamlimo
Mar 05 2016 07:22
@Stephen-antony Could you just summarize what it means
CamperBot
@camperbot
Mar 05 2016 07:22

: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

Saif Ali Khan
@saifat29
Mar 05 2016 07:23
```
```
iamlimo
@iamlimo
Mar 05 2016 07:23
?
Saif Ali Khan
@saifat29
Mar 05 2016 07:23
function titleCase(str) {
  var tempStr = str;
  tempStr = tempStr.split(" ");
  for(var i = 0; i < tempStr.length; i++) {
    tempStr[i].charAt(0) = tempStr[i].charAt(0).toUpperCase();
    }
  tempStr = tempStr.join(" ");
  return tempStr;
}

titleCase("I'm a little tea pot");
why's this code wrong?
V Arun Kumar
@arunvkumr
Mar 05 2016 07:23
@iamlimo in you code the codition statement of j is arr[i].length it is not comparing with j.
iamlimo
@iamlimo
Mar 05 2016 07:24
@arunkumrv thanks
CamperBot
@camperbot
Mar 05 2016 07:24
iamlimo sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 05 2016 07:24
this is gonna sound a bit counter-intuitive, @jkanive -- but if you JUST follow the instructions, create a function as described, and then return the function .. .you are 90% of the way home ...
CamperBot
@camperbot
Mar 05 2016 07:24
:star: 303 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Jayanth Kanive
@jkanive
Mar 05 2016 07:24

function add() {

 var total;
 if(arguments.length == 1){
 var x = arguments[0]; 
 total = function(y){
   return x+y;
 };
 }else{
  total =  arguments[0]+arguments[1];
 }
  //return arguments.length;

  return total;
}

add(2,3);
I am return the total which has a function assign to it
isn't that what I am suppose to do ?
Stephen Antony
@Stephen-antony
Mar 05 2016 07:25
@iamlimo hmm ok , the first ( i )array is taking the array length as the limit to how much the i loop should iterate , the second j loop is also accessing the array length to access the second dimension of the array so that each value in the multi dimenional array could be accessed , the product variable is then able to multiply the values of each value stored in the i and j based on each iteration from the loop
bitgrower
@bitgrower
Mar 05 2016 07:25
@jkanive -- no, you are supposed to return a function...
return function (....
iamlimo
@iamlimo
Mar 05 2016 07:27
@Stephen-antony oh ok
Jayanth Kanive
@jkanive
Mar 05 2016 07:28
 if(arguments.length == 1){
   var x = arguments[0];
   return function(y){
     return x+y;
   };

 }
bitgrower
@bitgrower
Mar 05 2016 07:28
looks promising, @jkanive ... :)
V Arun Kumar
@arunvkumr
Mar 05 2016 07:29
@bitgrower is this the closures challenge?
bitgrower
@bitgrower
Mar 05 2016 07:29
now you just need to make sure your arguments are numbers ... :)
@arunkumrv -- yes
"arguments optional"
V Arun Kumar
@arunvkumr
Mar 05 2016 07:30
ah i remember i read about this last night.. add(2,3) and add(2)(3)new way of calling functions :smiley:
Jayanth Kanive
@jkanive
Mar 05 2016 07:31
 if(arguments.length == 1){
   var x = arguments[0];
   if(Number.isInteger(x)){
   return function(y){
     return x+y;
   };
   }
   else{
     return undefined;
   }
 }
bitgrower
@bitgrower
Mar 05 2016 07:31
lol, well, I'm not sure how new it is to js -- but it's new to folks from most other programming languages ...
@jkanive ... typeof is a bit more accurate and definitely more direct ... :)
Rian Pauzi
@tekon92
Mar 05 2016 07:32
hai guys, im facing issue on part reverse array with reverse. this should be ok tho newArray = array.reverse(); ?
bitgrower
@bitgrower
Mar 05 2016 07:32
problem definition I don't think said whether the numbers were integers ... :)
This message was deleted
Jayanth Kanive
@jkanive
Mar 05 2016 07:34
@bitgrower
```
@bitgrower
if(arguments.length == 1){
   var x = arguments[0];
   if(typeof x  === 'number'){
   return function(y){
     return x+y;
   };
   }
   else{
     return undefined;
   }
 }
bitgrower
@bitgrower
Mar 05 2016 07:35
you also have to check whether your parameter y is a number, too, @jkanive
Jayanth Kanive
@jkanive
Mar 05 2016 07:36
@bitgrower
if(arguments.length == 1){
   var x = arguments[0];
   if(typeof x  === 'number'){
   return function(y){
     if(typeof y  === 'number'){
     return x+y;
     }else{
       return undefined;
     }
   };
   }
   else{
     return undefined;
   }
 }
bitgrower
@bitgrower
Mar 05 2016 07:37
well ... does it pass your test cases ? or not ?
Jayanth Kanive
@jkanive
Mar 05 2016 07:37
nope
its still unable to do the add(2,3) or add(2)(3)
bitgrower
@bitgrower
Mar 05 2016 07:38
well .. you don't code for handling 2 arguments yet ... :)
Jayanth Kanive
@jkanive
Mar 05 2016 07:38
I actually have it
bitgrower
@bitgrower
Mar 05 2016 07:38

that would explain add(2,3) ...

not sure about add(2)(3)

Jayanth Kanive
@jkanive
Mar 05 2016 07:39

function add() {

 var total;
 if(arguments.length == 1){
   var x = arguments[0];
   if(typeof x  === 'number'){
   return function(y){
     if(typeof y  === 'number'){
     return x+y;
     }else{
       return undefined;
     }
   };
   }
   else{
     return undefined;
   }
 }else{
  return  arguments[0]+arguments[1];
 }
  //return arguments.length;

}
the else part should take care of that
I know I am not handling the typeof case there
bitgrower
@bitgrower
Mar 05 2016 07:40
eeeee ... you really should test explicitly for 2 arguments ... not just default everything to not 1 argument ...
Ryan Price
@rsprice
Mar 05 2016 07:41
@bitgrower does it really matter?
Jayanth Kanive
@jkanive
Mar 05 2016 07:42
@bitgrower

function add() {

 var total;
 if(arguments.length === 1){
   var x = arguments[0];
   if(typeof x  === 'number'){
   return function(y){
     if(typeof y  === 'number'){
     return x+y;
     }else{
       return undefined;
     }
   };
   }
   else{
     return undefined;
   }
 }else if(arguments.length === 2){
  var a=  arguments[0];
  var b = arguments[1];
   if((typeof a === 'number') && 
      (typeof b === 'number')){
     return a+b;
   }else{
     return undefined;
   }
 }
  //return arguments.length;

}

add(2,3);
bitgrower
@bitgrower
Mar 05 2016 07:43

imnsho ... yes ... because if you are handed 0 arguments, you'll do the wrong thing, if you are handed 3 arguments, you'll possibly do the wrong thing ...

...there's a concept called "defensive programming" ... which means you should protect your code from idiot inputs coming into your function, and handle the (well defined) test cases appropriately ... :)

Saif Ali Khan
@saifat29
Mar 05 2016 07:43

function titleCase(str) {
  var tempStr = str;
  tempStr = tempStr.split(" ");
  for(var i = 0; i < tempStr.length; i++) {
    tempStr[i] = tempStr[i].toUpperCase().charAt(0);
    }
  tempStr = tempStr.join(" ");
  return tempStr;
}

titleCase("I'm a little tea pot");
}
I'm getting this as output
I A L T P
What's wrong?
bitgrower
@bitgrower
Mar 05 2016 07:44
@saifat29 - strings are immutable -- you cannot change a string ... you can manipulate a string and set it to a new variable ... but the string itself, you cannot change .
Saif Ali Khan
@saifat29
Mar 05 2016 07:44
The expected output is,
I'm A Little Tea Pot
CodeBabe
@CodeBabe
Mar 05 2016 07:44
@bitgrower . Sorry for the confusion. I meant to say that I had to find what I wrote on paper. Not the location of the challenge.
bitgrower
@bitgrower
Mar 05 2016 07:45
ahhh ... okay ... @CodeBabe ...
Ryan Price
@rsprice
Mar 05 2016 07:45
@bitgrower if there are more than two arguments it's just going to add the first two
V Arun Kumar
@arunvkumr
Mar 05 2016 07:45
@saifat29 tempStr[i] = tempStr[i].toUpperCase().charAt(0) this line is just taking the first character of the words thats why its returing thr first char.
Saif Ali Khan
@saifat29
Mar 05 2016 07:45
@bitgrower i think i get it
Ryan Price
@rsprice
Mar 05 2016 07:45
@bitgrower eh, I take back what I said. I agree with you
you're right
bitgrower
@bitgrower
Mar 05 2016 07:46
yeah, it's not specifically within the FCC challenge stuff ... it's just good programming practice ... :)
Ryan Price
@rsprice
Mar 05 2016 07:47
Yeah I agree
Jayanth Kanive
@jkanive
Mar 05 2016 07:47
@bitgrower I took care of that now
still not able to solve the challenge
bitgrower
@bitgrower
Mar 05 2016 07:48
@jkanive -- I'm not sure why your code isn't working at this point ...
CodeBabe
@CodeBabe
Mar 05 2016 07:48

Profile Lookup challenge:
I wrote this not understanding the problem or what to do.
for (i=0; i<contacts.length; i++) {
if (contacts[3].hasOwnProperty(“firstName”) && contacts[3].hasOwnProperty(“likes”))….
or…
If (contacts[i].hasOwnProperty(“firstName”) && contacts[i].hasOwnProperty(“likes”))
or …
If (contacts[3][firstName]==firstName && contacts[3][likes]==prop) {

        Return…..

}
}
I would appreciate any help. Thank you.

bitgrower
@bitgrower
Mar 05 2016 07:50
first of all, congratulations for realizing that your data structure is an array of objects ... w/an emphasis on ARRAY .. :)
Aleksander Gębicki
@Takumar
Mar 05 2016 07:50
@CodeBabe you've made loop good, now you have to check parameters of your function, don't hard code names of properties. Use your loop's index to check contacts[i] element
bitgrower
@bitgrower
Mar 05 2016 07:50
(or array indexes ... )
.hasOwnProperty is a GREAT start ... as well ...
CodeBabe
@CodeBabe
Mar 05 2016 07:52
But, I don't understand what I'm doing. So, I don't think I can continue.
Aleksander Gębicki
@Takumar
Mar 05 2016 07:52
@CodeBabe just construct your condtions according to the instruction, what is the first point to check?
bitgrower @bitgrower thinks she wants to give up coding at least once a day ... :)
Aleksander Gębicki
@Takumar
Mar 05 2016 07:53
@CodeBabe The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
CodeBabe
@CodeBabe
Mar 05 2016 07:54
Okay I'll go back and spend another 10 hours on it. Maybe it will click.
@Takumar . Thank you
CamperBot
@camperbot
Mar 05 2016 07:54
codebabe sends brownie points to @takumar :sparkles: :thumbsup: :sparkles: