These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Feb 2016
Norman Dela Cruz
@dcnr
Feb 10 2016 00:00
@Takumar hi :D
greg
@wearenotgroot
Feb 10 2016 00:02
@MariusGarbea you can parse the responseText to become an object
var response = jQuery.parseJSON(jqXHR.responseText);
Norman Dela Cruz
@dcnr
Feb 10 2016 00:02
@broktnet if your firstName isn't the first in the array, for example "Kristian" it would go to this else if (firstName !== contacts[i].firstName) thus ending your function with No such contact even though the contact is valid, the loop isn't reaching it
broktnet
@broktnet
Feb 10 2016 00:02
@dyczol You don't need to print the array but rather multiply the product by it and add to the total like so: product *= arr[i][j]
Marius Garbea
@MariusGarbea
Feb 10 2016 00:03
@wearenotgroot and how do i use this?
greg
@wearenotgroot
Feb 10 2016 00:03
@MariusGarbea just like any object call the properties you want
Tyler
@Thiggs
Feb 10 2016 00:03
@dyczol maybe you want a return instead of a console.log?
Aleksander Gębicki
@Takumar
Feb 10 2016 00:03
Hello @dcnr, how are things going? :-)
I see you are working hard!
greg
@wearenotgroot
Feb 10 2016 00:03
@MariusGarbea try to console.log(response); to see what you want, things you are interested on are .status and .message
Norman Dela Cruz
@dcnr
Feb 10 2016 00:04
@Takumar it's all good ahah and I hope it always stays good for everyone :P
Aleksander Gębicki
@Takumar
Feb 10 2016 00:04
@dcnr good to hear :-)
Renzo Mayer
@renzit
Feb 10 2016 00:04
Hey, im a little frustated about 'Local Scope and Functions'
Whatever i do still fail "No global myVar variable"
Bartek
@dyczol
Feb 10 2016 00:05
@Thiggs @broktnet let me give it a shot
Aleksander Gębicki
@Takumar
Feb 10 2016 00:05
@renzit show your code.
If you are sure your code is good, sometimes refreshing web browser helps :-)
Marius Garbea
@MariusGarbea
Feb 10 2016 00:05
@wearenotgroot so instead of jqXHR i write data.status
Vik
@vvang044
Feb 10 2016 00:05
``` var gloveBoxContents = "myStorage.car["inside"]. glove box"; what is wrong this code?
greg
@wearenotgroot
Feb 10 2016 00:05
@MariusGarbea then do that
Norman Dela Cruz
@dcnr
Feb 10 2016 00:05
@renzit remove the console.log outside your function, after you declare myVar inside
broktnet
@broktnet
Feb 10 2016 00:05
@dcnr not sure if I quite follow. Do you mean I need to look through the subarray?
greg
@wearenotgroot
Feb 10 2016 00:05
@MariusGarbea just a name :smile:
Renzo Mayer
@renzit
Feb 10 2016 00:06
function myFunction() {
var myVar = 10;
console.log(myVar);
}
myFunction();
Marius Garbea
@MariusGarbea
Feb 10 2016 00:06
@wearenotgroot ok doesn't work
Ivan Perez
@joannesalfa
Feb 10 2016 00:06
I made a mistake for writing DNA pairing and it results
http://i.imgur.com/I8KKrBo.png
Renzo Mayer
@renzit
Feb 10 2016 00:06
that is the code @Takumar
Collin
@collinferry
Feb 10 2016 00:06
Anyone feel like taking a glance at this Seek and Destroy code and telling me why my filter function isn't working?: http://bit.ly/1Q69LDj
Renzo Mayer
@renzit
Feb 10 2016 00:06
@dcnr already did that, and try everything
greg
@wearenotgroot
Feb 10 2016 00:07
@MariusGarbea the jqXHR will always be in the first parameter
Aleksander Gębicki
@Takumar
Feb 10 2016 00:07
@renzit your code looks good. Try refresh, "Reset" button or another web browser.
Renzo Mayer
@renzit
Feb 10 2016 00:07
i declare myVar in other places, even two times
Ivan Perez
@joannesalfa
Feb 10 2016 00:07
@collinferry using filter, you need to return true or false so it can pick existing values and return NOT destroyed values
Marius Garbea
@MariusGarbea
Feb 10 2016 00:07
@wearenotgroot i am way too tired, thanks for help! will search tomorrow for some documentation
CamperBot
@camperbot
Feb 10 2016 00:07
mariusgarbea sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: mariusgarbea already gave wearenotgroot points
greg
@wearenotgroot
Feb 10 2016 00:08
@MariusGarbea ill om you with the method
Aleksander Gębicki
@Takumar
Feb 10 2016 00:08
@renzit try "hard refresh" by Ctrl + F5
I have checked your code, it works in Firefox and Chrome.
Marius Garbea
@MariusGarbea
Feb 10 2016 00:08
@wearenotgroot ok ty
Vik
@vvang044
Feb 10 2016 00:08
```var gloveBoxContents = "myStorage.car["inside"]. glove box";
whats wrong with that?
Renzo Mayer
@renzit
Feb 10 2016 00:09
@Takumar thanks, ctrl+f5 works for me :D
CamperBot
@camperbot
Feb 10 2016 00:09
renzit sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2256 | @takumar | http://www.freecodecamp.com/takumar
Collin
@collinferry
Feb 10 2016 00:09
@joannesalfa but won't an equation (like the one I'm using) return a true or false each time it runs?
Vik
@vvang044
Feb 10 2016 00:10

this is the full code......
``` // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = "myStorage.car["inside"].glove box";

Aleksander Gębicki
@Takumar
Feb 10 2016 00:10
@renzit very good :-)
Farah Soltane
@chokolate
Feb 10 2016 00:11
hi im ded on this: stand in line: javascript section
the queue
Norman Dela Cruz
@dcnr
Feb 10 2016 00:11

@broktnet your conditions

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

Your for loop will first check for Akira then Harry, Sherlock then Kristian. But if for example, you call your function with lookup("Sherlock", "likes"), it will first see Akira and your if (firstName === contacts[i].firstName && .. would be false so it would go to else if (firstName !== contacts[i].firstName){... and end your loop and function.
Even though Sherlock is valid, it's just 2 objects away, your for loop never reaches it

Aleksander Gębicki
@Takumar
Feb 10 2016 00:11
@chokolate what you have got now? You should add one element item to the array, and remove first element from it, at the end return removed element from your function.
Vik
@vvang044
Feb 10 2016 00:11
anyone ?
Farah Soltane
@chokolate
Feb 10 2016 00:12

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

return item; // Change this line
}

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

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

Aleksander Gębicki
@Takumar
Feb 10 2016 00:12
This message was deleted
@chokolate do you know how to add element to your array?
Farah Soltane
@chokolate
Feb 10 2016 00:13
no
i dont understand how to think about this
Aleksander Gębicki
@Takumar
Feb 10 2016 00:13
@chokolate you should know array.push(argument) method for adding element argument to the end of your array.
Farah Soltane
@chokolate
Feb 10 2016 00:13
i know wat the concept need to give out
Aleksander Gębicki
@Takumar
Feb 10 2016 00:14
@chokolate so add item to the arr array in first step in your function.
Farah Soltane
@chokolate
Feb 10 2016 00:15
you mean declare a variable?
greg
@wearenotgroot
Feb 10 2016 00:15
@chokolate take a closer look--------->queue(arr,item)
Vik
@vvang044
Feb 10 2016 00:15
anyone completed accessing nested objects in JSON?
Ivan Perez
@joannesalfa
Feb 10 2016 00:16
@collinferry you could use loop inside of filter function, in that case:
  function nameFilter (s) {
    //Get index of argument.length
    for(var i = 1; i < arguments.length; i++){ 
      //If parameter is same as index, should return false
      if( s ){
      return false;
      }
    }
    //If not, it can pass destroyed values from argument
    return true;   
  }
Aleksander Gębicki
@Takumar
Feb 10 2016 00:16
@chokolate no, you don't need to declare any variable, push() method is modyfying array, it will add item to it, and your array is already changed.
Ivan Perez
@joannesalfa
Feb 10 2016 00:16
@collinferry you need to compare if is s same than index of argument
Aleksander Gębicki
@Takumar
Feb 10 2016 00:18
@chokolate you need only: arr.push(item); for adding item element to your array.
Vik
@vvang044
Feb 10 2016 00:19

``` // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = "myStorage.car["inside"].glove box"; // Change this line
can only tell me what mistake i made in here?

Farah Soltane
@chokolate
Feb 10 2016 00:20
but how can i make it print the first number on the array
Vik
@vvang044
Feb 10 2016 00:21
???? anyone
Mushfeque Zihan
@zicmic
Feb 10 2016 00:22
hi can some help me with switch statement code on basic javascript : i am trying to add default statement on my switch statement code but it seems
Tobias Murphy
@tmrdr
Feb 10 2016 00:23
@vvang044 remove the "" and put the array and "" around glovebox
@vvang044 var gloveBoxContents = myStorage.car.inside["glove box"];
Vik
@vvang044
Feb 10 2016 00:24
i was trying to do by looking at the example
so we are accessing whats inside the "glove box"...rather than "inside"? is that correct
Jon Spencer
@batboy138
Feb 10 2016 00:28
@zicmic Post your code so we can look at it.
Tobias Murphy
@tmrdr
Feb 10 2016 00:29
@vvang044 yes. Inside is referring to inside the car not inside the glove box
Vik
@vvang044
Feb 10 2016 00:30
makes sense...thank you
Tobias Murphy
@tmrdr
Feb 10 2016 00:30
np
Vik
@vvang044
Feb 10 2016 00:30
@tmrdr
thank you
Jonah Erlich
@jerlich97
Feb 10 2016 00:31
So I figured out filter but I'm still stuck. Any thoughts?
function diff(arr1, arr2) {
  var newArr = arr1.concat(arr2);
  var diffArr = newArr.filter(contains);
  return diffArr;
}

function contains(value, index, arr){
  if(arr.indexOf(value) !== -1){
    return arr.slice(index).indexOf(value) === -1;
  }
  else{
    return false;
  }
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Vik
@vvang044
Feb 10 2016 00:31
my page display someone how change......the code is at the bottom and the instructions is at the top how can i change it back to instructions will be to the left and the code will be to the right ?
Norman Dela Cruz
@dcnr
Feb 10 2016 00:31
@jerlich97 return true not the slice
Jonah Erlich
@jerlich97
Feb 10 2016 00:32
@dcnr yeah but that doesn't do anything, I was using the slice as comparison, setting it to true returns everything true
Norman Dela Cruz
@dcnr
Feb 10 2016 00:33
@jerlich97 oh actually I misread sorry
@jerlich97 you're supposed to diff with the OTHER array
@jerlich97 arr is the array being operated upon
Jonah Erlich
@jerlich97
Feb 10 2016 00:34
@dcnr right arr is, in my code, newArr
Norman Dela Cruz
@dcnr
Feb 10 2016 00:35
@jerlich97 and I didn't notice that you concat hmm
Jonah Erlich
@jerlich97
Feb 10 2016 00:35
@dcnr is the concat hindering me?
@dcnr Essentially, my strategy was to make it one array and delete duplicates
Norman Dela Cruz
@dcnr
Feb 10 2016 00:38
@jerlich97 yeah I see where you're going now there's a trick with using the index and indexOf but it will still leave you with one of the duplicates
@jerlich97 I found it way easier if I didn't concat the two arrs because I can just filter them against one another
then concat their results
by joining them, you'll have to inspect each element if they have duplicates
but by just filtering them against one another, you just remove the value if it's found in the other
Alain Holly
@aholly38
Feb 10 2016 00:44
I'm up to "Check Palindromes" exercise, most of test value go through except for palindrome("1 eye for of 1 eye.") should return false, palindrome("eye") should return true, palindrome("not a palindrome") should return false.
function palindrome(str) {
  // Good luck!

  var convert = /[^A-Za-z0-9]/gi;
  var newStr = str.replace(convert, " ");
  var lowerCaseStr = newStr.toLowerCase();
  var newRev = lowerCaseStr.split().reverse().join();
  var compare = lowerCaseStr.match(/[^A-Za-z0-9]/gi, newRev);

  if (compare){

    return true;
  }else{

  return false; 
}  
}



palindrome("eye");
Aleksander Gębicki
@Takumar
Feb 10 2016 00:46
@aholly38 you split() and join() methods needs arguments, put ther empty string: split("") and join("")
Phacometer
@Phacometer
Feb 10 2016 00:46
hello!
I am in the "find longest word" algorithm challenge
Aleksander Gębicki
@Takumar
Feb 10 2016 00:46
@aholly38 also you don't need match() metod to compare, you can compare lowerCaseStr with newRev
if (lowerCaseStr === newRev) {
Phacometer
@Phacometer
Feb 10 2016 00:47

But this doesn't work: var words = str.split(" ");
var longestWordLength = 0;
for(var word in words) {
longestWordLength = Math.max(longestWordLength, word.length);
}

return longestWordLength;

What am I doing wrong?
Norman Dela Cruz
@dcnr
Feb 10 2016 00:49
@Phacometer word is the index of words
@Phacometer so you should use words[word].length in your Math.max
Phacometer
@Phacometer
Feb 10 2016 00:49
what?
That's really confusing
Norman Dela Cruz
@dcnr
Feb 10 2016 00:50
@Phacometer for in does not work the way you think it does
Phacometer
@Phacometer
Feb 10 2016 00:50
Yeah, it's really weird
Norman Dela Cruz
@dcnr
Feb 10 2016 00:50
@Phacometer it does not take each word in your words array
it's awful for arrays anyway
Phacometer
@Phacometer
Feb 10 2016 00:50
Thanks, I know it now!
Granit Hajdini
@nitiblack
Feb 10 2016 00:53

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

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
what to do here can anybody help me

multiplyAll([1,2,[3]]); should return 6
multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);) should return 54
ichirped
@ichirped
Feb 10 2016 00:57
I can't wrap my head around the array filter(). I looked it up online, and used it an earlier solution too. But I still don't get it, can someone explain it in simple words please ?
Norman Dela Cruz
@dcnr
Feb 10 2016 00:58
@nitiblack you're not supposed to console.log the values, you're supposed to multiply them all
Bartek
@dyczol
Feb 10 2016 00:58
@nitiblack im stock on this one too. Someone suggested to do something like
return arr[i][j] 8 *= product
didn't quite work for me..
Granit Hajdini
@nitiblack
Feb 10 2016 01:00
where to write it
Bartek
@dyczol
Feb 10 2016 01:00
@nitiblack under your second for loop
Norman Dela Cruz
@dcnr
Feb 10 2016 01:01

@ichirped

var numbers = [1, -2, 10, 0, -5];

var result = numbers.filter(function(number) {
  if (number > 0) {
    return true;
  }

  return false;
});

result; // [1, 10]

.filter() takes each element of the array you called it upon and then applies the function.
If that function returns true for that element, then the element is kept, otherwise it's
discarded.

Johannah
@eccentricafterglow
Feb 10 2016 01:01
Hey, I’m totally lost on this: Return Early Pattern for Functions
Alain Holly
@aholly38
Feb 10 2016 01:01
@Takumar I've tried comparing (newRev === lowerCaseStr) and I almost put the parameters for .join("") and split("") but no luck.
Norman Dela Cruz
@dcnr
Feb 10 2016 01:01
@ichirped in my example, it each examines the numbers, and if it's greater than 0, then it is kept by saying return true
Johannah
@eccentricafterglow
Feb 10 2016 01:01

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

console.log (a);
return "Hello";
console.log (b);

}

// Only change code above this line

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

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

bah, didn’t work. :(
Bartek
@dyczol
Feb 10 2016 01:02
@dcnr @nitiblack any other suggestions ? luck ? :)
Norman Dela Cruz
@dcnr
Feb 10 2016 01:02
@dyczol it should be product *= arr[i][j]; :P
you are multiplying product with the value of arr[i][j] and assigning back toproduct
@eccentricafterglow you're supposed to check if a or b is less than 0 and then return undefined
not log them out or return hello
Johannah
@eccentricafterglow
Feb 10 2016 01:04
okay
so
there needs to be an if statement
Norman Dela Cruz
@dcnr
Feb 10 2016 01:05

@eccentricafterglow yes as the instructions say

Instructions

Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

ichirped
@ichirped
Feb 10 2016 01:05
@dcnr so the function that you pass to filter() as arg should be one that returns a boolean value right ?
Norman Dela Cruz
@dcnr
Feb 10 2016 01:06
@ichirped yes! :D
@ichirped using my earlier example you could just rewrite it as
var numbers = [1, -2, 10, 0, -5];

var result = numbers.filter(function(number) {
  return number > 0;
});

result; // [1, 10]
ichirped
@ichirped
Feb 10 2016 01:07
I'm doing the same but not getting the result @dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:07
@ichirped or more verbose
var numbers = [1, -2, 10, 0, -5];

var result = numbers.filter(positiveOnly);

function positiveOnly(number) {
  if (number > 0) {
    return true;
  }

  return false;
}

result; // [1, 10]
@ichirped why what's your code? will you share it?
ichirped
@ichirped
Feb 10 2016 01:08
oh ok let me go back and check my solution
working on Seek and Destroy btw @dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:08
@ichirped Ow I had a feeling it's that
you were using arguments ?
paste your code anyway :P
ichirped
@ichirped
Feb 10 2016 01:09

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

var args = arguments[1];
return arr.filter(function(val){ return val === args;});
}

Norman Dela Cruz
@dcnr
Feb 10 2016 01:10
@ichirped oh you're just checking for one args but destroyer can be called with more than one args

@ichirped for example

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

you're supposed to remove 2 and 3

ichirped
@ichirped
Feb 10 2016 01:11
@dcnr I know, but if i put that code arr.filter(function(val){ return val === args;}); in a for loop it doesn't work to check all args
Norman Dela Cruz
@dcnr
Feb 10 2016 01:11
but with your code, you're only removing 2
@ichirped args = arguments[1] only refers to 2 in that case
ichirped
@ichirped
Feb 10 2016 01:12
args[i] and the whole shebang @dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:13
@ichirped args[i] would be undefined...
ichirped
@ichirped
Feb 10 2016 01:13
@dcnr arguments[i] !! i think i need to take a break lol will revisit this problem later
Norman Dela Cruz
@dcnr
Feb 10 2016 01:13
@ichirped you've specifically set args with just the 2nd argument
@ichirped I know you already know about arguments but I also wrote a wiki about this one, maybe you can get something new about it :P
specifically the last part
bitgrower
@bitgrower
Feb 10 2016 01:15
ah, is that seek & destroy, @dcnr -- I'll have to check out what you wrote ...
ichirped
@ichirped
Feb 10 2016 01:15
@dcnr ahh ok, will read that wiki !! Thanks. I'll revisit this problem later
CamperBot
@camperbot
Feb 10 2016 01:15
ichirped sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 561 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:16
@bitgrower yeah Seek and Destroy was one of the tougher problems because of how arguments object work inside functions and I found myself explaining over and over so I wrote it :D
It's not a direct answer, but I like to think I explained the concept quite clearly
bitgrower
@bitgrower
Feb 10 2016 01:19

yeah, I created a solution where I documented it heavily, including references to where to find the example arguments to array conversion in MDN ...

....also, splice is such a cool function .

which reminds me ...

I should try this out and see .. but I'll ask ...

if I return arr.splice(0,1); -- does that return the removed elements, or the array ?

Clark Arnold
@clarkarnold
Feb 10 2016 01:20
help missing letters
CamperBot
@camperbot
Feb 10 2016 01:20

:point_right: algorithm missing letters [wiki]

Problem Explanation:

  • You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
:pencil: read more about algorithm missing letters on the FCC Wiki
Norman Dela Cruz
@dcnr
Feb 10 2016 01:21
@bitgrower yeah it returns the "spliced" element
@bitgrower result = arr.splice(0,1) result will get the first element of arr
and arr mutilated, you monster you
bitgrower
@bitgrower
Feb 10 2016 01:23
ah, you mean I could do some "arguments optional" tricks with it ?
earlcuritana
@earlcuritana
Feb 10 2016 01:23
need help guys
with javascript
Norman Dela Cruz
@dcnr
Feb 10 2016 01:25
@bitgrower which trick is that?
@earlcuritana hi what you need help with
bitgrower
@bitgrower
Feb 10 2016 01:28
so the modified arr is still sitting on the stack, and would be available for any function which comes along looking for a variable to instantiate ?
EHunt13
@EHunt13
Feb 10 2016 01:29
seek and destroy help
function destroyer(arr) {
 var arrayFinal = [];
  for(var i=0; i<arguments[0].length; i++){
    for(var j=1; j<arguments.length; j++){
      if(arguments[i]!==arguments[j]){
        arrayFinal.push(arguments[i]);
      }
    }            
  }               
  return arrayFinal;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
```
earlcuritana
@earlcuritana
Feb 10 2016 01:30
stand inline queue and array
EHunt13
@EHunt13
Feb 10 2016 01:30
i know i'm way off base
Norman Dela Cruz
@dcnr
Feb 10 2016 01:31
@bitgrower I'm sorry I really don't quite get what you mean but, as long as an object is still in use, it won't get gc'd
earlcuritana
@earlcuritana
Feb 10 2016 01:31

+dcnr with this function queue(arr, item) {
// Your code here

return item; // Change this line
}

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

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

Norman Dela Cruz
@dcnr
Feb 10 2016 01:33
@EHunt13 you should compare arr with arguments[j] :P
EHunt13
@EHunt13
Feb 10 2016 01:35
thanks @dcnr
CamperBot
@camperbot
Feb 10 2016 01:35
ehunt13 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 562 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:36
@EHunt13 oh wait but if you do it that way, you'll get duplciates
EHunt13
@EHunt13
Feb 10 2016 01:36
yea im running into tons of duplicats
hah
i still can't wrap my head around it
or the filter way
Norman Dela Cruz
@dcnr
Feb 10 2016 01:39
@EHunt13 filter's definitely easier
arr.filter(function(val) {
   // check if val should be removed
});
EHunt13
@EHunt13
Feb 10 2016 01:46
i'm trying that way, it says dont make functions within a loop
Kelsey
@kcdilla
Feb 10 2016 01:46
Hey, working on Nesting For Loops and am kinda stuck
Norman Dela Cruz
@dcnr
Feb 10 2016 01:47
@EHunt13 ah I'm guessing you are putting filter inside the for loop
Kelsey
@kcdilla
Feb 10 2016 01:47
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 = product * arr[j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Norman Dela Cruz
@dcnr
Feb 10 2016 01:47
@kcdilla arr[i][j]
Kelsey
@kcdilla
Feb 10 2016 01:48
ok
but why?
Norman Dela Cruz
@dcnr
Feb 10 2016 01:48
@kcdilla the first bracket is for arr itself, the 2nd one is for the array inside arr
Kelsey
@kcdilla
Feb 10 2016 01:48
@dcnr it worked but I don't understand why
Norman Dela Cruz
@dcnr
Feb 10 2016 01:49
var arr = [[1,2],[3,4],[5,6,7]];
`arr[1][0]` would be 3
Kelsey
@kcdilla
Feb 10 2016 01:49
Oh
Ah
yes thank you! @dcnr
CamperBot
@camperbot
Feb 10 2016 01:49
kcdilla sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
RickWisneske
@rwisneske
Feb 10 2016 01:49
@dcnr thanks!
CamperBot
@camperbot
Feb 10 2016 01:49
rwisneske sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 563 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 564 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:49
you're welcome, thank you too @kcdilla
CamperBot
@camperbot
Feb 10 2016 01:49
dcnr sends brownie points to @kcdilla :sparkles: :thumbsup: :sparkles:
:star: 213 | @kcdilla | http://www.freecodecamp.com/kcdilla
bitgrower
@bitgrower
Feb 10 2016 01:49
I'm sorry I really don't quite get what you mean but, as long as an object is still in use, it won't get gc'd <<<--- @dcnr -- what is gc'd ?
Norman Dela Cruz
@dcnr
Feb 10 2016 01:50
thanks too @rwisneske good night and day :P
CamperBot
@camperbot
Feb 10 2016 01:50
dcnr sends brownie points to @rwisneske :sparkles: :thumbsup: :sparkles:
:star: 206 | @rwisneske | http://www.freecodecamp.com/rwisneske
Norman Dela Cruz
@dcnr
Feb 10 2016 01:51
@bitgrower Garbage Collection
bitgrower
@bitgrower
Feb 10 2016 01:51
ahhh ...
are you done for the day/night @dcnr ... and thanks
CamperBot
@camperbot
Feb 10 2016 01:52
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 565 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 01:52
@bitgrower oh no i'll be on for couple hours, I just step away now and then
@bitgrower but rwisneske said he's going
bitgrower
@bitgrower
Feb 10 2016 01:52
ahh ... g'night @rwisneske
arjunpunnam
@arjunpunnam
Feb 10 2016 01:58
Hi

function myTest(val) {
if (val <=24 ) { // Change this line
return "Under 25";
}

if (val <= 54) { // Change this line
return "Under 55";
}

return "55 or Over";
}

// Change this value to test
myTest(10);

but it still says You should use the < operator at least twice
Norman Dela Cruz
@dcnr
Feb 10 2016 02:01
@arjunpunnam it says return "Under 25" so your if should be val < 25 because <= means less than or equal to
@arjunpunnam same goes for the other one "Under 55"
Jon Spencer
@batboy138
Feb 10 2016 02:02
I'm stuck on Return Largest Numbers in an Array.
Norman Dela Cruz
@dcnr
Feb 10 2016 02:02
@arjunpunnam val < 25 is the same as saying val <= 24
@batboy138 hi, will you paste your code?
arjunpunnam
@arjunpunnam
Feb 10 2016 02:02
oh shit got it @dcnr
@dcnr thanks
CamperBot
@camperbot
Feb 10 2016 02:03
arjunpunnam sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 566 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 02:03
no probs, thanks too @arjunpunnam
CamperBot
@camperbot
Feb 10 2016 02:03
dcnr sends brownie points to @arjunpunnam :sparkles: :thumbsup: :sparkles:
:star: 191 | @arjunpunnam | http://www.freecodecamp.com/arjunpunnam
Jonah Erlich
@jerlich97
Feb 10 2016 02:03
For roman numeral converter should I make an array of all major roman numerals? ex (1, 4, 5, 10, 20)
Norman Dela Cruz
@dcnr
Feb 10 2016 02:04
@jerlich97 depends on how you'd approach the problem, for me, I just mapped the numbers through their place values
Jon Spencer
@batboy138
Feb 10 2016 02:04
For some reason, I can't copy+paste my code!
Jonah Erlich
@jerlich97
Feb 10 2016 02:05
@dcnr what do you mean by that?
rphares
@rphares
Feb 10 2016 02:05
@batboy138 , you mean formatted?
Norman Dela Cruz
@dcnr
Feb 10 2016 02:05

@batboy138 type ```js those are backticks the key above Tab, left of 1, and below Esc. then Shift+Enter to go to next line, paste your code, then shift+enter again and another ``` so it would look like this
```js

<paste here>
```

Jon Spencer
@batboy138
Feb 10 2016 02:06
function largestOfFour(arr) {
  // You can do this!
  var x = 0;
  var y = 3;
  var z = 4;
  for(var i = 0; i < arr; i++){
    if(arr[i] > x){
      //return largest num
    }
  }
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Nevermind. I got it working again. The copy+paste thing, not my code.
Norman Dela Cruz
@dcnr
Feb 10 2016 02:07
@jerlich97 I mean I mapped them based on their place value. I have an array of roman numerals for hundreds place, tens place, etc
Jonah Erlich
@jerlich97
Feb 10 2016 02:09
@dcnr like this
 var ones = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
Norman Dela Cruz
@dcnr
Feb 10 2016 02:09
@batboy138 arr is an array holding other arrays, so if you were to loop through using for loops you'd have to nest your loops
Jonah Erlich
@jerlich97
Feb 10 2016 02:09
@dcnr that seems a bit redundant. Shouldn't there be a more efficient way
Norman Dela Cruz
@dcnr
Feb 10 2016 02:09
@jerlich97 yes, looks brute forcey unlike the other wiki solutions :P
Jon Spencer
@batboy138
Feb 10 2016 02:11
@dcnr How many loops should I use? 2? 3? And will I need if/else Statements?
Chris Dalton
@manwithgills
Feb 10 2016 02:11

Good evening fellow campers. I am stuck and need a bit of guidance.

function findLongestWord(str) {
  var wordArray = str.split(" ");
  var longestWord = 0;
  for(i=0; i<wordArray[i].length; i++){
    if(longestWord<wordArray[i].length){
      longestWord = wordArray[i].length;
    }
  }
  return longestWord;
}

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

I am not sure where I am going wrong.

Norman Dela Cruz
@dcnr
Feb 10 2016 02:11
@batboy138 something like this exercise http://www.freecodecamp.com/challenges/nesting-for-loops
Clark Arnold
@clarkarnold
Feb 10 2016 02:11
help missing letters
CamperBot
@camperbot
Feb 10 2016 02:11

:point_right: algorithm missing letters [wiki]

Problem Explanation:

  • You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
:pencil: read more about algorithm missing letters on the FCC Wiki
Norman Dela Cruz
@dcnr
Feb 10 2016 02:12
@manwithgills I think you meant i < wordArray.length :P
Jon Spencer
@batboy138
Feb 10 2016 02:12
@manwithgills I might be able to help with this.
Norman Dela Cruz
@dcnr
Feb 10 2016 02:12
@manwithgills and not i < wordArray[i].length
Alain Holly
@aholly38
Feb 10 2016 02:15
@khaduch I've already solved that challenge. I'm up to the Palindrome challenge
Chris Dalton
@manwithgills
Feb 10 2016 02:15
@dcnr when I make that change is still does not computer right. @batboy138 I can use all the help I can get
Conrad Bogus
@ConradBo
Feb 10 2016 02:17
hi yall
Chris Dalton
@manwithgills
Feb 10 2016 02:18

Here is the code revised

function findLongestWord(str) {
  var wordArray = str.split(" ");
  var longestWord = 0;
  for(i=0; i<wordArray.length; i++){
    if(longestWord<wordArray.length){
      longestWord = wordArray[i].length;
    }
  }
  return longestWord;
}

findLongestWord("What if we try a super-long word such as otorhinolaryngology");

Hi @ConradBo

Norman Dela Cruz
@dcnr
Feb 10 2016 02:18
@manwithgills I made the change and it passed
@manwithgills oh you replaced the second one too
@manwithgills I just meant the for loop
@manwithgills don't change the if
Conrad Bogus
@ConradBo
Feb 10 2016 02:18
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  function isNotFalse(value) {
  return value !== (false, null, 0, NaN, undefined, "");
}

var filtered = arr.filter(isNotFalse);


  return arr;
}

bouncer([7, "ate", "", false, 9]);
My attempt thus far at "Falsy Bouncer", any tips/suggestions to make it work?
Chris Dalton
@manwithgills
Feb 10 2016 02:18
@dcnr Can you explain why?
greg
@wearenotgroot
Feb 10 2016 02:19
@ConradBo might as well use a Boolean wrapper
Norman Dela Cruz
@dcnr
Feb 10 2016 02:19
@manwithgills wordArray is your main array of your broken up words. wordArray[i] is each of the word. So if you want to loop through the entire array, you would use wordArray.length
Luke Murray
@vremerz
Feb 10 2016 02:20

Hi, can someone help me with this- dont know why it isnt working. Testing Objects for properties.
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp); {
return myObj[checkProp];
}
return "Not Found";
}

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

Clark Arnold
@clarkarnold
Feb 10 2016 02:20
function fearNotLetter(str) {
  var arr=[];

  for (var i=0; i<str.length; i++) {
    currentLetter = str[i];
    code = currentLetter.charCodeAt();
    nextLetter = str[i+1];
    nextCode = nextLetter.charCodeAt();
    if (code == nextCode-1) {

    } else {
      arr.push(String.fromCharCode(nextCode-1));
    }
  }
  return arr;
}
Clark Arnold
@clarkarnold
Feb 10 2016 02:20
Any advice on Missing Letters algorithm?
Norman Dela Cruz
@dcnr
Feb 10 2016 02:20
@manwithgills
wordArray = ["The", "quick", "brow", etc...];
wordArray[0]; // "The"
Chris Dalton
@manwithgills
Feb 10 2016 02:20
@dcnr Makes sense. Not sure why I was missing it.
rphares
@rphares
Feb 10 2016 02:20
@vremerz , you need an if in that first line,
and no ; after the condition :)
greg
@wearenotgroot
Feb 10 2016 02:21
@ConradBo you cant compare things like that though
Chris Dalton
@manwithgills
Feb 10 2016 02:21
I tested it before I put the if statement in and got what I was looking for. If I understand the correction you made was I was iterating through the letters of each word by using wordArray[i].length.
Luke Murray
@vremerz
Feb 10 2016 02:22
@rphares Sweet, cheers man
Norman Dela Cruz
@dcnr
Feb 10 2016 02:22
@clarkarnold you're supposed to return the character, not an array :D
rphares
@rphares
Feb 10 2016 02:23
anytime~
Norman Dela Cruz
@dcnr
Feb 10 2016 02:23
@clarkarnold and you should stop the loop once you've found your missing letter, also check for out of bounds. If your loop reaches str's end, nextLetter would be undefined
Conrad Bogus
@ConradBo
Feb 10 2016 02:24
@wearenotgroot
should I do away with the "isNotFalse(value)" function alltogether?
Clark Arnold
@clarkarnold
Feb 10 2016 02:25
@dcnr I cought the first part, but Im having trouble with your second tip..
greg
@wearenotgroot
Feb 10 2016 02:26
@ConradBo is fine but the comparison you do is not quite right
@ConradBo try out what i linked you
@ConradBo will make it easier and shorter
cannelflow
@cannelflow
Feb 10 2016 02:27
@vremerz do like if(myObj.hasOwnProperty(checkProp))
rest is f9
rphares
@rphares
Feb 10 2016 02:28
( @cannelflow !! WB :) )
Tarik Nachat
@intertarik
Feb 10 2016 02:28
I didn't understand the golf game, please someone help me
greg
@wearenotgroot
Feb 10 2016 02:28
@ConradBo so using Boolean(your value here) wrapper will initialise anything passed to it with false value if they are 0, -0, null, false, NaN, undefined, or the empty string ("")
otherwise the will be true
cannelflow
@cannelflow
Feb 10 2016 02:28
@rphares GM :smile:
Norman Dela Cruz
@dcnr
Feb 10 2016 02:29
@clarkarnold maybe limit your loop to str.length - 1 so nextLetter wouldn't be undefined? Or maybe check if nextLetter is undefined then that means you've reached the end, and there are no missing letters. So just return ""
Collin
@collinferry
Feb 10 2016 02:29
A belated thanks to @joannesalfa, though having a separate function just doesn't seem to cooperate. I'm guessing there are rules about calling a function into a function or something higher level that I just don't know about.
CamperBot
@camperbot
Feb 10 2016 02:29
collinferry sends brownie points to @joannesalfa :sparkles: :thumbsup: :sparkles:
:star: 383 | @joannesalfa | http://www.freecodecamp.com/joannesalfa
Conrad Bogus
@ConradBo
Feb 10 2016 02:30
@wearenotgroot thnx dude, i'LL check out the link.
CamperBot
@camperbot
Feb 10 2016 02:30
conradbo sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 713 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 10 2016 02:30
@ConradBo YW
@ConradBo you can also just return val; but it wil probably just confuse you
Marie
@Marie79
Feb 10 2016 02:31

Need help with nesting for loops please!
Instructions: Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr.

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0;i < arr.length;i++) {
product= arr[i];
for (var j=0; j < arr[i][j].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]]);

rphares
@rphares
Feb 10 2016 02:32
@intertarik , you just need to make some if statements comparing strokes and par.
example:
 else if (strokes == (par + 27)){
    return "Something you want to return";
  }
Okan
@Okandja
Feb 10 2016 02:33
Hello, i'm having trouble with some Javascript
rphares
@rphares
Feb 10 2016 02:33
@Marie79 , you are really close,
first-- check the example-- your second for-- arr[i][j].length;
what should that be?
Okan
@Okandja
Feb 10 2016 02:34
I'm supposed to convert celsius to fahrenheit using an algorithm, i've defined my var but everything past that is confusing
rphares
@rphares
Feb 10 2016 02:34
Second, you are nesting the loops so, you dont want the extra product= arr[i]; line after the first for, @Marie79
@Okandja , can you paste your code, please?
Conrad Bogus
@ConradBo
Feb 10 2016 02:35
@wearenotgroot lol probably, i'm putting booleans in right now
rphares
@rphares
Feb 10 2016 02:35
@Marie79 third, you want product, so you might consider using *= in that last set of {} :)
Okan
@Okandja
Feb 10 2016 02:35
I'm sorry, i just figured it out, thanks anyway :)
rphares
@rphares
Feb 10 2016 02:36
sure thing, well done~
Collin
@collinferry
Feb 10 2016 02:38
Anyone an expert on the filter method for arrays? I'm working on Seek and Destroy and kinda determined to make this work my way.
icepeda
@icepedad
Feb 10 2016 02:40
hey guys, im stuck in: Escape Sequences in Strings
Marie
@Marie79
Feb 10 2016 02:40
@rphares Regarding first comment.. should it be arr[i][j].length;j++
icepeda
@icepedad
Feb 10 2016 02:40
Instructions
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
rphares
@rphares
Feb 10 2016 02:41
@Marie79 , no-- lose the [j] in length...
@icepedad , you just need to use the chart on the left to write that in code,
for example, backslash would be \\
and assign it to myStr :)
(hint: if its name is myStr, you probably want quotes around the whole sequence :blush: )
CamperBot
@camperbot
Feb 10 2016 02:43
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Marie
@Marie79
Feb 10 2016 02:43
@rphares got it, thanks!
CamperBot
@camperbot
Feb 10 2016 02:43
marie79 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2610 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 10 2016 02:44
anytime~
Happy coding :)
Marie
@Marie79
Feb 10 2016 02:44
:clap:
icepeda
@icepedad
Feb 10 2016 02:45
let me try that
rphares
@rphares
Feb 10 2016 02:45
sure thing~
icepeda
@icepedad
Feb 10 2016 02:48
it worked :)
@rphares tnx, i was i few minutes stuck in there
CamperBot
@camperbot
Feb 10 2016 02:49
icepedad sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2615 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 10 2016 02:49
anytime! Happy coding~
Collin
@collinferry
Feb 10 2016 02:54
```
Why oh why does this filter method not seem to do anything?
function destroyer(arr) {

  var initialArray = arguments[0];
  var survivors = initialArray.filter(function(s) {
    for (var i = 1; i < arguments.length; i++){ 
    return s != arguments[i];
    }

});
return survivors;
}

destroyer(["tree", "hamburger", 53], "tree", 53);
Norman Dela Cruz
@dcnr
Feb 10 2016 02:55
@collinferry arguments is different for each function
@collinferry your filter arguments isn't the same as destroyer's
RK1225
@RK1225
Feb 10 2016 02:55

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

// Only change code below this line
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}

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

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

rphares
@rphares
Feb 10 2016 02:56
@RK1225 , okay, good start,
rphares
@rphares
Feb 10 2016 02:56
we want to format that table, though, just like the example @RK1225
Norman Dela Cruz
@dcnr
Feb 10 2016 02:56
@collinferry you have the right format though, just can't use arguments that way
Collin
@collinferry
Feb 10 2016 02:56
@dcnr ohhhhhh, this explains so much. I just felt myself learn. Thank you thank you.
CamperBot
@camperbot
Feb 10 2016 02:56
collinferry sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
RK1225
@RK1225
Feb 10 2016 02:56
sorry, meant to add comment to it before sending
CamperBot
@camperbot
Feb 10 2016 02:56
:star: 567 | @dcnr | http://www.freecodecamp.com/dcnr
rphares
@rphares
Feb 10 2016 02:56
var lookup =  {
    "alpha": "Adams",
Okan
@Okandja
Feb 10 2016 02:56
Need some guidance with some Javascript
rphares
@rphares
Feb 10 2016 02:57
first line might look like that, @RK1225 :)
RK1225
@RK1225
Feb 10 2016 02:57
but...I am supposed to be changing the switch to a lookup, which i did like this

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

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

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

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

Okan
@Okandja
Feb 10 2016 02:57

Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes"

my code var myStr="I am a \"double quoted\" string inside \"double quotes\" ";
rphares
@rphares
Feb 10 2016 02:57
ohh, okay-- @RK1225 , good start!
RK1225
@RK1225
Feb 10 2016 02:57
however, it won't produce any results
rphares
@rphares
Feb 10 2016 02:57
@Okandja , there is an extra space between he also two " "
@RK1225 , so three things to fix
first, you dont need [] around "Frank" @RK1225
Okan
@Okandja
Feb 10 2016 02:58
Jeez, thanks a lot @rphares
CamperBot
@camperbot
Feb 10 2016 02:58
okandja sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2616 | @rphares | http://www.freecodecamp.com/rphares
RK1225
@RK1225
Feb 10 2016 02:58
k
rphares
@rphares
Feb 10 2016 02:58
then, we need to 1) build our lookup
2) think about how to return
lets start with the lookup--
check out the example on the left
RK1225
@RK1225
Feb 10 2016 02:58

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

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

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

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

built my lookup, can't seem to get it to return properly
rphares
@rphares
Feb 10 2016 02:59
their table is named var alpha and they want to get 2, so they write alpha[2] @RK1225
not the table lookup, i mean the thing that looks up val,
RK1225
@RK1225
Feb 10 2016 02:59
at the bottom they added phoneticLookup(val)
rphares
@rphares
Feb 10 2016 03:00
thats not how it works, either... thats just the function,
we need to make the function do the looking up part,
RK1225
@RK1225
Feb 10 2016 03:00
ah
rphares
@rphares
Feb 10 2016 03:00
your table is named var lookup and you want to get val
RK1225
@RK1225
Feb 10 2016 03:00
yes
rphares
@rphares
Feb 10 2016 03:00
how could you write that, looking at the example i sent? :)
RK1225
@RK1225
Feb 10 2016 03:01
it instructed me to name it "lookup"
rphares
@rphares
Feb 10 2016 03:01
yes, and thats good
we need to add two things,
RK1225
@RK1225
Feb 10 2016 03:01
k
rphares
@rphares
Feb 10 2016 03:01
(and remove those brackets around frank)
RK1225
@RK1225
Feb 10 2016 03:01
done
rphares
@rphares
Feb 10 2016 03:02
their table is named var alpha and they want to get 2, so they write alpha[2] @RK1225
your table is named var lookup and you want to get val... how can you write that?
RK1225
@RK1225
Feb 10 2016 03:02
lookup[val] ?
rphares
@rphares
Feb 10 2016 03:02
yep!
now we need to think about how to return that...
you are gonna return result, right?
(its below the do not change line)
RK1225
@RK1225
Feb 10 2016 03:03
yes
rphares
@rphares
Feb 10 2016 03:03
so, we need to put the nice lookup[val] you just built in result before you return...
Norman Dela Cruz
@dcnr
Feb 10 2016 03:04
@RK1225 As an aside, I wrote this yesterday about looking up objects with dot and brackets. Maybe you can get something about it?
Peter Elbaum
@elbaumpj
Feb 10 2016 03:04
Could anyone help with the Lookup exercise? I'm close but can't tell what I'm missing...
var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank",
  };
rphares
@rphares
Feb 10 2016 03:04
they put " " in result at the top... we can use the same way to reassign result after the table, before we return, and then when we run it, you will get what you want! :) @RK1225
sure, @elbaumpj , same one we were just talking about
nice table-- well done,
RK1225
@RK1225
Feb 10 2016 03:04
literally in the process of asking myself @elbaumpj
rphares
@rphares
Feb 10 2016 03:04
now you have two steps left--
you need to build the thing that gets val for you,
and figure out how to return it,
lets start with getting val-- check out the example on the left
their table is named var alpha and they want 2, so they write alpha[2]
your table is named var lookup and you want val, so you could write...? @elbaumpj
Peter Elbaum
@elbaumpj
Feb 10 2016 03:06
@rphares I think I'm following you...
rphares
@rphares
Feb 10 2016 03:07
okay, so... tableName[thingWeWantToGet]... what would that be in yours, @elbaumpj ?
Peter Elbaum
@elbaumpj
Feb 10 2016 03:07
lookup[val]
rphares
@rphares
Feb 10 2016 03:07
once you have that, you just need to think about how to return it... because just writing that doesn't give use what we want when we try and run our function, it has to connect the return,
yep!
so... you are gonna return result
(its below the do not change line, no choice :wink2:)
so, we want to put that nice lookup[val] in result before we return result...
RK1225
@RK1225
Feb 10 2016 03:08
how do u put it in result?
rphares
@rphares
Feb 10 2016 03:08
how could we reassign result after the table, to be sure it gives us our desired answer when we run the function?
well, at the top, they have already put something in result...
Peter Elbaum
@elbaumpj
Feb 10 2016 03:09
result = lookup[val] ??
rphares
@rphares
Feb 10 2016 03:09
result = " "
yep!! well done, @elbaumpj !
Peter Elbaum
@elbaumpj
Feb 10 2016 03:09
Thanks! @rphares
CamperBot
@camperbot
Feb 10 2016 03:09
elbaumpj sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
RK1225
@RK1225
Feb 10 2016 03:09
it says not to change that code
rphares
@rphares
Feb 10 2016 03:09
Anytime!
CamperBot
@camperbot
Feb 10 2016 03:09
:star: 2617 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 10 2016 03:09
yes-- see what @elbaumpj did :point_up: February 10, 2016 10:09 AM ?
you can do that after the table,
you are just changing it,
you can put stuff in at any time,
RK1225
@RK1225
Feb 10 2016 03:10
got it got it!
rphares
@rphares
Feb 10 2016 03:10
just by writing something new on the right of the = :)
awesome, congrats and happy coding, @RK1225 ~
one more thing to both of you--
RK1225
@RK1225
Feb 10 2016 03:11
i get it now. i didn't think you could redefine result after it was defined
Norman Dela Cruz
@dcnr
Feb 10 2016 03:11
What! There's always a choice! :fire: Don't let any silly comment stop you from the glory you deserve! :triumph:
rphares
@rphares
Feb 10 2016 03:11
this is one of the first lessons where we used something like val instead of the specific string, etc
that will be happening more and more often--
we dont want to write for the specifics, they change
Peter Elbaum
@elbaumpj
Feb 10 2016 03:12
@rphares it's not going through...the last in the list of things to check says not to use any case, switch, or if statements....doesn't seem like there's any way around that.
Kelsey
@kcdilla
Feb 10 2016 03:12
Hi, is anyone able to go over the Profile Lookup challenge with me? It looks like there are objects within an array - but how do I identify and access each object?
rphares
@rphares
Feb 10 2016 03:12
hmm can you paste your whole code, @elbaumpj , must be a small thing we missed :)
RK1225
@RK1225
Feb 10 2016 03:12
the lookup replaces the other statements @elbaumpj
rphares
@rphares
Feb 10 2016 03:12
( @dcnr -- disagree. a LOT of us newbies really struggle with that part--
Kelsey
@kcdilla
Feb 10 2016 03:13
like... how do i look up a property of a specific object, if the object itself doesn't seem to have an identifier?
rphares
@rphares
Feb 10 2016 03:13
and dont even have a clue how or why its important
can't tell you how many times people haven't done anything to connect their code and the return, @dcnr
the lessons are *also& showing them that is important,
and ways to make it actually return
Norman Dela Cruz
@dcnr
Feb 10 2016 03:13
@rphares or they'd start something and ignore the predefined parts, it goes either way
Peter Elbaum
@elbaumpj
Feb 10 2016 03:14
@RK1225 @rphares thanks! got it now
CamperBot
@camperbot
Feb 10 2016 03:14
elbaumpj sends brownie points to @rk1225 and @rphares :sparkles: :thumbsup: :sparkles:
:warning: elbaumpj already gave rphares points
Norman Dela Cruz
@dcnr
Feb 10 2016 03:14
sometimes it's not so obvious, especially when the description can oftentimes be vague :(
CamperBot
@camperbot
Feb 10 2016 03:14
:star: 213 | @rk1225 | http://www.freecodecamp.com/rk1225
rphares
@rphares
Feb 10 2016 03:14
true-- which is why i feel showing them looking at what was expected and why they missed it is important to helping them learn,
i can tell people more simple ways on several (even though I'm a newbie) ... but then they dont always learn some of those repeated lessons in there ...
arjunpunnam
@arjunpunnam
Feb 10 2016 03:18
Hi im having problem with below code
couldnt find why

function myTest(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";

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

// Change this value to test
myTest(3);

Franco Zapata
@Francozt01
Feb 10 2016 03:18
@arjunpunnam Capitalize the answers ?
"Alpha" "Beta" "Gamma"
arjunpunnam
@arjunpunnam
Feb 10 2016 03:19
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
rphares
@rphares
Feb 10 2016 03:19
nah, it was lowercase, i think.
arjunpunnam
@arjunpunnam
Feb 10 2016 03:19
that isnt the case i doubt
yes
rphares
@rphares
Feb 10 2016 03:20
@arjunpunnam , did you close the table before the return?
arjunpunnam
@arjunpunnam
Feb 10 2016 03:20
no i didnt and thats the mistake
rphares
@rphares
Feb 10 2016 03:20
(and... did you add a } to the do not change part?)
sweet! happy coding~
arjunpunnam
@arjunpunnam
Feb 10 2016 03:21
thanks for finding it
rphares
@rphares
Feb 10 2016 03:21
anytime~
Kelsey
@kcdilla
Feb 10 2016 03:22
Hey, can someone help me figure out how to access a certain object within an array?
specifically for the Profile Lookup challenge
i don't even know where to start
Jason
@carpediem1213
Feb 10 2016 03:22
kcdilla, I'm having the same issue with the same challenge
Kelsey
@kcdilla
Feb 10 2016 03:22
@carpediem1213 phew
it's not just me
i feel like i'm missing a couple lessons
rphares
@rphares
Feb 10 2016 03:23
most everyone struggles on that one-- you are not alone
Jason
@carpediem1213
Feb 10 2016 03:23
@kcdilla so far, I think it needs to start with a "for" loop to go through the array of objects, but I need some help !
Kelsey
@kcdilla
Feb 10 2016 03:23
but is it arrays within arrays?
it seems like objects
rphares
@rphares
Feb 10 2016 03:23
@carpediem1213 , another camper wrote some pseudo that might help you,
Kelsey
@kcdilla
Feb 10 2016 03:23
but they aren't identified by anything??
maybe the curly brackets are throwing me off
rphares
@rphares
Feb 10 2016 03:24
for each item in the contact list
    does this person have the name we are looking for?
        YES - does this person have the property we are looking for?
           YES - return the property value
           NO - return the 'no such property' return
        NO - (this s the non-matching name test) just continue the loop
(after running out of names) - return "No such contact"
Jason
@carpediem1213
Feb 10 2016 03:24
@rphares thanks! I think I'll work with that
CamperBot
@camperbot
Feb 10 2016 03:24
carpediem1213 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2618 | @rphares | http://www.freecodecamp.com/rphares
Kelsey
@kcdilla
Feb 10 2016 03:25
That makes sense @rphares - but I don't understand how to pinpoint the prop that goes along with that name
Jason
@carpediem1213
Feb 10 2016 03:25
@kcdilla so we have to cycle through the array with a "for" loop for sure
Kelsey
@kcdilla
Feb 10 2016 03:25
so like... first we have to find the array with that name
and once we do, we check for the prop?
are these arrays? why are the brackets curly?
rphares
@rphares
Feb 10 2016 03:25
heh-- I'm terrible at explaining things, thats why i stole their pseudo to help others
Jason
@carpediem1213
Feb 10 2016 03:25
@kcdilla {1,2,3,4} is an array
rphares
@rphares
Feb 10 2016 03:25
(thanks, @khaduch !! twice now :) )
CamperBot
@camperbot
Feb 10 2016 03:25
rphares sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 501 | @khaduch | http://www.freecodecamp.com/khaduch
Jason
@carpediem1213
Feb 10 2016 03:26
@kcdilla I think it's essentially the same as [1,2,3,4]
Kelsey
@kcdilla
Feb 10 2016 03:26
do we know if there's a good reason to use curly vs. square brackets?
Norman Dela Cruz
@dcnr
Feb 10 2016 03:26
Sorry again , but I'm going for a shameless plug here. I wrote something about accessing objects with dot and bracket notation. I hope it gets the message across on the ways of getting the values.
Aaron Graves
@gravesmeister
Feb 10 2016 03:26
Square brackets are for arrays I believe
Jason
@carpediem1213
Feb 10 2016 03:27
@dcnr thanks!
CamperBot
@camperbot
Feb 10 2016 03:27
carpediem1213 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 568 | @dcnr | http://www.freecodecamp.com/dcnr
Aaron Graves
@gravesmeister
Feb 10 2016 03:27
Hello @rphares How're you?
Kelsey
@kcdilla
Feb 10 2016 03:27
@gravesmeister then why does it look like there are curly brackets holding arrays?
Norman Dela Cruz
@dcnr
Feb 10 2016 03:27
@kcdilla a [] would signify an array, and {} an "object"
rphares
@rphares
Feb 10 2016 03:27
Good good, @gravesmeister ~
thanks, @gravesmeister , you?
CamperBot
@camperbot
Feb 10 2016 03:27
rphares sends brownie points to @gravesmeister :sparkles: :thumbsup: :sparkles:
:star: 225 | @gravesmeister | http://www.freecodecamp.com/gravesmeister
Kelsey
@kcdilla
Feb 10 2016 03:27
@dcnr ok. do i treat them differently then?
Jason
@carpediem1213
Feb 10 2016 03:27
@dcnr @kcdilla but where it gets confusing is JS looks at objects like arrays, right?
@dcnr hence the need for a "for" loop
Kelsey
@kcdilla
Feb 10 2016 03:28
@carpediem1213 Does it? I thought so... ok
Aaron Graves
@gravesmeister
Feb 10 2016 03:28
Doing ok. I had to take a break for a few days. I was letting this frustrate me so I needed to clear my mind
Kelsey
@kcdilla
Feb 10 2016 03:28
i'll give it a shot...
Vince
@Vince33
Feb 10 2016 03:28
an array is an object
Aaron Graves
@gravesmeister
Feb 10 2016 03:28
I had to change my frame of mind
Norman Dela Cruz
@dcnr
Feb 10 2016 03:28
@carpediem1213 you can't do a standard for loop on an object {}, but you can on an array
Vince
@Vince33
Feb 10 2016 03:28
it is a special object
that has a bunch of array methods as properties
like splice() and length
Kelsey
@kcdilla
Feb 10 2016 03:29
oh jeez
Norman Dela Cruz
@dcnr
Feb 10 2016 03:29
well everything in js is some type of object so let's just say an array is [] and an object {} is a collection of key/value pairs.
Vince
@Vince33
Feb 10 2016 03:30
sorry maybe gave a little to much info
but under the hood that is what an array is
but it is super cool cause you get all that functionality out of the box
Kelsey
@kcdilla
Feb 10 2016 03:30
I think I might have an idea of how to attack this
but first
sleep.
thanks @dcnr @carpediem1213 @Vince33
CamperBot
@camperbot
Feb 10 2016 03:31
kcdilla sends brownie points to @dcnr and @carpediem1213 and @vince33 :sparkles: :thumbsup: :sparkles:
:star: 356 | @vince33 | http://www.freecodecamp.com/vince33
:star: 569 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 218 | @carpediem1213 | http://www.freecodecamp.com/carpediem1213
rphares
@rphares
Feb 10 2016 03:31
Im glad you are back, @gravesmeister :)
Norman Dela Cruz
@dcnr
Feb 10 2016 03:31
@kcdilla the trick is "drilling down" one at a time :P
rphares
@rphares
Feb 10 2016 03:31
rest well, @kcdilla ~
Norman Dela Cruz
@dcnr
Feb 10 2016 03:32
@kcdilla good night! :zzz: :sleeping:
Aaron Graves
@gravesmeister
Feb 10 2016 03:32
Thanks @rphares Me too. JavaScript bucked me off but I got back up and I'm ready for more
CamperBot
@camperbot
Feb 10 2016 03:32
gravesmeister sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2620 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 10 2016 03:33
i feel that way all the time-- very normal~ Small breaks help!
Aaron Graves
@gravesmeister
Feb 10 2016 03:33
Yes they do.
I think 3 days was too long but what can I do but keep on keeping on
Vince
@Vince33
Feb 10 2016 03:34
i like the space sometime helps me digest
Norman Dela Cruz
@dcnr
Feb 10 2016 03:35
We all need some diffuse mode sometimes :D
Aaron Graves
@gravesmeister
Feb 10 2016 03:35
Yeah. JavaScript really gives me a short fuse sometimes but I think that's because it makes me feel dumb
It makes me feel like I have an IQ of 1
rphares
@rphares
Feb 10 2016 03:36
Hear that, its definitely humbling!
Aaron Graves
@gravesmeister
Feb 10 2016 03:36
Tru dat
rphares
@rphares
Feb 10 2016 03:36
but... it just takes time, study, and practice~ We'll get there :)
Aaron Graves
@gravesmeister
Feb 10 2016 03:36
Agreed
Jason
@carpediem1213
Feb 10 2016 03:37
@dcnr thanks again for that wiki... I think it's finally sinking in!
CamperBot
@camperbot
Feb 10 2016 03:37
carpediem1213 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: carpediem1213 already gave dcnr points
rphares
@rphares
Feb 10 2016 03:37
Ill be back shortly-- gotta step AFK for a bit-- happy to see you and happy coding! :)
Aaron Graves
@gravesmeister
Feb 10 2016 03:37
Take care @rphares
Norman Dela Cruz
@dcnr
Feb 10 2016 03:38
This message was deleted
Jason
@carpediem1213
Feb 10 2016 03:38
gn all!
Aaron Graves
@gravesmeister
Feb 10 2016 03:38
gn
Norman Dela Cruz
@dcnr
Feb 10 2016 03:38
@carpediem1213 please give me feedback on the hard to understand parts, or if on where I should elaborate more :D
@carpediem1213 goodnight!
Aaron Graves
@gravesmeister
Feb 10 2016 03:39
Can anyone help me with Nesting For Loops?
Jason
@carpediem1213
Feb 10 2016 03:39
@dcnr will do. gn. I think this is what I needed to see.... hard to visual objects within objects within arrays, etc etc
visualize*
Aaron Graves
@gravesmeister
Feb 10 2016 03:39
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++) {
    for (var j=0; j < arr[i].length; j++) {
      console.log(arr[i][j]);
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
I pretty much just copied the example because I don't fully understand exactly what's going on here
Norman Dela Cruz
@dcnr
Feb 10 2016 03:40
@carpediem1213 ah yeah I understand what you mean! have a good rest! :sleeping:
Jason
@carpediem1213
Feb 10 2016 03:40
@gravesmeister you don't want to output to the console, you just want to do some math (multiply all)
Thom
@GABAB6
Feb 10 2016 03:40

Not really sure what's going on with this one. I thought I had it right, but there's something missing. Can anyone point me in the right direction? ```js // Setup
function phoneticLookup(val) {
var result = "";

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

"bravo":"Boston",

"charlie":"Chicago",

"delta":"Denver",

"echo":"Easy",

"foxtrot":"Frank",

};

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

// Change this value to test
phoneticLookup("charlie"); ``` I'm supposed to convert a switch statement into a table called "lookup," the use it to lookup "val" and assign the associated string to the "result" variable.

Aaron Graves
@gravesmeister
Feb 10 2016 03:40
@carpediem1213 ok thanks
CamperBot
@camperbot
Feb 10 2016 03:40
gravesmeister sends brownie points to @carpediem1213 :sparkles: :thumbsup: :sparkles:
:star: 219 | @carpediem1213 | http://www.freecodecamp.com/carpediem1213
Thom
@GABAB6
Feb 10 2016 03:41
And again my code doesn't paste in the correct format... smh
Aaron Graves
@gravesmeister
Feb 10 2016 03:41
Got it
I guess I understand it better than I thought
azat55
@azat55
Feb 10 2016 03:44
/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

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
get stuck here, can someone navigate me, whether I need to do if\else or switch
Thom
@GABAB6
Feb 10 2016 03:44
// Setup
function phoneticLookup(val) {
  var result = "";

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

    "bravo":"Boston",

    "charlie":"Chicago",

    "delta":"Denver",

    "echo":"Easy",

    "foxtrot":"Frank",
  };

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

// Change this value to test
phoneticLookup("charlie");
I'm stuck on this one.
Norman Dela Cruz
@dcnr
Feb 10 2016 03:47
@GABAB6 yes you can look up values through your "table" couple of ways! Here more shameless plug You want to use the "second method of using brackets"
Tracy Mazelin
@tracymazelin
Feb 10 2016 03:47
Question - how do I access the second array when the function is written like this?
function sym(args) {
  return args;
}
sym([1, 2, 3], [5, 2, 1, 4]);
Brian
@sludge256
Feb 10 2016 03:47
@dcnr A competing wiki! :P
Matthew Baker
@matthew-baker01
Feb 10 2016 03:47

I'm stuck on Understanding Case Sensitivity in Variables if anyone could kindly help

I'm stuck on this:
// Declarations
var studlyCapVar = 10 + "camelCase";
var properCamelCase = "camelCase";
var titleCaseOver;

// Assignments
studyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;

Norman Dela Cruz
@dcnr
Feb 10 2016 03:49
@sludge256 where's the other one? maybe I should reference that instead :D
if you mean the FCC wiki, I personally have trouble reading that :(
Brian
@sludge256
Feb 10 2016 03:50
@dcnr Yours is more informative
There is a challenge guide section on the FCC wiki that could use some loving though
Norman Dela Cruz
@dcnr
Feb 10 2016 03:50
@tracymazelin you use the arguments object to access the other parameters
@sludge256 I really should look at FCC contribution guidelines, maybe I can just do it there
thanks by the way @sludge256
CamperBot
@camperbot
Feb 10 2016 03:51
dcnr sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1382 | @sludge256 | http://www.freecodecamp.com/sludge256
We are moving to a new Wiki system though
Norman Dela Cruz
@dcnr
Feb 10 2016 03:52
wiki Accessing Objects Properties with the Dot Operator
CamperBot
@camperbot
Feb 10 2016 03:52

:point_right: challenge accessing objects properties with the dot operator [wiki]

Challenge: Accessing Objects Properties with the Dot Operator

There are two ways to access the properties of an object: the dot operator (.) and bracket notation ([]), similar to an array.

The dot operator is what you use when you know the name of the property you're trying to access ahead of time.

Here is a sample of using the dot operator (.) to read an object property:

var myObj = {
  prop1: "val1",
  prop2: "val2"
};
myObj.prop1; // val1
myObj.prop2; // val2

:pencil: read more about challenge accessing objects properties with the dot operator on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 10 2016 03:53
oh it does work!
people should learn more about this feature
Brian
@sludge256
Feb 10 2016 03:53
It's basically just the instruction's example though
at least for that challenge
Norman Dela Cruz
@dcnr
Feb 10 2016 03:54
@sludge256 most of the instructions are too concise :( some people just "copy" them and think they understand that it worked
Brian
@sludge256
Feb 10 2016 03:54
@dcnr Yep I've totally noticed that
Norman Dela Cruz
@dcnr
Feb 10 2016 03:54
@sludge256 trips people up when you switch the example with the exercise, like with Profile Lookup
Brian
@sludge256
Feb 10 2016 03:54
Then they don't think about what the code is actually doing at times
They've accessed the value but they're not doing anything with it (as shown in the example)
Norman Dela Cruz
@dcnr
Feb 10 2016 03:56
@sludge256 and most of the time the new campers get the mindset that "I should do this for when I encounter this scenario" rather than "I should do this because this is what I've learned about for this scenario"
Tracy Mazelin
@tracymazelin
Feb 10 2016 03:56
@dcnr but when I try to access args[1], it gives me the second value of the first array instead of the second array. What am I missing?
Jay
@lantiwonka
Feb 10 2016 03:57
can anyone please help me point out where i might be making a mistake in the code below

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

if (value !== "" && prop !== "tracks"){

return collection[id][prop][value];
}

}

// Alter values below to test your code
update(5439, "artist", "ABBA");

suppose to add "artist" as a property with "ABBA" as a value to 5439 id
Norman Dela Cruz
@dcnr
Feb 10 2016 03:59
@tracymazelin ah the arguments object is different from args. Here's something SaintPeter wrote about and here's from my own wiki
Tracy Mazelin
@tracymazelin
Feb 10 2016 04:01
@dcnr - thank you, I'll have a read. Appreciate it!
CamperBot
@camperbot
Feb 10 2016 04:01
tracymazelin sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
Cooper Reck
@cooperreck
Feb 10 2016 04:01
```js
CamperBot
@camperbot
Feb 10 2016 04:01
:star: 570 | @dcnr | http://www.freecodecamp.com/dcnr
Cooper Reck
@cooperreck
Feb 10 2016 04:01
```js
```
Norman Dela Cruz
@dcnr
Feb 10 2016 04:02
@tracymazelin come back if you still have questions!
Cooper Reck
@cooperreck
Feb 10 2016 04:02
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      return "alpha";
      break;
    case 2:
      return "Beta";
      break;
    case 3:
      return "Gamma";
      break;
    case 4:
      return "Delta";
      break;
  }


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

// Change this value to test
myTest(1);
why isn't this being accepted?
Jay
@lantiwonka
Feb 10 2016 04:03
@cooperreck use "answer" instead of return
Norman Dela Cruz
@dcnr
Feb 10 2016 04:03
@lantiwonka collections is an array of objects, so you would have to traverse the array to find the values you are looking for
Jay
@lantiwonka
Feb 10 2016 04:04
@dcnr hmm let me go through it myself for 5 to 10 mins
il come back if i still have problems
Norman Dela Cruz
@dcnr
Feb 10 2016 04:05
man Profile Lookup is the new Seek and Destroy/Steam Roller nowadays O:
Cooper Reck
@cooperreck
Feb 10 2016 04:05
@lantiwonka ahh thank you!
CamperBot
@camperbot
Feb 10 2016 04:05
cooperreck sends brownie points to @lantiwonka :sparkles: :thumbsup: :sparkles:
:star: 218 | @lantiwonka | http://www.freecodecamp.com/lantiwonka
Tracy Mazelin
@tracymazelin
Feb 10 2016 04:10
@dcnr - your wiki was very helpful, it makes sense now and I learned something new!
Norman Dela Cruz
@dcnr
Feb 10 2016 04:11
thank you! @tracymazelin please tell me if I can improve it, if there are things still unclear
CamperBot
@camperbot
Feb 10 2016 04:11
dcnr sends brownie points to @tracymazelin :sparkles: :thumbsup: :sparkles:
:star: 324 | @tracymazelin | http://www.freecodecamp.com/tracymazelin
Kristin Anthony
@anthkris
Feb 10 2016 04:15
I've having trouble understanding the test cases for the no repeats please. According to my calculations, there should be 6 possibilities for aabb, not 8 (see here: http://advancedmathtutoring.com/permutations-with-and-without-repetition/)
Karma Tsering
@ktseringchem
Feb 10 2016 04:15
switch (val){
case value1:
answer = "alpha";
break;
case value2:
answer ="beta";
break;
case value3:
answer ="gamma";
break;
case value4:
answer = "delta";
break;
}
what is wrong with this?
I don't know how to use switch statement
Kristin Anthony
@anthkris
Feb 10 2016 04:16
@ktseringchem it's just case 1: not case value1
Karma Tsering
@ktseringchem
Feb 10 2016 04:16
oh thank you anthkris
@anthkris thank you
CamperBot
@camperbot
Feb 10 2016 04:16
ktseringchem sends brownie points to @anthkris :sparkles: :thumbsup: :sparkles:
:star: 392 | @anthkris | http://www.freecodecamp.com/anthkris
Thom
@GABAB6
Feb 10 2016 04:23
@dcnr thank you for the link, but I think I'm more confused now than ever. I've tried the examples in the 2nd bracket example, but to no avail. I'm now staring at the original code in frustration.
CamperBot
@camperbot
Feb 10 2016 04:23
gabab6 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 571 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 04:23

@anthkris Hi, if you permutate aabb you will get this

[ 'a', 'a', 'b', 'b' ]
[ 'a', 'a', 'b', 'b' ]
[ 'b', 'a', 'a', 'b' ]
[ 'a', 'b', 'a', 'b' ] x
[ 'a', 'b', 'a', 'b' ] x
[ 'b', 'a', 'a', 'b' ]
[ 'b', 'a', 'a', 'b' ]
[ 'a', 'b', 'a', 'b' ] x
[ 'a', 'b', 'a', 'b' ] x
[ 'b', 'a', 'a', 'b' ]
[ 'a', 'a', 'b', 'b' ]
[ 'a', 'a', 'b', 'b' ]
[ 'a', 'b', 'b', 'a' ] 
[ 'b', 'a', 'b', 'a' ] x
[ 'b', 'a', 'b', 'a' ] x
[ 'a', 'b', 'b', 'a' ]
[ 'b', 'b', 'a', 'a' ]
[ 'b', 'b', 'a', 'a' ]
[ 'b', 'b', 'a', 'a' ]
[ 'b', 'b', 'a', 'a' ]
[ 'a', 'b', 'b', 'a' ]
[ 'b', 'a', 'b', 'a' ] x
[ 'b', 'a', 'b', 'a' ] x
[ 'a', 'b', 'b', 'a' ]

And the ones with the x are the ones with non repeating consecutive characters, and there are only 8 of them

Kristin Anthony
@anthkris
Feb 10 2016 04:24
So I've done that, but according to the formula there are only 6 with non repeating indistinguishable objects
The problem assumes that we are counting a1 and b1 separately
That is a1a2b1b2
Norman Dela Cruz
@dcnr
Feb 10 2016 04:25
@anthkris I'm not that good with this kind of math, I don't even know if a standard permutation equation satisfies this case
Kristin Anthony
@anthkris
Feb 10 2016 04:25
Which is weird. But I guess I have to find a way around it
Norman Dela Cruz
@dcnr
Feb 10 2016 04:25
so I just brute forced it :(
Kristin Anthony
@anthkris
Feb 10 2016 04:25
Right O. Thanks @dcnr I'll give it a go
CamperBot
@camperbot
Feb 10 2016 04:25
anthkris sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 572 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 04:26
@GABAB6 ah val is your property that needs looking up so to use it you would have to do lookup[val]
Brian
@sludge256
Feb 10 2016 04:26
You could throw away any thoughts of them being letters for now
and just think of them by their index value
(might not help with your code at all but maybe in visualizing)
Although, you seem to already be aware of it
bitgrower
@bitgrower
Feb 10 2016 04:30
@dcnr -- that permutation of aabb makes no sense to me ... as how could you possibly distinguish between 1 a and another ?
EHunt13
@EHunt13
Feb 10 2016 04:32
function rot13(str) { // LBH QVQ VG!
  var myString = str;
  var finalArray = [];
  for (var i=0; i<myString.length; i++){
    if((str.charCodeAt(i)>64) && (myString.charCodeAt(i)<92)){
      finalArray.push(charCodeAt(i)+13);
    }
    else{
      finalArray.push(charCodeAt(i));
    }
  }

  return finalArray.join("");
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
can someone give me a hint with this?
bitgrower
@bitgrower
Feb 10 2016 04:34
what happens if the address flops over the end of the alphabet ?
what happens, say, if the letter is Z ?
EHunt13
@EHunt13
Feb 10 2016 04:36
ahhhh
i see what you are saying
Thom
@GABAB6
Feb 10 2016 04:36
Aha! result = lookup[val]; Thank you, @dcnr
CamperBot
@camperbot
Feb 10 2016 04:36
gabab6 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: gabab6 already gave dcnr points
Matthew Baker
@matthew-baker01
Feb 10 2016 04:36

Can someone help me with Convert Celsius to Fahrenheit
` function convert(celsius) {
// Only change code below this line

var fahrenheit = / a value/ * 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);
`

EHunt13
@EHunt13
Feb 10 2016 04:36
still, i am getting reference error : charCodeAt is not defined, so i am not sure my plan will work
@bitgrower
DJ
@qualitymanifest
Feb 10 2016 04:37
finalArray.push(charCodeAt(i)+13); you need to specify what string before the charCodeAt() @EHunt13
EHunt13
@EHunt13
Feb 10 2016 04:37
ahhhh thanks @qualitymanifest
CamperBot
@camperbot
Feb 10 2016 04:37
ehunt13 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 935 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
EHunt13
@EHunt13
Feb 10 2016 04:37
thanks @bitgrower
CamperBot
@camperbot
Feb 10 2016 04:37
ehunt13 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
EHunt13
@EHunt13
Feb 10 2016 04:37
ill keep working on it
CamperBot
@camperbot
Feb 10 2016 04:37
:star: 420 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 10 2016 04:38
@EHunt13 -- it's basically 3 big chunks that you have to do
  1. convert the character in the string to the character code
  2. do the cipher
  3. convert the un-cipher'd number back to a character code ...
do 1 step at a time :)
EHunt13
@EHunt13
Feb 10 2016 04:39
k :smile:
Norman Dela Cruz
@dcnr
Feb 10 2016 04:41
@bitgrower I don't understand either but eh what works :P
@GABAB6 awesome, you got it :D
bitgrower
@bitgrower
Feb 10 2016 04:42
lol @dcnr -- i don't know what you don't understand ...
Norman Dela Cruz
@dcnr
Feb 10 2016 04:42
@matthew-baker01 the formula for Celsius to Fahrenheit is Celsies times 9/5 + 32
@bitgrower the permutation :P
bitgrower
@bitgrower
Feb 10 2016 04:43
LOL ... okay ... kinda like that other crazy challenge we were talking about yesterday ...
when I looked at the answers to the test cases, I went ... wt????
Matthew Baker
@matthew-baker01
Feb 10 2016 04:45
@dcnr Yeah I got that but I have no clue how to add values for the Celsius...whenever I add values when I get onto the other value it deselects the first one if that makes any sense. It seems like I need all values for the Celsius at once.
bitgrower
@bitgrower
Feb 10 2016 04:45
@matthew-baker01 you just need to take the argument and put it into the equation ... :)
Matthew Baker
@matthew-baker01
Feb 10 2016 04:48
@bitgrower convert(-30) is the argument?
bitgrower
@bitgrower
Feb 10 2016 04:49
that is VERY cold!!!!
hmm ... that's interesting ... not sure if that was one of the test cases when I did that ...
Matt Gilbert
@Alquh
Feb 10 2016 04:52
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case "a":
      answer = "apple";
      break;
    case "b":
      answer = "bird";
      break;
    case "c":
      answer = "cat";
      break;
    default:
      answer = "stuff";
  }

}

// Change this value to test
myTest("a");
what am I doing wrong here?
Matthew Baker
@matthew-baker01
Feb 10 2016 04:54
@bitgrower I figured it out :) The formula was right but I was multiplying the individual numbers I had to find the farenheit readings for instead of just applying the formula to celsius in general but thanks :)
CamperBot
@camperbot
Feb 10 2016 04:54
matthew-baker01 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 421 | @bitgrower | http://www.freecodecamp.com/bitgrower
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:00
@Alquh you are not returning answer
EHunt13
@EHunt13
Feb 10 2016 05:00
function rot13(str) { // LBH QVQ VG!
  var myString = str;
  var finalArray = [];
  var finalNumber = 0;
  for (var i=0; i<myString.length; i++){
    if((myString.charCodeAt(i)>64) && (myString.charCodeAt(i)<78)){
      finalArray.push(str.charCodeAt(i)+13);
    }
    else if((myString.charCodeAt(i)>77) && (myString.charCodeAt(i)<91)){
      finalArray.push(str.charCodeAt(i)-13);
  }
    else {
      finalArray.push(str.charCodeAt(i));
    }
  }  
   finalString = finalArray.join(",");
   return String.fromCharCode(finalString);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
why doesnt this work?
its not reading finalString as a series of numbers as an argument, but it looks just like a series of numbers.....is it because the numbers are in string format?
sorry var finalNumber should be var finalString
playing around with it
budimanfix
@budimanfix
Feb 10 2016 05:02
Any one can give example for this challenge : freecodecamp.com/challenges/using-objects-for-lookups

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

// Only change code below this line

var alpha = {
  1: "Adams",

  2: "Boston",

  3: "Chicago",

  4: "Denver"

  5: "Easy",

  6: "Frank",
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:03
@budimanfix you should call "alphla", "beta".... instead of 1,2,3
sry "alpha" , "bravo" and so on
because the function is calling those in this case not 1 2 like example
budimanfix
@budimanfix
Feb 10 2016 05:06
@abhishekKumar1 thanks :+1:
CamperBot
@camperbot
Feb 10 2016 05:06
budimanfix sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 304 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Norman Dela Cruz
@dcnr
Feb 10 2016 05:07
@EHunt13 fromCharCode only accepts numbers, or comma delimited numbers
EHunt13
@EHunt13
Feb 10 2016 05:08
thanks @dcnr
CamperBot
@camperbot
Feb 10 2016 05:08
ehunt13 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 573 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 05:08
@EHunt13
String.fromCharCode(65); // "A"
String.fromCharCode(65, 66, 67); // "A", "B", "C"
Jason
@carpediem1213
Feb 10 2016 05:08
Profile Lookup is still tearing at me. Here's my "for" loop... ```js for (var i = 0; i < 4; i++)
{
if ((contacts[i].firstName !== "") && (contacts[i].firstName === prop))
{
return contacts[i].firstName[prop];
}
else if (contacts[i] !== firstName)
{
return "No such contact";
}
else if (contacts[i] !== prop)
{
return "No such property";
}
}
Norman Dela Cruz
@dcnr
Feb 10 2016 05:10
@EHunt13 since finalArrayis your array of charcodes (don't join them), and if you have no qualms about using new javascript features, you can just use String.fromCharCode(...finalArray);
EHunt13
@EHunt13
Feb 10 2016 05:10
how does the ... work?
Norman Dela Cruz
@dcnr
Feb 10 2016 05:11
@EHunt13 it's the Spread Operator and IT IS AWESOME
Ben Codrington
@bencodrington
Feb 10 2016 05:11
Hi, I was looking for some help.
I'm doing a challenge where I'm supposed to filter out falsy values such as false, null, "", etc. from a list.
I'm using arr.filter(), and my code works just fine, except when the array contains NaN in which case instead of removing it, it replaces it with [null]... super frustrating :p
EHunt13
@EHunt13
Feb 10 2016 05:11
sweet thanks!
Niraj Warade
@nirajw11
Feb 10 2016 05:13
@bencodrington use Boolean
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:13
@bencodrington i had same problem i used one more if statement and wrote if the array is null return an empty array arr1 which i have declared earlier in the program :smile:
Ben Codrington
@bencodrington
Feb 10 2016 05:13
sorry, where would I use that?
I assume you're reffering to the function
EHunt13
@EHunt13
Feb 10 2016 05:13
@dncr spread operator doesnt work on ES6
Ben Codrington
@bencodrington
Feb 10 2016 05:13
huh, thanks abhishek, I'll give it a try
@nirajw11 did you mean Boolean(isFalsy)? where isFalsy() is my callback function
@abhishekKumar1 didn't work unfortunately, still returning [null] :/
Niraj Warade
@nirajw11
Feb 10 2016 05:16
@bencodrington put Boolean in filter
Norman Dela Cruz
@dcnr
Feb 10 2016 05:16
@carpediem1213 your for loop goes through each of your object one by one right? and it applies the conditions per object, but if your function is called, say lookup("Sherlock", "likes") your loop will first start at "Akira"'s object. But since "Sherlock" !== "Akira", it will go in your else if (contacts[i] !== firstName), thus ending the loop and your function with a return No such contact. Even though "Sherlock" is a valid contact, he's just later than "Akira", the for loop never reaches him
Niraj Warade
@nirajw11
Feb 10 2016 05:17
Boolean considers NAN,null,"",false,undefined as false .so they will be removed
@bencodrington
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:17
@bencodrington use the if statment just before returning the array and it should be if(!arr)
abraxas3112
@abraxas3112
Feb 10 2016 05:17
hello! how are you guys?? i need help with convert celsius to fahrenheit. I can get the right answer, but i don't know how to leave the multiple results on the tasks
Ben Codrington
@bencodrington
Feb 10 2016 05:17
WOW thanks so much @nirajw11
CamperBot
@camperbot
Feb 10 2016 05:17
bencodrington sends brownie points to @nirajw11 :sparkles: :thumbsup: :sparkles:
:star: 266 | @nirajw11 | http://www.freecodecamp.com/nirajw11
Norman Dela Cruz
@dcnr
Feb 10 2016 05:17
@EHunt13 spread is an ES6 feature, so you need a more modern browser. and some won't support it at all
Ben Codrington
@bencodrington
Feb 10 2016 05:17
problem solved
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:18
@abraxas3112 use a for loop and pass it multiple times
Ben Codrington
@bencodrington
Feb 10 2016 05:18
@abhishekKumar1 I think it was pretty much the same solution, so thanks for that too
CamperBot
@camperbot
Feb 10 2016 05:18
bencodrington sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 305 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
EHunt13
@EHunt13
Feb 10 2016 05:18
@ dncr ok thanks! I will try looping through the array, pushing the letters individually and joining
Norman Dela Cruz
@dcnr
Feb 10 2016 05:18
@EHunt13 yeah that's the alternative :P
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:18
@bencodrington u r welcome
EHunt13
@EHunt13
Feb 10 2016 05:19
thanks @dcnr
CamperBot
@camperbot
Feb 10 2016 05:19
ehunt13 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: ehunt13 already gave dcnr points
Norman Dela Cruz
@dcnr
Feb 10 2016 05:19
@EHunt13 rather than make a new for loop, why not convert from char code, BEFORE you push into finalArray?
@EHunt13 that way, you can modify the charcode with +13/-13, then convert it back to character, then push in the array
then just join your array in the end
Jason
@carpediem1213
Feb 10 2016 05:20
@dcnr Why would Sherlock and Akira be compared? I thought I wrote if firstName !== "". Do you by chance have that psuedocode that you posted earlier?
Norman Dela Cruz
@dcnr
Feb 10 2016 05:22
@EHunt13 you can even forgo with the array and just append to some empty string! turn finalArray to finalString = "" and in your for loop do something like finalString += String.fromCharCode(charcode convert and +13 or -13 here);
Bryce Turner
@AbryceT
Feb 10 2016 05:22
Hey everyone, a little help on the Testing Objects for Properties. Not sure what I am doing wrong
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("gift");
  myObj.hasOwnProperty("pet");
  myObj.hasOwnProperty("bed");
  if (checkProp == 'true') {
    return myObj.checProp(val);
}else if (checkProp == 'false') {
    return "Not Found";
}
  }
// Test your code by modifying these values
checkObj("bed");
EHunt13
@EHunt13
Feb 10 2016 05:24
haha thanks @dncr I'll try to get a grasp on all that
CamperBot
@camperbot
Feb 10 2016 05:24
ehunt13 sends brownie points to @dncr :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for dncr
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:24
@AbryceT instead of writing
myObj.hasOwnProperty("gift");
myObj.hasOwnProperty("pet");
myObj.hasOwnProperty("bed");
try writing myObj.hasOwnProperty(checkProp)
and use a boolean to equate it
Bryce Turner
@AbryceT
Feb 10 2016 05:25
@abhishekKumar1 I'll try that...let me see
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:25
then check the boolean
Norman Dela Cruz
@dcnr
Feb 10 2016 05:28
@carpediem1213 I totally misread your code sorry, the problem is with how you access the objects
Jay
@lantiwonka
Feb 10 2016 05:28
thanks @dcnr for the tip earlier to to traverse the array to find the values. Solved the record collection problem.
CamperBot
@camperbot
Feb 10 2016 05:28
lantiwonka sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 574 | @dcnr | http://www.freecodecamp.com/dcnr
Niraj Warade
@nirajw11
Feb 10 2016 05:28
@abhishekKumar1 use myObj.hasOwnProperty(checkProp) != -1 for checking if the property is not present in object
Norman Dela Cruz
@dcnr
Feb 10 2016 05:28
@carpediem1213 first of all (contacts[i].firstName === prop)) prop should be firstName
Niraj Warade
@nirajw11
Feb 10 2016 05:29
@AbryceT use myObj.hasOwnProperty(checkProp) != -1 for checking if the property is not present in object
Norman Dela Cruz
@dcnr
Feb 10 2016 05:29
@carpediem1213 contacts[i].firstName[prop] does not exists, you are asking for a [prop] in firstName but firstName is a string
n9exorcist
@n9exorcist
Feb 10 2016 05:30

I have problem with "comparisons with the logical or operator" function myTest(val) {
// Only change code below this line

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

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

// Change this value to test
myTest(5);
myTest(15);

Jason
@carpediem1213
Feb 10 2016 05:30
@dcnr so prop != value of firstName?
Norman Dela Cruz
@dcnr
Feb 10 2016 05:30
@carpediem1213 else if (contacts[i] !== firstName) contacts[i] is the whole object, you can't compare it with firstName too
n9exorcist
@n9exorcist
Feb 10 2016 05:30
I m getting error in "myTest(10) should return "Inside"
myTest(15) should return "Inside"
myTest(19) should return "Inside"
myTest(20) should return "Inside""
Norman Dela Cruz
@dcnr
Feb 10 2016 05:30
great! :D thanks too @lantiwonka
CamperBot
@camperbot
Feb 10 2016 05:30
dcnr sends brownie points to @lantiwonka :sparkles: :thumbsup: :sparkles:
:star: 219 | @lantiwonka | http://www.freecodecamp.com/lantiwonka
Samuel Gonçalves Petroline
@Vlocks
Feb 10 2016 05:31
Hey guys, I've been trying to retrieve the second tree from the variable myPlants, but every time I got this error: "TypeError: Cannot read property '1' of undefined" Does anyone knows how to fix it?
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees.[1] ; // Change this line
Jason
@carpediem1213
Feb 10 2016 05:31
@dcnr ah yes, I see where the else if is wrong
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:31
@n9exorcist your code is write what was the ptoblem?
Norman Dela Cruz
@dcnr
Feb 10 2016 05:31
@carpediem1213 I think it was @rphares that posted for the pseudocode from earlier
bitgrower
@bitgrower
Feb 10 2016 05:31
@Vlocks -- it's an array of objects
so first you have to index into the array ... :)
n9exorcist
@n9exorcist
Feb 10 2016 05:32
@abhishekKumar1 I cldn't get executed with these lines" myTest(10) should return "Inside"
myTest(15) should return "Inside"
myTest(19) should return "Inside"
myTest(20) should return "Inside"
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:32
@Vlocks your last line is incorrect
Jason
@carpediem1213
Feb 10 2016 05:32
@Vlocks you'll want to access the second object in the myPlants array
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:33
then your if shoud be
if(var>=10 && var<=20)
@n9exorcist
Norman Dela Cruz
@dcnr
Feb 10 2016 05:33
@Vlocks myPlants is an array, note the [ that starts the definition. So you would have access it first like an array myPlants[index here].propertyname
Samuel Gonçalves Petroline
@Vlocks
Feb 10 2016 05:34
Oh, thank you guys, I got it. Sorry for the bothering
n9exorcist
@n9exorcist
Feb 10 2016 05:34
@abhishekKumar1 but in this challenge, I am supposed to use "logical or operator (||)"
Samuel Gonçalves Petroline
@Vlocks
Feb 10 2016 05:34
@dcnr thank you
CamperBot
@camperbot
Feb 10 2016 05:34
vlocks sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
Norman Dela Cruz
@dcnr
Feb 10 2016 05:34
@Vlocks don't be sorry :P
CamperBot
@camperbot
Feb 10 2016 05:34
:star: 575 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 05:34
and thank you too @Vlocks
CamperBot
@camperbot
Feb 10 2016 05:34
dcnr sends brownie points to @vlocks :sparkles: :thumbsup: :sparkles:
:star: 8 | @vlocks | http://www.freecodecamp.com/vlocks
bitgrower
@bitgrower
Feb 10 2016 05:34
sheesh ... I get no respect ... :(
Olawale Akinseye
@brainyfarm
Feb 10 2016 05:35
Be sorry for being a programmer :P
Jason
@carpediem1213
Feb 10 2016 05:35
@dcnr so I understand that contacts[i] is the object. Does contacts[i][prop] access the value of the property then?
Norman Dela Cruz
@dcnr
Feb 10 2016 05:35
@bitgrower who hurt you?! let's pwn him/her!
Niraj Warade
@nirajw11
Feb 10 2016 05:35
@AbryceT use myObj.hasOwnProperty(checkProp) != = undefined for checking if the property is not present in object
Olawale Akinseye
@brainyfarm
Feb 10 2016 05:35
Hello BitGrower
bitgrower
@bitgrower
Feb 10 2016 05:35
I told @vlocks it was an array of objects earlier ... :( sniff!!! Don't mind me ... git is making me over-emotional ... LOL
hi @brainyfarm
Olawale Akinseye
@brainyfarm
Feb 10 2016 05:36
Lol
Norman Dela Cruz
@dcnr
Feb 10 2016 05:36
@nirajw11 @AbryceT hasOwnProperty returns true or false so it will always be unequal to undefined :P
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:36
@n9exorcist but should use and operator
Norman Dela Cruz
@dcnr
Feb 10 2016 05:36
thanks @bitgrower there! :D
CamperBot
@camperbot
Feb 10 2016 05:36
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 423 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 10 2016 05:37
convos get so fast, and when people post code it pushes everything up, especially unformatted ones :( so many chat gets lost
bitgrower
@bitgrower
Feb 10 2016 05:37
awwww, tanks, @dcnr
CamperBot
@camperbot
Feb 10 2016 05:37
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 576 | @dcnr | http://www.freecodecamp.com/dcnr
n9exorcist
@n9exorcist
Feb 10 2016 05:37
@abhishekKumar1
You should use the || operator once
You should only have one if statement
myTest(0) should return "Outside"
myTest(9) should return "Outside"
myTest(10) should return "Inside"
myTest(15) should return "Inside"
myTest(19) should return "Inside"
myTest(20) should return "Inside"
myTest(21) should return "Outside"
myTest(25) should return "Outside"
Jason
@carpediem1213
Feb 10 2016 05:37
how does one post formatted code?
I tried typing```js
n9exorcist
@n9exorcist
Feb 10 2016 05:38
thats the error, I have now after using and opertor
Norman Dela Cruz
@dcnr
Feb 10 2016 05:38

@carpediem1213
```js

<paste here>
```

the backticks should be on their own line

@carpediem1213 shift+enter to go to the next line
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:38
oh i get it @n9exorcist if(var<10 || var>20) return "outside";
Norman Dela Cruz
@dcnr
Feb 10 2016 05:38
@carpediem1213 ```js (shift+enter) (paste code) (shift+enter) ```
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:38
else return "inside"
Norman Dela Cruz
@dcnr
Feb 10 2016 05:39
anyway I have to go everyone thank you all!
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:39
@n9exorcist your problem solved?
Norman Dela Cruz
@dcnr
Feb 10 2016 05:39
@carpediem1213 good luck on your solution :D I'm sure @bitgrower can help you :+1:
bitgrower
@bitgrower
Feb 10 2016 05:40
g'night @dcnr
Norman Dela Cruz
@dcnr
Feb 10 2016 05:40
@bitgrower g'night!
bitgrower
@bitgrower
Feb 10 2016 05:40
awwww ... thanks, @dcnr
CamperBot
@camperbot
Feb 10 2016 05:40
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave dcnr points
Bryce Turner
@AbryceT
Feb 10 2016 05:41
@nirajw11 myObj.hasOwnProperty(checkProp) !=-1 gives me an error on it's own...
n9exorcist
@n9exorcist
Feb 10 2016 05:41
@abhishekKumar1 Thank you. I have solved the problem, it was bit tricky with the instructions step. By changing the <,> signs, I got the output.
CamperBot
@camperbot
Feb 10 2016 05:41
n9exorcist sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 306 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 05:41
@n9exorcist u r welcome
bitgrower
@bitgrower
Feb 10 2016 05:41

@carpediem1213

type
```js <--- ending at the s -- on one line, the rest of this is just comment
then paste your code in
then, on a separate line, type 3 backticks again, followed by shift enter

Jason
@carpediem1213
Feb 10 2016 05:43
function lookUp(firstName, prop)
{
// Only change code below this line
  for (var i = 0; i < 4; i++) 
  {
      if ((contacts[i].firstName !== "")  && (contacts[i].firstName === prop)) 
      {
      return contacts[i][prop];
      }
      else if (contacts[i][prop] !== firstName)
      {
      return "No such contact"; 
      }
      else if (contacts[i][prop] !== prop)
      {
      return "No such property";
      }
  }
Sweet! I don't think I'm accessing the objects correctly in Profile Lookup.
but at least I can cut and paste code correctly now
bitgrower
@bitgrower
Feb 10 2016 05:44
LOL ... the trick to this problem is breaking down, clearly, each of the different things you need to return, and when to return them ... the first 2 are easy ... the 3rd one is what trips people up
but I'd have to look at my solution for the right addressing ...

I think some of yours is right, and some not ...

are you using console.log to print out intermediate values?

Jason
@carpediem1213
Feb 10 2016 05:49
@bitgrower I think I should try that
bitgrower
@bitgrower
Feb 10 2016 05:50
yeah, it will help ...
Jason
@carpediem1213
Feb 10 2016 05:50
contacts[i][prop] doesn't appear to print anything
bitgrower
@bitgrower
Feb 10 2016 05:51
they've added a section of video tutorials on chrome dev tools ... they don't go in depth on each one ... but there are tutorials out there that do .. chrome dev tools are HUGE ...
I need to spend some time learning more about them ...
lpix
@lpix
Feb 10 2016 05:51
@carpediem1213 I had trouble with this one too
2 Hints: 1) Use .hasOwnProperty and 2) it's better to use a while loop because there is no guarantee your contacts will be exactly of length 4 ( use i<contact.length)
bitgrower
@bitgrower
Feb 10 2016 05:53
did I miss his hard-coding numbers ?!? shame on me ...
Jason
@carpediem1213
Feb 10 2016 05:54
console.log(contacts[i].firstName);
am i printing this correctly?
bitgrower
@bitgrower
Feb 10 2016 05:55
I don't think I used dot notation on this one ...
Jason
@carpediem1213
Feb 10 2016 05:55
contacts[i][prop]?
bitgrower
@bitgrower
Feb 10 2016 05:56
hang on, let me look ...
Jason
@carpediem1213
Feb 10 2016 05:56
I do not see anything print to console, unfortunately. Even if I put it right before returning "No such contact"
bitgrower
@bitgrower
Feb 10 2016 05:56
console.log(variablename); will print out to the console
Jason
@carpediem1213
Feb 10 2016 05:56
wiki .hasOwnProperty
CamperBot
@camperbot
Feb 10 2016 05:56
no wiki entry for: hasownproperty
bitgrower
@bitgrower
Feb 10 2016 05:57
try Mozilla Developer Network @carpediem1213
and case matters ... hasOwnProperty ... maybe not to google, but it does to js ...
Niraj Warade
@nirajw11
Feb 10 2016 06:00
@AbryceT @dcnr is right . hasOwnProperty will either return true or false
Bryce Turner
@AbryceT
Feb 10 2016 06:02
@nirajw11 @dcnr Ok...so I have the Boolean true working but am still doing some thing wrong with false
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

  }
// Test your code by modifying these values
checkObj("house");
Niraj Warade
@nirajw11
Feb 10 2016 06:02
@AbryceT if for a object you want to check if property is present or not then I think myObj.checkprop=='undefined' will do
Jason
@carpediem1213
Feb 10 2016 06:03
@bitgrower @lpix "The function should check if firstName is an actual contact's firstName." How do I do this? I thought I'd just check to see if it had an empty value with contacts[i].firstName !== ""
bitgrower
@bitgrower
Feb 10 2016 06:05
well ... this whole challenge is centered around how to find the most relevant piece of information most efficiently ...
lpix
@lpix
Feb 10 2016 06:05
@carpediem1213 check the entire list of contacts by comparing it to all available
@carpediem1213 that's how I did it
bitgrower
@bitgrower
Feb 10 2016 06:05
This message was deleted
This message was deleted
ugh ... my brain is fried ..
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 06:06
@AbryceT use the if operator on myObj.hasOwnProperty(checkProp)
lpix
@lpix
Feb 10 2016 06:07
I'm sure there are many ways to go about this problem @bitgrower I tried many myself but the modules are about while and for loops, so we are stuck with that
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 06:07
your code is wrong now because it will always pass since checkProp has a value
Niraj Warade
@nirajw11
Feb 10 2016 06:07
@AbryceT myObj.hasOwnProperty(checkProp) just put this in if condition
bitgrower
@bitgrower
Feb 10 2016 06:09
lol @lpix -- there are efficient ways of deciding, within the loops -- what I am referring to is looking at things from more of a figure ground perspective ... what's the figure, what's the ground,, and can i solve the problem more efficiently by checking for something to be true, or checking for something to not be true ...
sometimes it can make a huge difference in how you view the problem ...
I didn't solve the problem outside of using a for loop ...
basically
Niraj Warade
@nirajw11
Feb 10 2016 06:10
@AbryceT or put (myObj[checkProp]!==undefined) in if condition
Bryce Turner
@AbryceT
Feb 10 2016 06:10
@nirajw11 @abhishekKumar1 You guys are kings!
@nirajw11 Thanks!
CamperBot
@camperbot
Feb 10 2016 06:10
abrycet sends brownie points to @nirajw11 :sparkles: :thumbsup: :sparkles:
:star: 267 | @nirajw11 | http://www.freecodecamp.com/nirajw11
Bryce Turner
@AbryceT
Feb 10 2016 06:10
@abhishekKumar1 Thanks
CamperBot
@camperbot
Feb 10 2016 06:10
abrycet sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 307 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
lpix
@lpix
Feb 10 2016 06:11
@bitgrower :+1:
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 06:11
@AbryceT you r welcome
Niraj Warade
@nirajw11
Feb 10 2016 06:11
@AbryceT wc
lpix
@lpix
Feb 10 2016 06:11
how do you give brownie points?
rphares
@rphares
Feb 10 2016 06:11
explain brownie
CamperBot
@camperbot
Feb 10 2016 06:11

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

bitgrower
@bitgrower
Feb 10 2016 06:11
thanks tax thx
lpix
@lpix
Feb 10 2016 06:12
thanks @bitgrower
bitgrower
@bitgrower
Feb 10 2016 06:12
tanks
CamperBot
@camperbot
Feb 10 2016 06:12
lpix sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 425 | @bitgrower | http://www.freecodecamp.com/bitgrower
lpix
@lpix
Feb 10 2016 06:12
yey!
bitgrower
@bitgrower
Feb 10 2016 06:12
:)
Niraj Warade
@nirajw11
Feb 10 2016 06:12
@lphix put thanks besides name
CamperBot
@camperbot
Feb 10 2016 06:12
nirajw11 sends brownie points to @lphix :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 10 2016 06:12
thanks @lpix
CamperBot
@camperbot
Feb 10 2016 06:12
bitgrower sends brownie points to @lpix :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for lphix
bitgrower
@bitgrower
Feb 10 2016 06:12
sheesh
CamperBot
@camperbot
Feb 10 2016 06:12
:star: 230 | @lpix | http://www.freecodecamp.com/lpix
bitgrower
@bitgrower
Feb 10 2016 06:12
thanks @lpix
CamperBot
@camperbot
Feb 10 2016 06:12
bitgrower sends brownie points to @lpix :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave lpix points
I'm just stuck tho
lpix
@lpix
Feb 10 2016 06:13
hehe :)
rphares
@rphares
Feb 10 2016 06:13
okay-- good table, now we need to use it, @sikthought
bitgrower
@bitgrower
Feb 10 2016 06:13
@sikthought ... read the example they show -- and do likewise ... that example is practically a giveaway ...
rphares
@rphares
Feb 10 2016 06:13
two steps-- building the part that looks up val and thinking about the return,
check out the example not he left, like @bitgrower said...
their table is named var alpha and they want 2, so they write alpha[2]
youir table is named var lookup and you want val, so you can write...?
@sikthought
Markus Kiili
@Masd925
Feb 10 2016 06:16
@nirajw11 obj.prop===undefined does not check the existence of the property, because a property can exist and have value undefined.
Corey Gilmore
@sikthought
Feb 10 2016 06:16
lookup[val];
?
rphares
@rphares
Feb 10 2016 06:17
cool
V Arun Kumar
@arunvkumr
Feb 10 2016 06:17
@sikthought ya that's right :smile:
rphares
@rphares
Feb 10 2016 06:17
so next, we just need to relate that to the return...
you are gonna return result, right? (its below the do not change line)
so.... you probably want to put that nice lookup[val] you made in result before you return it...
Vantrav
@vantrav
Feb 10 2016 06:18
does >= have lower preecedence as compared to &&?
what will javascript engine pick to do first?
or does it even matter while comparing?
bitgrower
@bitgrower
Feb 10 2016 06:19
btw @rphares -- I discovered the examples are not always on the left hand side ... only if your monitor & browser window is wide enough ... otherwise things are shown going down the page ...
help precedence
CamperBot
@camperbot
Feb 10 2016 06:19
no wiki entry for: precedence
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 06:19
@vantrav i don't think it should matter
rphares
@rphares
Feb 10 2016 06:19
ahhh-- thank you, @bitgrower , i should have thought about that!!
CamperBot
@camperbot
Feb 10 2016 06:19
rphares sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 426 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 10 2016 06:19
okay ... well ... the answer should be in the Mozilla Developer Network pages ...
LOL, yah, @rphares -- I didn't realize it until one day my left side bar had disappeared ... and i was not a (no pun intended) a happy camper ...
would be nice if you did help precedence and it took you to the appropriate mdn page ...
Markus Kiili
@Masd925
Feb 10 2016 06:21
@vantrav >= has higher precedence than &&.
bitgrower
@bitgrower
Feb 10 2016 06:21
...was also true, btw, for the MDN network ...
(no sidebars)
help arrays
CamperBot
@camperbot
Feb 10 2016 06:21

:point_right: algorithm diff two arrays [wiki]

Explanation:

Check two arrays and return a new array that contains only the items that are not in either of the original arrays.

:pencil: read more about algorithm diff two arrays on the FCC Wiki

bitgrower
@bitgrower
Feb 10 2016 06:22
hmm ... okay ... I could dream ...
rahulcode22
@rahulcode22
Feb 10 2016 06:23

'<var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

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

};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear();
myBike.setGear(1);

'

What's wrong with this code??
Vantrav
@vantrav
Feb 10 2016 06:23
@abhishekKumar1 @Masd925 thanks
CamperBot
@camperbot
Feb 10 2016 06:23
vantrav sends brownie points to @abhishekkumar1 and @masd925 :sparkles: :thumbsup: :sparkles:
:star: 955 | @masd925 | http://www.freecodecamp.com/masd925
:star: 308 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
rphares
@rphares
Feb 10 2016 06:23
@sikthought , you good now?
Abhishek Kumar
@abhishekKumar1
Feb 10 2016 06:24
@rahulcode22 help post code
Corey Gilmore
@sikthought
Feb 10 2016 06:24
@rphares — I'm sorry I'm out of it this evening. I'm having trouble processing what you said, "you probably want to put that nice lookup[val] you made in result before you return it"
rphares
@rphares
Feb 10 2016 06:24
@rahulcode22 , for setGear, you dont want to return anything,
oh, sorry, that was super casually said,
the thing you want in the end is lookup[val]
but, you are returning result,
which is currently set to result = " "
so, under the table...
bitgrower
@bitgrower
Feb 10 2016 06:26
@sikthought -- did you solve the problem ?
rphares
@rphares
Feb 10 2016 06:26
you should probably put what you want in result (before you return result)
because right now, the lookup[val] just sits there. you haven't put it in result, so it isn't being returned....
cannelflow
@cannelflow
Feb 10 2016 06:26
any helps me understand this
function print(stuff){
    console.log(stuff);
}
function mainFunction(anotherfunction,value){
    anotherfunction(value);
}
mainFunction(print,"Hello");
bitgrower
@bitgrower
Feb 10 2016 06:27
arguments optional, @cannelflow ?
bitgrower
@bitgrower
Feb 10 2016 06:28
basically, if you want to know what the "topic" is, @cannelflow -- it's called "closures"
rphares
@rphares
Feb 10 2016 06:28
( @sikthought , if that still isn't clear. At the top, they set result = " ". You need to reset it with result = *theThingYouWantToReturn* :blush: )
Niraj Warade
@nirajw11
Feb 10 2016 06:28
@Masd925 you are right if a property is defined as undefined then (myObj[checkProp]!==undefined) won't work because then that will not give the value of property as undefined.
hasOwnProperty is the right way then.
Thanks @Masd925
CamperBot
@camperbot
Feb 10 2016 06:28
nirajw11 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 956 | @masd925 | http://www.freecodecamp.com/masd925
bitgrower
@bitgrower
Feb 10 2016 06:29
what's happening is -- it's like there's a stack of values that mainFunction puts, well, on the stack ...
bitgrower
@bitgrower
Feb 10 2016 06:30
actually I take that back -- it isn't about closures ... it's about passing a function as an argument ...
rahulcode22
@rahulcode22
Feb 10 2016 06:30
Sorry,i am not getting you ...@rphares
cannelflow
@cannelflow
Feb 10 2016 06:31
@bitgrower yes can you help me understand it
bitgrower
@bitgrower
Feb 10 2016 06:32
so @cannelflow -- the call to mainfunction passes a function as an argument, and a string ... mainfunction then calls the function passed to it with the 2nd argument ...
Niraj Warade
@nirajw11
Feb 10 2016 06:32
@cannelflow print func and value 'hello' is passed as argument to main
main in turn calls print func to display 'hello'
rphares
@rphares
Feb 10 2016 06:32
oh, sorry-- only that first line was for you, @rahulcode22 !
got distracted--
for setGear, you dont want to return anything,
you just want to setGear,
bitgrower
@bitgrower
Feb 10 2016 06:33
this is a perfect thing to take a pencil and paper out and and see how the different variables/parameters/arguments are being instantiated with values ...
rphares
@rphares
Feb 10 2016 06:33
and you want to use something like change from the example up top, @rahulcode22
(you can choose your own, just make sure to setGear to it, not +=, just like you did with an =)
Corey Gilmore
@sikthought
Feb 10 2016 06:34
I feel like I understand 100% of what you're saying, @rphares , it's just not turning into the code I want in my head. I get it. I just can't output it…
Markus Kiili
@Masd925
Feb 10 2016 06:34
@bitgrower You are right. That is about 1st class functions, not closure.
rphares
@rphares
Feb 10 2016 06:34
@sikthought , you have 75% of it done--
Corey Gilmore
@sikthought
Feb 10 2016 06:34
perhaps trying this after such a long day at work isn't a good idea
rphares
@rphares
Feb 10 2016 06:34
can you paste your new code, with the lookup[val] included?
Corey Gilmore
@sikthought
Feb 10 2016 06:35
It's so jacked now, lol…
bitgrower
@bitgrower
Feb 10 2016 06:35
hmmm ... i thought 1st class functions were a topic under closures ... oh well ... passing around functions as parameters is old hat to c programmers ...
rphares
@rphares
Feb 10 2016 06:36
nope-- really close
so, lets look at it too ways...
right now, what are you returning when you run that, @sikthought ?
bitgrower
@bitgrower
Feb 10 2016 06:36
what is that lookup[val]; sitting there in your code doin' for ya ?
Corey Gilmore
@sikthought
Feb 10 2016 06:36
Nothing. There's nothing coming back
rphares
@rphares
Feb 10 2016 06:36
(oh-- delete that line below the 'do not change line)
the var result = "alpha"; line, we dont need, BUT, its the right idea
yes--
bitgrower
@bitgrower
Feb 10 2016 06:37
well ... how do you think you might be able to send it back to the calling function ...
rphares
@rphares
Feb 10 2016 06:37
you told it to return result, right?
bitgrower
@bitgrower
Feb 10 2016 06:37
right now that lookup[val]; does NUTHIN for ya ...
Corey Gilmore
@sikthought
Feb 10 2016 06:37
correct
bitgrower
@bitgrower
Feb 10 2016 06:37
except take up space ...
rphares
@rphares
Feb 10 2016 06:37
in your function, what does result=?
bitgrower
@bitgrower
Feb 10 2016 06:38
all those cpu cycles going to waste ...
Corey Gilmore
@sikthought
Feb 10 2016 06:38
right now, nothing, ""
bitgrower
@bitgrower
Feb 10 2016 06:38
:)
rphares
@rphares
Feb 10 2016 06:38
yes,
so, under the table,
lets change that
bitgrower
@bitgrower
Feb 10 2016 06:38
so ... put it to work!
rphares
@rphares
Feb 10 2016 06:38
you know you want lookup[val]
Jason
@carpediem1213
Feb 10 2016 06:38
@bitgrower I got it!
@bitgrower @lpix thanks a ton
CamperBot
@camperbot
Feb 10 2016 06:38
carpediem1213 sends brownie points to @bitgrower and @lpix :sparkles: :thumbsup: :sparkles:
:star: 427 | @bitgrower | http://www.freecodecamp.com/bitgrower
rphares
@rphares
Feb 10 2016 06:38
and you are going to return result
CamperBot
@camperbot
Feb 10 2016 06:38
:star: 240 | @lpix | http://www.freecodecamp.com/lpix
Corey Gilmore
@sikthought
Feb 10 2016 06:39
result = lookup[val]
rphares
@rphares
Feb 10 2016 06:39
yay!!!
Corey Gilmore
@sikthought
Feb 10 2016 06:39
son of a …
rphares
@rphares
Feb 10 2016 06:39
:blush: heh, super common.
bitgrower
@bitgrower
Feb 10 2016 06:39
thanks @rphares
CamperBot
@camperbot
Feb 10 2016 06:39
bitgrower sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2622 | @rphares | http://www.freecodecamp.com/rphares
bitgrower
@bitgrower
Feb 10 2016 06:40
yes ... super common problem with that challenge ...
rphares
@rphares
Feb 10 2016 06:40
thanks, @bitgrower :)
CamperBot
@camperbot
Feb 10 2016 06:40
rphares sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: rphares already gave bitgrower points
Corey Gilmore
@sikthought
Feb 10 2016 06:40
ugh!
super thanks @rphares
CamperBot
@camperbot
Feb 10 2016 06:40
sikthought sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2623 | @rphares | http://www.freecodecamp.com/rphares
bitgrower
@bitgrower
Feb 10 2016 06:41
LOL ... don't sweat it ... it's very common to make those kinds of mistakes ... it's like training your eyes & your mind to see what kinds of mistakes we make when coding ...
so ...
for instance
watching people here, and myself ...
2 common errors ...
rahulcode22
@rahulcode22
Feb 10 2016 06:41

var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

// Only change code below this line.
var gear=4,setGear,getGear;

this.setGear = function(change)
{
setGear=change;
};
this.getGear = function(change){
return getGear =change;
};

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(1);
myBike.getGear();

bitgrower
@bitgrower
Feb 10 2016 06:41
  1. not actually using the parameters being passed
rahulcode22
@rahulcode22
Feb 10 2016 06:41
No output still @rphares
rphares
@rphares
Feb 10 2016 06:41
so close, but--
bitgrower
@bitgrower
Feb 10 2016 06:41
  1. not returning a value, or the correct value ... even though the work has been done ...
so then programmers spend a lot of time trying to fix up (break) code that's already working !!!
rphares
@rphares
Feb 10 2016 06:42
i misled you, @rahulcode22 , so sorry--
Matt
@mattbag
Feb 10 2016 06:42