These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Feb 2016
greg
@wearenotgroot
Feb 11 2016 00:03
@carpediem1213 what happend was because array and newArray came from the same origin they evaluate to true when compare and gave false result
@carpediem1213 you should have compare the original string that was not reverse versus the new one
Jason
@carpediem1213
Feb 11 2016 00:04
@wearenotgroot this was really helpful! the funny thing is when I add the underscore, less tests pass. I get all but the last one when I omit it.
palindrome("0_0 (: /-\ :) 0-0") fails
greg
@wearenotgroot
Feb 11 2016 00:04
@carpediem1213 read what i wrote^
@carpediem1213 it gave false result because you compared the same thing
@carpediem1213 instead of the original that was not reverse
Jason
@carpediem1213
Feb 11 2016 00:05
@wearenotgroot Thanks! I got it. I forgot the bracket. What exactly is going on when I type [\W_] ? I know the W is the negation of all the chars
CamperBot
@camperbot
Feb 11 2016 00:05
carpediem1213 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
Gauti
@gautamkumar94
Feb 11 2016 00:06

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

{case 1:
  case 2:
  case 3:
result="Low"; break;
  case 4:
  case 5:
  case 6:
    result="Mid"; break;
  case 7:
case 8:
  case 9:
result="High"; break;}

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

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

greg
@wearenotgroot
Feb 11 2016 00:06
@carpediem1213 it makes sure that anything inside it will be compared/match, both or either
CamperBot
@camperbot
Feb 11 2016 00:06
:star: 740 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Gauti
@gautamkumar94
Feb 11 2016 00:06
whats wrong in this
Aleksander Gębicki
@Takumar
Feb 11 2016 00:06
@gautamkumar94 you should assign values to answer variable not to "result", because you are returning this variable: return answer;
greg
@wearenotgroot
Feb 11 2016 00:08
@carpediem1213 another thing you can clean the code up by chaining method calls
Jason
@carpediem1213
Feb 11 2016 00:08
@wearenotgroot how do I do that?
Gauti
@gautamkumar94
Feb 11 2016 00:09
@Takumar how to do that
greg
@wearenotgroot
Feb 11 2016 00:09
@carpediem1213 .split('').reverse().join(''); for example
Jason
@carpediem1213
Feb 11 2016 00:09
@wearenotgroot Oh that's pretty cool
Aleksander Gębicki
@Takumar
Feb 11 2016 00:09
@gautamkumar94 answer = "Low"; break; and two other lines with "Mid" and "High"
Pavan Kulkarni
@pavankrcr
Feb 11 2016 00:11
Friends what is the best way to learn JavaScript. I seem to forget solution to challenges i solved .too many concepts . how you practice it
greg
@wearenotgroot
Feb 11 2016 00:13
@pavankrcr practice by doing and then when you grasp and completely understood something teach someone else!
@pavankrcr that way it reinforces what you know
Pavan Kulkarni
@pavankrcr
Feb 11 2016 00:15
Thanks @wearenotgroot will try this
CamperBot
@camperbot
Feb 11 2016 00:15
pavankrcr sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Feb 11 2016 00:15
@pavankrcr also revisit task and take another approach
CamperBot
@camperbot
Feb 11 2016 00:15
:star: 741 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Robert Richey
@0x0936
Feb 11 2016 00:15
@pavankrcr lots of practice - in the dev console, on codepen, local dev inv, jsbin, etc
@wearenotgroot covered it nicely :)
greg
@wearenotgroot
Feb 11 2016 00:16
@0x0936 :smile: I try
Aleksander Gębicki
@Takumar
Feb 11 2016 00:17
@gautamkumar94 is your code ready?
Gauti
@gautamkumar94
Feb 11 2016 00:20
@Takumar yes
thenku for help
:)
daiwik
@daiwik
Feb 11 2016 00:27
what is difference between Array.prototype.filter() and Array.filter()?
Norman Dela Cruz
@dcnr
Feb 11 2016 00:30
@daiwik Array.prototyperepresents the prototype for the array constructor. All array instances inherit from this. If you modify Array.prototype.filter you will also modify all instances of Array, and their usage of filter. Array.filter() means that you have a variable Array and you're using .filter() function inherited from the master race
@daiwik so if you want to add another method to ALL your arrays, you add it to Array.prototype. You should look up javascript prototypes
Matt
@mattbag
Feb 11 2016 00:33
help palindromes
CamperBot
@camperbot
Feb 11 2016 00:33

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 11 2016 00:33
@daiwik I suggest you watching this video :D
Aleksander Gębicki
@Takumar
Feb 11 2016 00:40
@gautamkumar94 your code: "thenku for help" is not working ;-)
RickWisneske
@rwisneske
Feb 11 2016 00:43
@dcnr thanks!
CamperBot
@camperbot
Feb 11 2016 00:43
rwisneske sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 584 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 11 2016 00:43
you're welcome, thanks too @rwisneske
CamperBot
@camperbot
Feb 11 2016 00:43
dcnr sends brownie points to @rwisneske :sparkles: :thumbsup: :sparkles:
:star: 215 | @rwisneske | http://www.freecodecamp.com/rwisneske
Vinícius
@vinicius978
Feb 11 2016 00:44
Hello guys, I have a doubt: When using objects for lookups the following syntax is right or I need to put a colon after "alpha" and "bravo"?
var lookup = {
1:"alpha"
        result="Adams";
2:"bravo"
       result="Boston";
}
Aleksander Gębicki
@Takumar
Feb 11 2016 00:45
@vinicius978 correct is property:value, property: value .... syntax
Vinícius
@vinicius978
Feb 11 2016 00:46
Ahh ok
Aleksander Gębicki
@Takumar
Feb 11 2016 00:46
@vinicius978 so:
var lookup = {
"alpha": "Adams",
...
Vinícius
@vinicius978
Feb 11 2016 00:46
I can't write a statement inside this object?
Chase Childers
@d00mb0x
Feb 11 2016 00:46
Just a quick question, what would be the opposite of .pop? i.e. I want to do the same thing but with the front of the array?
Aleksander Gębicki
@Takumar
Feb 11 2016 00:46
@vinicius978 not
Matt
@mattbag
Feb 11 2016 00:47
.shift?
Aleksander Gębicki
@Takumar
Feb 11 2016 00:47
@d00mb0x it is shift() method.
Vinícius
@vinicius978
Feb 11 2016 00:47
@d00mb0x try shift()
HAHAHA
Thanks for your help! @Takumar
CamperBot
@camperbot
Feb 11 2016 00:47
vinicius978 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
Chase Childers
@d00mb0x
Feb 11 2016 00:47
Why was I trying unshift.. I'm so silly haha thanks everyone
CamperBot
@camperbot
Feb 11 2016 00:47
:star: 2276 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Feb 11 2016 00:47
@vinicius978 you are welcome :-)
Matt
@mattbag
Feb 11 2016 00:47
help find the longest word
CamperBot
@camperbot
Feb 11 2016 00:47

:point_right: algorithm find the longest word in a string [wiki]

Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

:pencil: read more about algorithm find the longest word in a string on the FCC Wiki

Fouad Hassouneh
@fouad-hassouneh
Feb 11 2016 00:51
Hey everyone, I'm working on the Seek and Destroy example and I'm getting the right return but the example is not passing. Any ideas?
Michael Mason
@boone2016
Feb 11 2016 00:51
Thank you for the help @Takumar
CamperBot
@camperbot
Feb 11 2016 00:51
boone2016 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2277 | @takumar | http://www.freecodecamp.com/takumar
Norman Dela Cruz
@dcnr
Feb 11 2016 00:52
@fouad-hassouneh will you share your code here?
Aleksander Gębicki
@Takumar
Feb 11 2016 00:52
@boone2016 you're welcome :-)
chris1819
@chris1819
Feb 11 2016 00:53

```
// Setup
function abTest(a, b) {
// Only change code below this line
if (a || b < 0){
console.log(undefined);
} else{
return (a, 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);

```I dont know why this is not working, can anyone help??

darnit
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a || b < 0){
    console.log(undefined);
  }  else{
    return (a, 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);
Norman Dela Cruz
@dcnr
Feb 11 2016 00:54
@chris1819 your a should be tested like b too
chris1819
@chris1819
Feb 11 2016 00:54
the following is what is not working
i guess i dont understand how it's not being tested
Norman Dela Cruz
@dcnr
Feb 11 2016 00:54
@chris1819 also return (a, b); you're only returning b
Fouad Hassouneh
@fouad-hassouneh
Feb 11 2016 00:54
function destroyer(arr) {
  // Remove all the values
  for (var i = 1; i < arguments.length; i++) {
    arr = arr.filter(function(val){
      if(val !== this){
        return val;
      }
    },arguments[i]);
  }
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
this is my return: [1,1]
Norman Dela Cruz
@dcnr
Feb 11 2016 00:55
to test both a and b if they're both less than 0, you should do if (a < 0 || b < 0)
@chris1819
chris1819
@chris1819
Feb 11 2016 00:55
@dcnr I will try that
Fouad Hassouneh
@fouad-hassouneh
Feb 11 2016 00:56
@dcnr I posted my code
Norman Dela Cruz
@dcnr
Feb 11 2016 00:57
@fouad-hassouneh oh the console to the left side is lying, you're not actually modifying filtering the array
@fouad-hassouneh also by using arguments[i] as this you're only comparing to one of the arguments, in this case 2
chris1819
@chris1819
Feb 11 2016 00:58
@dcnr (a < 0 || b < 0) did not help.
Norman Dela Cruz
@dcnr
Feb 11 2016 00:59
and this does not equal 2 too! it's actually an object
@fouad-hassouneh
@chris1819 what's the challenge name again? so I could look it up
anthonygallina1
@anthonygallina1
Feb 11 2016 00:59
thank you @sludge256
CamperBot
@camperbot
Feb 11 2016 00:59
anthonygallina1 sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
Fouad Hassouneh
@fouad-hassouneh
Feb 11 2016 00:59
@dcnr ok thanks, I'll take a look at the arguments
CamperBot
@camperbot
Feb 11 2016 00:59
fouad-hassouneh sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 1408 | @sludge256 | http://www.freecodecamp.com/sludge256
:star: 585 | @dcnr | http://www.freecodecamp.com/dcnr
chris1819
@chris1819
Feb 11 2016 01:00
@dcnr Return Early Pattern for Functions
Matt
@mattbag
Feb 11 2016 01:00
help title case
CamperBot
@camperbot
Feb 11 2016 01:00

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 11 2016 01:00
@chris1819 aah remove your else
and don't console.log
you should return

@chris1819 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.

@chris1819 you can exit the function by doing a return valueHere;
Emmanuel Sekyi
@theSekyi
Feb 11 2016 01:01
I need help on the factorization algorithm
I have seen the sample code online but I do not understand it.
Norman Dela Cruz
@dcnr
Feb 11 2016 01:04
@fouad-hassouneh Hi, if you want to stick to your code, you can actually use
Emmanuel Sekyi
@theSekyi
Feb 11 2016 01:04
Hello
Norman Dela Cruz
@dcnr
Feb 11 2016 01:04

@fouad-hassouneh

this.valueOf()

in your comparison

@fouad-hassouneh I was wrong earlier that I said you were only testing for one argument, because I didn't notice the for loop

@fouad-hassouneh but

if (val != this.valueOf())

will make your code work

clever solution IMO :D
@Socs2708 hi, I'm not that good with the math problems but put your code here anyway maybe someone can help you
Joseph
@revisualize
Feb 11 2016 01:05

Dear Ladies,

(And gentlemen)
There is a Puget Sound Programming Python (PuPPy) meetup tonight:
February Meeting at Dropbox -- Panel Discussion on Women in Software Engineering
http://www.meetup.com/PSPPython/events/228123877/
The live stream is available at:
https://www.youtube.com/watch?v=xoz8Acp40uA
Type: /collapse
Purna Kanneganti
@purnakanneganti
Feb 11 2016 01:12

var Bike = function() {

// Only change code below this line.
var gear = 1;

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

did anyone got this challenge
Norman Dela Cruz
@dcnr
Feb 11 2016 01:14
@purnakanneganti iirc setGear part should be gear = change;
because you are setting gear, not adding to it
Jeff Garrett
@jeffjg
Feb 11 2016 01:15
Thanks @Rafase282 for your help with Algorithm: Seek and Destroy
CamperBot
@camperbot
Feb 11 2016 01:15
jeffjg sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 964 | @rafase282 | http://www.freecodecamp.com/rafase282
Purna Kanneganti
@purnakanneganti
Feb 11 2016 01:16
thank you very much @dcnr
CamperBot
@camperbot
Feb 11 2016 01:16
purnakanneganti sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 586 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 11 2016 01:17
you're welcome, thanks too @purnakanneganti
CamperBot
@camperbot
Feb 11 2016 01:17
dcnr sends brownie points to @purnakanneganti :sparkles: :thumbsup: :sparkles:
:star: 238 | @purnakanneganti | http://www.freecodecamp.com/purnakanneganti
Rafael J. Rodriguez
@Rafase282
Feb 11 2016 01:17
youa re welcome @jeffjg
chris1819
@chris1819
Feb 11 2016 01:18
@dcnr thanks. That had me stumped for hours, such a seamingly simple bit of code
CamperBot
@camperbot
Feb 11 2016 01:18
chris1819 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 587 | @dcnr | http://www.freecodecamp.com/dcnr
chris1819
@chris1819
Feb 11 2016 01:19
@Rafase282 thanks. Thanks for your blog.. has helpped me alot
CamperBot
@camperbot
Feb 11 2016 01:19
chris1819 sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 965 | @rafase282 | http://www.freecodecamp.com/rafase282
Rafael J. Rodriguez
@Rafase282
Feb 11 2016 01:20
blog or github repo?
Norman Dela Cruz
@dcnr
Feb 11 2016 01:20
no prob, usually it's just semantic more than syntax errors, thanks too @chris1819
CamperBot
@camperbot
Feb 11 2016 01:20
dcnr sends brownie points to @chris1819 :sparkles: :thumbsup: :sparkles:
:star: 207 | @chris1819 | http://www.freecodecamp.com/chris1819
Jeff Garrett
@jeffjg
Feb 11 2016 01:20

Hey, I have a question. In the code below, what does the "element" argument represent? And is there anyway to show me visually step-by-step what is happening with the filter method so I can get a better understanding?

```

function destroyer(arr) {
  var destroyerArgs = Array.prototype.slice.call(arguments);
  destroyerArgs.splice(0,1);
  return arr.filter(function(element) {
    return destroyerArgs.indexOf(element) === -1;
  });

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Norman Dela Cruz
@dcnr
Feb 11 2016 01:22
@jeffjg it is the current value of arr
@jeffjg .filter takes each of the element/value of the array it's called on and applies the function
Jeff Garrett
@jeffjg
Feb 11 2016 01:23
so "element" in this case would be the [2,3]?
Chris Hinton
@hintcj
Feb 11 2016 01:23
bonfire Chunky Monkey
CamperBot
@camperbot
Feb 11 2016 01:23

:fire:Bonfire: Chunky Monkey :link:

function chunk(arr, size) {
  // Break it up.
  return arr;
}

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

Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.

more info:  bf details | bf links | hint

Chris Dalton
@manwithgills
Feb 11 2016 01:23

Can someone help me understand the syntax of the following line of code?

for (var i = 0, chr; i < str.length; i++) {...

I am very familiar with the for loop but I have never seen the chr placed inside it. Why would you do this?

Jeff Garrett
@jeffjg
Feb 11 2016 01:23
(since I spliced off the first item in the original array)
Norman Dela Cruz
@dcnr
Feb 11 2016 01:24
@jeffjg no it's not it's still [1, 2, 3, 1, 2, 3]
@jeffjg because you called .filter on arr
and since you sliced arguments, you created a new reference with destroyerArgs
and arr is left untouched
@manwithgills the for loop goes like this
for ( /* initialization here */ ; /* condition checked before every loop */ ; /* thing to do after every loop */ )
Richard Gomez
@themanager311
Feb 11 2016 01:27
Trying to multiply product by the numbers in the array but I'm not sure what I'm missing, I can only get product to return 1.
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

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

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

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);
Jeff Garrett
@jeffjg
Feb 11 2016 01:28
@dcnr ohhh ok, that makes sense so far. So It's checking through all 3 array items in arr array, and the next statement is saying if you find [2, 3] within the arr array, return false and filter it out of the arr array?
Matt
@mattbag
Feb 11 2016 01:28
help return largest numbers
CamperBot
@camperbot
Feb 11 2016 01:28

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

Explanation:

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

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

Norman Dela Cruz
@dcnr
Feb 11 2016 01:29
@manwithgills so in your case
for (var i = 0, chr; i < str.length; i++)

i = 0 // initialized i to 0
chr // initialized to undefined

i < str.length // check first if i is less than the length of str, if it is go on with the loop, stop otherwise

i++ // after each loop increment i
Chris Hinton
@hintcj
Feb 11 2016 01:29
@themanager311 you're only multiplying by the outer array. You need to access the inner array by using product *= arr[i][j];
Norman Dela Cruz
@dcnr
Feb 11 2016 01:31
@jeffjg I'm sorry I don't quite get what you mean by the 3 items in arr
Richard Gomez
@themanager311
Feb 11 2016 01:32
@hintcj I tried that as well, still returns 1.
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].lenth; j++) {
      product *= arr[i][j];
    }
  }

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

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);
Chris Dalton
@manwithgills
Feb 11 2016 01:32
@dcnr But why is the chr there? I have never seen anything beside the three sections var i=0; i<something; i++. I am confused as to why you would insert anything after the var i=0.
Chris Hinton
@hintcj
Feb 11 2016 01:33
@themanager311 if that's you're actual code, in your second for loop, length is missing the 'g'
Norman Dela Cruz
@dcnr
Feb 11 2016 01:34

@manwithgills well if you want to initialize more than one variable, that's legal :D
take this for example

for (var i = 0, chr, len = str.length; i < len; i++) {...

it's the same as the for loop you posted

Richard Gomez
@themanager311
Feb 11 2016 01:35
@hintcj been looking at it for an hour and never saw it, thanks!
CamperBot
@camperbot
Feb 11 2016 01:35
themanager311 sends brownie points to @hintcj :sparkles: :thumbsup: :sparkles:
:star: 273 | @hintcj | http://www.freecodecamp.com/hintcj
Chris Hinton
@hintcj
Feb 11 2016 01:36
@themanager311 you're welcome!
Chris Dalton
@manwithgills
Feb 11 2016 01:38
@dcnr I am going to have to read into that because I did not know you could initialize on more than one variable.
Norman Dela Cruz
@dcnr
Feb 11 2016 01:39
@manwithgills ah you're not initialized on one variable, you're initialized i and chr, and in my example, len too

@manwithgills but you can use one var

var i = 0, x = 1, y = z;

is valid, but confusing IMO

Chris Dalton
@manwithgills
Feb 11 2016 01:40
@dcnr At first but it makes sense. Not sure how it would be used at this point but its just one more area to research and learn.
Norman Dela Cruz
@dcnr
Feb 11 2016 01:41

@manwithgills I don't personally use it :P If I have to initialize multiple variables I do them separately

var i = 0;
var x = 1;
var y = z;

some people do it like

var i = 0,
    x = 1,
    y = z;

/* or */

var i = 0
  , x = 1
  , y = z;

but for a for loop you need to do the one line thing

Chris Dalton
@manwithgills
Feb 11 2016 01:42
That solves a lot of repetition.
Norman Dela Cruz
@dcnr
Feb 11 2016 01:43
@manwithgills yeah depends on coding style really. So stick to your own style, or to your team's style guidelines
Chris Dalton
@manwithgills
Feb 11 2016 01:44
Im such a noob I dont have a style...
Alex Evans
@alex-evans
Feb 11 2016 01:44
Hi, I'm working on the "Exact Change" challenge and struggling to understand how to use an Object in the solution like the Helpful Link suggests. My answer is becoming pretty ugly so I'm sure the Global Object is the way to go but can someone give me a pointer on how to use it for that challenge?
Chris Dalton
@manwithgills
Feb 11 2016 01:44
@dcnr Thanks for your help.
CamperBot
@camperbot
Feb 11 2016 01:44
manwithgills sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 588 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 11 2016 01:45
thank you too @manwithgills
CamperBot
@camperbot
Feb 11 2016 01:45
dcnr sends brownie points to @manwithgills :sparkles: :thumbsup: :sparkles:
:star: 254 | @manwithgills | http://www.freecodecamp.com/manwithgills
Omar Richardson
@omie86
Feb 11 2016 01:45
I have a noob Js question - http://screencast.com/t/PxvDaFJNJ
Jeff Garrett
@jeffjg
Feb 11 2016 01:45
help Where do I belong
CamperBot
@camperbot
Feb 11 2016 01:45

:point_right: algorithm where do i belong [wiki]

Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

:pencil: read more about algorithm where do i belong on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 11 2016 01:46

@jeffjg

Home is where the Heart is

Jeff Garrett
@jeffjg
Feb 11 2016 01:46
@dcnr ;)
Norman Dela Cruz
@dcnr
Feb 11 2016 01:46
@jeffjg :P
Alex Evans
@alex-evans
Feb 11 2016 01:48
@omie86 You're assigning 7 into b. Look again at what b is suppose to be.
Matt
@mattbag
Feb 11 2016 01:50
help confirm
CamperBot
@camperbot
Feb 11 2016 01:50

:point_right: algorithm confirm the ending [wiki]

Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the end('Bastian', 'n'); case.

:pencil: read more about algorithm confirm the ending on the FCC Wiki

Omar Richardson
@omie86
Feb 11 2016 01:50
@alcatrats Figured it out thanks
CamperBot
@camperbot
Feb 11 2016 01:50
omie86 sends brownie points to @alcatrats :sparkles: :thumbsup: :sparkles:
:star: 302 | @alcatrats | http://www.freecodecamp.com/alcatrats
Cooper Reck
@cooperreck
Feb 11 2016 02:00
// Setup
function abTest(a, b) {
  // Only change code below this line


  // 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);
can someone help me understand this exercise?
it is Return Early Pattern for Functions
bitgrower
@bitgrower
Feb 11 2016 02:01
what are you supposed to do, @cooperreck ?
Cooper Reck
@cooperreck
Feb 11 2016 02:02
@bitgrower Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
bitgrower
@bitgrower
Feb 11 2016 02:02
so.... break it down ... what are the pieces you need to do ...
  1. modify the function ... okay, that's sort of a given ... LOL
  1. if a or b is less than 0 <<<--- do you know how to express that in JS ?
Henry Wilcox
@DreadGlimpse
Feb 11 2016 02:05
Does anyone know if there is an issue with code pen that doesn't allow you to utilize the weather API in the weather zipline for frontend?
bitgrower
@bitgrower
Feb 11 2016 02:08
no ... try the helpfrontend room, @DreadGlimpse
Norman Dela Cruz
@dcnr
Feb 11 2016 02:09
hi @bitgrower :D
Henry Wilcox
@DreadGlimpse
Feb 11 2016 02:09
Thanks
Cooper Reck
@cooperreck
Feb 11 2016 02:09
if (a < 0 || b < 0)
@bitgrower
? I think
bitgrower
@bitgrower
Feb 11 2016 02:09
excellent !!!! that looks good here ...
okay ... so, stick it in an if statement ...
hi @dcnr .... another day in the FCC mines, eh ?
oops ... you already did ... excellent -- well, now all you have to do is return undefined ...
yeah ?
Norman Dela Cruz
@dcnr
Feb 11 2016 02:10
@bitgrower yeah, looking for nuggets
bitgrower
@bitgrower
Feb 11 2016 02:13
how's it going, @cooperreck ?
Tyler
@Thiggs
Feb 11 2016 02:13
Hey all!
Alex Evans
@alex-evans
Feb 11 2016 02:14
Trying this again here to see if anyone can throw me a bone as I'm starting to pull my hair out on the Exact Change challenge...
Working on the "Exact Change" challenge where you have to return the specific change in coins and bills and I believe I am approaching it incorrectly and wondering if someone could do a review of what I have. The helpful link points to Global Object but I don't follow how to best utilize that. I'm guessing that's why I'm heading down an ugly coding solution. Any help would be appreciated:
function drawer(price, cash, cid) {
  var cshDrw = {
    "PENNY": cid[0][1],
    "NICKEL": cid[1][1],
    "DIME": cid[2][1],
    "QUARTER": cid[3][1],
    "ONE": cid[4][1],
    "FIVE": cid[5][1],
    "TEN": cid[6][1],
    "TWENTY": cid[7][1],
    "HUNDRED": cid[8][1]
  };
  var change = cash - price;
  var total = cshDrw.PENNY + cshDrw.NICKEL + cshDrw.DIME + cshDrw.QUARTER + cshDrw.ONE + cshDrw.FIVE + cshDrw.TEN + cshDrw.TWENTY + cshDrw.HUNDRED;
  total = Math.round(total * 100) / 100;

  if(cshDrw.total < change) {
    return "Insufficient Funds";

  } else if(cshDrw.total == change) {
    return "Closed";

  } else {

    // ugly code that builds an array of coins and bills for the change

  }
}

drawer(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Tyler
@Thiggs
Feb 11 2016 02:14
Anyone have time to help? I'm stuck on the Seek and Destroy mission, and I just really want to know where my does is breaking so I can figure out how to fix it.
Vik
@vvang044
Feb 11 2016 02:17
hey guys
bitgrower
@bitgrower
Feb 11 2016 02:18
help exact change
CamperBot
@camperbot
Feb 11 2016 02:18

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Tyler
@Thiggs
Feb 11 2016 02:18

I tried to comment out my code to help.

```function destroyer(arr) {
var searchArr = arr[0]; //first given argument is array to be searched

for (var i = 1; i< arr.length; i++){ //For the provided destroyer items
for (var j =0; j< searchArr.length; j++){ //search the first array
if (searchArr[j] === arr[i]){ //if anything in the search array equals the current number
delete searchArr[j]; //take that number out of the search array.
}
}
}

return searchArr; //return the array
}

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

bitgrower
@bitgrower
Feb 11 2016 02:18
I can't help you -- but the wiki page may be able to ... LOL ...
Vik
@vvang044
Feb 11 2016 02:18
``` var secondTree = myPlants.trees[1];..... why isthis not working when trying to access the arrays
bitgrower
@bitgrower
Feb 11 2016 02:18
@vvang044 & @Thiggs -- CAREFULLY follow the instructions here
Tyler
@Thiggs
Feb 11 2016 02:18
oops, sorry...
bitgrower
@bitgrower
Feb 11 2016 02:18
help format
CamperBot
@camperbot
Feb 11 2016 02:18

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Matt
@mattbag
Feb 11 2016 02:19
you need to access both props
help repeat a string
CamperBot
@camperbot
Feb 11 2016 02:19

:point_right: algorithm repeat a string repeat a string [wiki]

Explanation:

The program is very simple, we have to take a variable and return that variable being repeated certain amount of times. No need to add space or anything, just keep repeating it into one single string.

:pencil: read more about algorithm repeat a string repeat a string on the FCC Wiki

Tyler
@Thiggs
Feb 11 2016 02:20
Sorry, I got the 3 ticks, but forgot the rest...
js function destroyer(arr) {
  var searchArr = arr[0]; //first given argument is array to be searched


 for (var i = 1; i< arr.length; i++){ //For the provided destroyer items
   for (var j =0; j< searchArr.length; j++){ //search the first array
     if (searchArr[j] === arr[i]){          //if anything in the search array equals the current number
       delete searchArr[j]; //take that number out of the search array.
     }
   }
 }



  return searchArr; //return the array
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
bitgrower
@bitgrower
Feb 11 2016 02:20
for seek & destroy indexOf is your friend
Cooper Reck
@cooperreck
Feb 11 2016 02:20
great, thank you! @bitgrower
CamperBot
@camperbot
Feb 11 2016 02:20
cooperreck sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 437 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 02:21
delete is not something you'll find in js ... however, Array.splice can help you ... :) Or you could use Array.filter
yw @cooperreck -- got it all figured out ?
Tyler
@Thiggs
Feb 11 2016 02:21
I had splice before! with
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:22
anyone familiar with the mutations challenge/bonfire thing?
Cooper Reck
@cooperreck
Feb 11 2016 02:22
yep! @bitgrower
Norman Dela Cruz
@dcnr
Feb 11 2016 02:22
@bitgrower JS does have a delete :P
bitgrower
@bitgrower
Feb 11 2016 02:22
awesome @cooperreck -- happy coding ...
Tyler
@Thiggs
Feb 11 2016 02:22
I think I passed (i, 1) through .splice
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:22
i think i'm getting some falsely correct returns...
bitgrower
@bitgrower
Feb 11 2016 02:22
well dang it -- color me embarrassed -- I hadn't run into it in any of the challenges ... :(
got a link for more info, @dcnr -- I don't recall coming across it at all ...
@JSDesign yes
want to post your code ?
Norman Dela Cruz
@dcnr
Feb 11 2016 02:24
@bitgrower hmmmmm ah it's in uhh I know the new challenges use them
@bitgrower I think record collection wants you to use delete
Tyler
@Thiggs
Feb 11 2016 02:24
e.g.
searchArr.splice(j, 1)
but I got the same result I got when I did
delete searchArr[j]
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:24
i'll post my code... it feels kinda wrong
function mutation(arr) {

  var first = arr.shift().toString();
  var second = arr.pop();
  var someBool;

  for (var i = 0; i < second.length; i++) {
    if (first.indexOf(second[i]) > 0) {
      someBool = true;
    } else {
      someBool = false;
    }
  }

  console.log(someBool);

  //var testStr = 'hello';
  //var testArr = ['neo'];
  //console.log(testStr.indexOf(testArr));

  return someBool;

  //return arr;
}

mutation(["hello", "hey"]);
Norman Dela Cruz
@dcnr
Feb 11 2016 02:24
@bitgrower but yeah delete, it removes object properties, sets array elements to undefined, and obliterates single variables
bitgrower
@bitgrower
Feb 11 2016 02:24
well cover me stupid ...
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:25
i know i don't need that someBool variable - that was for testing
i'm getting greens on all the tests except the last one (which i have sitting in the commented out part)
bitgrower
@bitgrower
Feb 11 2016 02:26
what makes you feel like it's wrong ?
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:27
i was thinking that looping through the array would return a true value prematurely... but idk. all the other tests that should fail do so probably not.
but i can't figure out why the last test comes out incorrect. i'm getting a true when it should be false.
Vik
@vvang044
Feb 11 2016 02:28
var secondTree = myPlants.trees1 is this wrong way to accessing nested array in JSON ?
Norman Dela Cruz
@dcnr
Feb 11 2016 02:28
@JSDesign I think with your current structure, what if the first character tested was false, and then the next one is in first, so someBool would be true, now you don't know that you had one character that failed and your loop continues
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:28
when testing in those comments though it comes out false (-1) as it should though.
Vik
@vvang044
Feb 11 2016 02:28
ops 1 after trees
cannelflow
@cannelflow
Feb 11 2016 02:28
@vvang044 which exercise ?
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:29
@dcnr ahh right
Vik
@vvang044
Feb 11 2016 02:29
accessing nested arrays in JSON
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:29
@dcnr so i need to return immediately?
Norman Dela Cruz
@dcnr
Feb 11 2016 02:29
@JSDesign if it's false, yes I think so
@JSDesign because every character must be in it right?
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:29
yeah that makes sense - i'll try it
yeah every one
Vik
@vvang044
Feb 11 2016 02:29
it says cannot read property '1' undefined
cannelflow
@cannelflow
Feb 11 2016 02:31
you need to retrieve pine
so 
var myPlants = [<-------------you starts from here which is array so myPlants[0]
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",<-----------then you have to go here which is inside array list so list[1]
      "birch"
    ]
  }  
];
bitgrower
@bitgrower
Feb 11 2016 02:31
@JSDesign -- @dcnr is right -- also what I wrote but I was having connectivity issues ...
cannelflow
@cannelflow
Feb 11 2016 02:31
@vvang044 ^
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:32
ok cool
bitgrower
@bitgrower
Feb 11 2016 02:32
I mean ... once you have a false value, you know it's not gonna turn true ... so just return false
there are a few examples in the challenges ... where if you find a condition, you can return early ... but you have to loop thru all values to make sure the condition is not found ... this example is sort of the opposite ...
Vik
@vvang044
Feb 11 2016 02:34
myplants.trees[ 1 ] <<
guessing thats not the way
bitgrower
@bitgrower
Feb 11 2016 02:37
@vvang044 --- imagine if these weren't objects ... but were just numbers in an array, how would you access them ?\
Vik
@vvang044
Feb 11 2016 02:37
starts with 0 ....and so on...
the second one will be [ 1 ]
bitgrower
@bitgrower
Feb 11 2016 02:38
okay ... so, how would you reference the first element of the array myplants ?
Tyler
@Thiggs
Feb 11 2016 02:38
I dunno, I tried using IndexOf, but this makes even less sense to me?
js function destroyer(arr) {
  var searchString = arr[0];

  for (var i=1; i<arr.length; i++){
    var indexToDelete = -1;
    indexToDelete = searchString.indexOf(arr[i]);
    if (indexToDelete !== -1){
      searchString = searchString.splice(indexToDelete, 1);
    }
  }

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
cannelflow
@cannelflow
Feb 11 2016 02:39
@vvang044 ?
Vik
@vvang044
Feb 11 2016 02:39
sorry i had to scroll up to read
bitgrower
@bitgrower
Feb 11 2016 02:39
okay, first thing to know is that arr refers to just [1,2,3,1,2,3]
Vik
@vvang044
Feb 11 2016 02:40
yeah
Jeannie Stevenson
@JSDesign
Feb 11 2016 02:40
i got it sorted! thanks a lot @dcnr and @bitgrower :)
CamperBot
@camperbot
Feb 11 2016 02:40
jsdesign sends brownie points to @dcnr and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 438 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 589 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 11 2016 02:40
so, your first statement sets searchstring to 1
Tyler
@Thiggs
Feb 11 2016 02:40
wait, really?
bitgrower
@bitgrower
Feb 11 2016 02:40
yes, really ...
Tyler
@Thiggs
Feb 11 2016 02:40
I thought that set it equal to the array at argument 1
bitgrower
@bitgrower
Feb 11 2016 02:41
nope ...
Tyler
@Thiggs
Feb 11 2016 02:41
err position 0
bitgrower
@bitgrower
Feb 11 2016 02:41
I spent hours sussing this out ... here's the secret ...
Tyler
@Thiggs
Feb 11 2016 02:41
WOW, that explains why my old code was broken!
Thanks, @bitgrower !
CamperBot
@camperbot
Feb 11 2016 02:41
thiggs sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Vik
@vvang044
Feb 11 2016 02:41
and the secret is?
CamperBot
@camperbot
Feb 11 2016 02:41
:star: 439 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 02:41
if you have one argument passed, it gets assigned to the first named variable...
if you have more variables than are named, they don't get added to the first named parameter ...
you need to find a way to get all the arguments ...
Norman Dela Cruz
@dcnr
Feb 11 2016 02:42
thanks too @JSDesign
CamperBot
@camperbot
Feb 11 2016 02:42
dcnr sends brownie points to @jsdesign :sparkles: :thumbsup: :sparkles:
:star: 261 | @jsdesign | http://www.freecodecamp.com/jsdesign
Tyler
@Thiggs
Feb 11 2016 02:42
hmmmm....
Norman Dela Cruz
@dcnr
Feb 11 2016 02:42
@bitgrower @Thiggs This is the part where I do my shameless plug
Tyler
@Thiggs
Feb 11 2016 02:42
Something to investigate!
bitgrower
@bitgrower
Feb 11 2016 02:43
hahahahahaha @dcnr ...
how can I stop rooms from notifying me ...
Vik
@vvang044
Feb 11 2016 02:43
im sorry guys i really appreciate you trying to explain....but im lost
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:43
'''
CamperBot
@camperbot
Feb 11 2016 02:43
:bulb: to format code use backticks! ``` more info
Norman Dela Cruz
@dcnr
Feb 11 2016 02:43
@bitgrower the wretched icon upper right
@bitgrower *wrench I mean
Ivan Perez
@joannesalfa
Feb 11 2016 02:44
hey guys, probably is not related to js, anyone can help me about npm lessons?
Norman Dela Cruz
@dcnr
Feb 11 2016 02:44
@bitgrower you have to set it for each room though!
@joannesalfa hi what about them?
bitgrower
@bitgrower
Feb 11 2016 02:44
yeah, just discovered that ... thanks @dcnr
CamperBot
@camperbot
Feb 11 2016 02:44
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 590 | @dcnr | http://www.freecodecamp.com/dcnr
Ivan Perez
@joannesalfa
Feb 11 2016 02:45
@dcnr can we have private chat for more comfortable? it's about im stuck with "Publish" step
rphares
@rphares
Feb 11 2016 02:45
@vvang044 , you get it now?
Vik
@vvang044
Feb 11 2016 02:46
nope....im lost
bitgrower
@bitgrower
Feb 11 2016 02:46
doesn't look like it @rphares
Norman Dela Cruz
@dcnr
Feb 11 2016 02:46
@joannesalfa hold on lemme check that lesson
bitgrower
@bitgrower
Feb 11 2016 02:46
lol ... oops
rphares
@rphares
Feb 11 2016 02:46
okeydoke-- @vvang044 , are you on the one where you try and access pine?
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:46
thanks @bitgrower i got and idea hehehe
CamperBot
@camperbot
Feb 11 2016 02:46
markjean22 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
rphares
@rphares
Feb 11 2016 02:46
(sorry, just waking up)
CamperBot
@camperbot
Feb 11 2016 02:46
:star: 440 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 11 2016 02:46
@joannesalfa I'll pm you!
Vik
@vvang044
Feb 11 2016 02:46
yes
Ivan Perez
@joannesalfa
Feb 11 2016 02:46
@dcnr ok, pm me.. cool
rphares
@rphares
Feb 11 2016 02:47
okay-- can you paste what you have so far? Just the one line is okay...
bitgrower
@bitgrower
Feb 11 2016 02:47
function(a) <- definition of the function ...
if 1 argument is passed, it will take the value of a
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:47
@vvang044 you get your answers??
bitgrower
@bitgrower
Feb 11 2016 02:47
but in js, you can pass a variable number of arguments ...
Vik
@vvang044
Feb 11 2016 02:47
``` var secondTree = myPlants.trees[1];
Reena
@annzach
Feb 11 2016 02:47
@cannelflow @cannelflow var secondTree :myPlants[1].list[1] // gives u "pine"
rphares
@rphares
Feb 11 2016 02:47
okay-- thats a good start,
we have two things... left to do..
bitgrower
@bitgrower
Feb 11 2016 02:47
but I can still define my function as having just ONE named variable ...
rphares
@rphares
Feb 11 2016 02:47
oh
cannelflow
@cannelflow
Feb 11 2016 02:48
@annzach yes
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:48
var secondTree = myPlants1.list1; ^_^
bitgrower
@bitgrower
Feb 11 2016 02:48
if I want to reference the OTHER arguments, I have to play with the arguments object ... which is where the page that @dcnr sent you to will be helpful ...
cannelflow
@cannelflow
Feb 11 2016 02:48
@vvang044
rphares
@rphares
Feb 11 2016 02:48
okay... nm then, @vvang044 ...
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:48
@vvang044
rphares
@rphares
Feb 11 2016 02:48
for the getting it side-
myPlants has two parts, @vvang044 , so it also needs an index,
bitgrower
@bitgrower
Feb 11 2016 02:49
@vvang044 is working on a different challenge @rphares ...
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:50
yeah they have to arrays that you want to get, .
Accessing Nested Arrays in JSON
bitgrower
@bitgrower
Feb 11 2016 02:50
I think ... at least I was hellping him out with a different one ...
rphares
@rphares
Feb 11 2016 02:50
this is what @vvang044 sent me, @bitgrower ``` var secondTree = myPlants.trees[1];
Vik
@vvang044
Feb 11 2016 02:50
if you do myPlants[ 1]. trees[1 ]
rphares
@rphares
Feb 11 2016 02:50
think its the same one...
thats halfway!
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:50
yeah your right @bitgrower and i am the you help me, .
bitgrower
@bitgrower
Feb 11 2016 02:50
ahhh ... okay ... LOL ... nvm ...
rphares
@rphares
Feb 11 2016 02:50
so then... look again, @vvang044
bitgrower
@bitgrower
Feb 11 2016 02:50
ah ... sorry, @markjean22 ...
Robert Richey
@0x0936
Feb 11 2016 02:50
:eyes:
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:50
aw hahaha
bitgrower
@bitgrower
Feb 11 2016 02:50
:(
:blush:
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:51
^_^
rphares
@rphares
Feb 11 2016 02:51
the second part also needs to change-- you already got the right group with myPlants[1] @vvang044
bitgrower
@bitgrower
Feb 11 2016 02:51
do you understand now @markjean22
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:51
yeah thats right, .
rphares
@rphares
Feb 11 2016 02:51
but we need to find pine in that small set [], @vvang044
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:51
yup
Tyler
@Thiggs
Feb 11 2016 02:51
@dcnr before I forget, thanks for your help! I read that arguments object doc a million times but it didn't click with me until @bitgrower told me what I was doing wrong...I'm making progress. Appreciate the help!
CamperBot
@camperbot
Feb 11 2016 02:51
thiggs sends brownie points to @dcnr and @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: thiggs already gave bitgrower points
Vik
@vvang044
Feb 11 2016 02:51
ok
CamperBot
@camperbot
Feb 11 2016 02:51
:star: 591 | @dcnr | http://www.freecodecamp.com/dcnr
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:51
@rphares you get that problem
@vvang044 you get that problem??
rphares
@rphares
Feb 11 2016 02:52
but, that small set [] isn't with trees, @vvang044 ... look where the comma is,
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:52
or not yet
rphares
@rphares
Feb 11 2016 02:52
look where the : is...
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:52
^_^
Vik
@vvang044
Feb 11 2016 02:53
list?
rphares
@rphares
Feb 11 2016 02:53
yep :)
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:53
yes list
bitgrower
@bitgrower
Feb 11 2016 02:53
@thiggs yw -- I spent hours digging in and getting the answer ... and it wasn't making sense to me ... kinda get spoiled because so many of the challenges pass 1 argument, but do so in an array ... so you get used to the argument being ALL of the arguments, not just one ...
Reena
@annzach
Feb 11 2016 02:53
can some one tell me the significance of getting brownie points?
rphares
@rphares
Feb 11 2016 02:53
explain brownie
CamperBot
@camperbot
Feb 11 2016 02:53

: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

Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:54
hahaha master @bitgrower start angry, .lol sorry master
Norman Dela Cruz
@dcnr
Feb 11 2016 02:54
@Thiggs I'd appreciate it if you can tell me where the confusing parts are, I can be vague at times!
bitgrower
@bitgrower
Feb 11 2016 02:54
? angry ? nope ... just frustrated ...
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:54
hahaha sorry
bitgrower
@bitgrower
Feb 11 2016 02:55
...but I turn frustration into curiosity ...
Vik
@vvang044
Feb 11 2016 02:55
so it should be myplants.lists.trees?
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:55
your good for coding area and i get make sense
rphares
@rphares
Feb 11 2016 02:55
@vvang044 , not quite,
bitgrower
@bitgrower
Feb 11 2016 02:55
glad I could be of help ...
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:55
nope @vvang044
Tyler
@Thiggs
Feb 11 2016 02:55
@bitgrower @dcnr that's exactly the struggle! I just assumed that when an array was passed as an argument, that the array was the argument... arr[0] === arguments[0]
rphares
@rphares
Feb 11 2016 02:55
you had the index for myPLants earlier, the from part is myPlants[1]... we need to tell it we want that second object,
Vik
@vvang044
Feb 11 2016 02:56
they green pops are freaking annoying keep blocking the screen
rphares
@rphares
Feb 11 2016 02:56
then, we want the second item in the list part,
so we need the index for that too
so it would be myPlants[1].list[?], @vvang044 ?
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:56
myplants and list @vvang044
?
bitgrower
@bitgrower
Feb 11 2016 02:56
@vvang044 -- go over to the wrench at the top right of the specific room and you can change the room notifications ...
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:57
nice nice now @vvang044 you can get that, .hehehe
hahahaha
Vik
@vvang044
Feb 11 2016 02:57
looks like the wrench is on a break or something it doesnt work.....
rphares
@rphares
Feb 11 2016 02:57
theres another way, you can also start a message with /lurk
Mark Gil Sumanlad
@markjean22
Feb 11 2016 02:58
look the comment of sir @rphares you can get that, .
Vik
@vvang044
Feb 11 2016 02:58
/lurk thank you all for the help......
rphares
@rphares
Feb 11 2016 02:58
oh yay--
Norman Dela Cruz
@dcnr
Feb 11 2016 02:58
@Thiggs how about this crappy chart?
function name(argument1, argument2, etc) { /* function body */ }
               │            │        │
               │   ┌────────┘        │
               │   │   ┌─────────────┘
               │   │   │
         name(10, 20, etc);
rphares
@rphares
Feb 11 2016 02:58
@vvang044 , does it make sense?
/ lurk
Vik
@vvang044
Feb 11 2016 02:59
@bitgrower @rphares
rphares
@rphares
Feb 11 2016 02:59
by itself (no space)
(i shouldn't be able to see the text, if i can see /lurk in the message, it didn't work :) )
Vik
@vvang044
Feb 11 2016 02:59
lol
oh i tried
rphares
@rphares
Feb 11 2016 03:00
any luck? (i know they were considering updating that feature, so minot sure if its still good...)
Vik
@vvang044
Feb 11 2016 03:00
but going back to the exercise now i understand......
@rphares thank you
CamperBot
@camperbot
Feb 11 2016 03:00
vvang044 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2647 | @rphares | http://www.freecodecamp.com/rphares
Vik
@vvang044
Feb 11 2016 03:00
@bitgrower thank you
CamperBot
@camperbot
Feb 11 2016 03:00
vvang044 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 11 2016 03:00
worked for me @rphares ... just changed a bunch of room notifications ....
CamperBot
@camperbot
Feb 11 2016 03:00
:star: 441 | @bitgrower | http://www.freecodecamp.com/bitgrower
rphares
@rphares
Feb 11 2016 03:01
yay! thats the important part~
bitgrower
@bitgrower
Feb 11 2016 03:01
yw @vvang044 ! Happy coding!
rphares
@rphares
Feb 11 2016 03:01
oh, fantastic-- unexpected bonus , glad that works for ya, @bitgrower
Matthew Baker
@matthew-baker01
Feb 11 2016 03:01

Can someone help me with escape sequences? I' supposed to Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr

This is my code
```

bitgrower
@bitgrower
Feb 11 2016 03:01
me too /1
rphares
@rphares
Feb 11 2016 03:02
sure, @matthew-baker01 :)
Matthew Baker
@matthew-baker01
Feb 11 2016 03:02
var myStrv = "\\ \t \t \r \n";
rphares
@rphares
Feb 11 2016 03:02
myStr
not myStrv
bitgrower
@bitgrower
Feb 11 2016 03:02
you have some spare blanks in the string ...
Matthew Baker
@matthew-baker01
Feb 11 2016 03:02
xD @rphares thanks
CamperBot
@camperbot
Feb 11 2016 03:02
matthew-baker01 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2648 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 11 2016 03:02
sure thing~
Matthew Baker
@matthew-baker01
Feb 11 2016 03:03
I always add and skimp over typos like that for some reason :s
rphares
@rphares
Feb 11 2016 03:03
takes us time to get them, a skill we need to build up :)
bitgrower
@bitgrower
Feb 11 2016 03:03
syntax coloring can help, @matthew-baker01 -- if you use a new variable and it's not passed as an argument, it will be colored white ...
Vik
@vvang044
Feb 11 2016 03:04
one day im going to steal @rphares brownie's ....you have one too many.....lol
rphares
@rphares
Feb 11 2016 03:04
the other day i was staring at someones code trying to help feeling dumb for quite a while... even looking at someone else, i missed that there was no + in an exercise just about concatenating, lol
bitgrower
@bitgrower
Feb 11 2016 03:04
hahahahahaha @vvang044
rphares
@rphares
Feb 11 2016 03:04
i would gladly give them away if i could :blush:
but, a better goal:
bitgrower
@bitgrower
Feb 11 2016 03:04
@rphares -- why it's handy to take a break once in a while ...
Matthew Baker
@matthew-baker01
Feb 11 2016 03:04
I always get stuck on typos and spend loads of time fixing my code when I just need to delete a letter xD
rphares
@rphares
Feb 11 2016 03:04
someday, you will earn so many, you will simply pass me by a mile :)
bitgrower
@bitgrower
Feb 11 2016 03:04
so @matthew-baker01 -- not to distract you too much -- does your challenge work now?
Vik
@vvang044
Feb 11 2016 03:05
no sh*t....really
Matthew Baker
@matthew-baker01
Feb 11 2016 03:05
@bitgrower Yup deleted the v and it worked :)
Vik
@vvang044
Feb 11 2016 03:05
hahaha
rphares
@rphares
Feb 11 2016 03:05
@bitgrower , i do! I've cut down my time on here by more than half in the last two weeks~
Norman Dela Cruz
@dcnr
Feb 11 2016 03:05
@rphares I knew it! you're all going to turn FCC into a free-to-play microtransaction site with Brownie points as your fiat currency
bitgrower
@bitgrower
Feb 11 2016 03:05
excellent!
Jonathan Mitchell
@Vanhealen
Feb 11 2016 03:05
any recommended reading on regexp? Trying to figure out how to ignore
bitgrower
@bitgrower
Feb 11 2016 03:05
@dcnr geeking out big time ...
help regex
CamperBot
@camperbot
Feb 11 2016 03:05

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

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

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

bitgrower
@bitgrower
Feb 11 2016 03:05
TONS of resources for you
rphares
@rphares
Feb 11 2016 03:06
lol, @dcnr ... giving that i didn't have a computer or unrestricted internet till two months ago... i think i get the joke? :wink2:
Mark Gil Sumanlad
@markjean22
Feb 11 2016 03:06
aw hahahaha
rphares
@rphares
Feb 11 2016 03:06
but the likelyhood of me running any kinda tech scheme is kinda low :blush:
Tyler
@Thiggs
Feb 11 2016 03:08
so....stupid question....I don't get why .filter takes a function instead of a value to filter out?
Norman Dela Cruz
@dcnr
Feb 11 2016 03:09
@rphares ahaha
@Thiggs that's just how the specs decided it's to be
Vik
@vvang044
Feb 11 2016 03:10
ok.....this is might stupid question but i will ask......all my previous exercises the instructions were to the left and the code was to the right.....it was easy to read the instructions and work......but now the instructions is at the top and the code is all the way at the bottom.....is there way to reverse this?
Norman Dela Cruz
@dcnr
Feb 11 2016 03:10
@Thiggs and it's good because you can do complicted stuffs inside
@vvang044 you need a larger screen
@vvang044 that mode is the mobile layout iirc
Vik
@vvang044
Feb 11 2016 03:11
hmm.....
bitgrower
@bitgrower
Feb 11 2016 03:11
yup -- like @dcnr said -- stretch out your screen
Vik
@vvang044
Feb 11 2016 03:12
yep.....once i sell @rphares brownies on E-bay i can afford a larger screen laptop
until then i have to deal with my small screen
Tyler
@Thiggs
Feb 11 2016 03:12

@dcnr I just can't ever get it to remove stuff inside a loop!

I'll keep playing with it and .splice but I was just curious why it worked so much different from other array methods

bitgrower
@bitgrower
Feb 11 2016 03:12
I don't think it's just mobile, @dcnr ... it didn't take much for my sidebars to shift to down the page when I shortened the width not alll that much ...
splice -- I am in love with splice ... such a cool function ...
Norman Dela Cruz
@dcnr
Feb 11 2016 03:14
@bitgrower @vvang044 rather than mobile, I should say "responsive design" :P
if you shrink your window small enough, it changes the layout to that
bitgrower
@bitgrower
Feb 11 2016 03:14
@thiggs -- DO look at the MDN page on arguments object that @dcnr posted earlier ...
Vik
@vvang044
Feb 11 2016 03:15
isnt that what we used in HTML first chapters the catphotoapp
bitgrower
@bitgrower
Feb 11 2016 03:15
arguments are array-LIKE but they are NOT formally arrays ... if you want to use them in an array, you will need to convert them ... there is code on the MDN page you can steal for doing that ...
@vvang044 -- that's bootstrap -- bootstrap is one way of doing responsive design ... :)
rphares
@rphares
Feb 11 2016 03:15
lol, @vvang044 ~
Tyler
@Thiggs
Feb 11 2016 03:16
@bitgrower yup, that fixed my code so it works with the first 2 tests, but not the last 3. I think I still have a problem with how I'm filtering out the bad stuff.
Vik
@vvang044
Feb 11 2016 03:17
now im doing record collection....i needs a lot of luck with this
bitgrower
@bitgrower
Feb 11 2016 03:17
seek and destroy, right ?
Tyler
@Thiggs
Feb 11 2016 03:18
yup!
bitgrower
@bitgrower
Feb 11 2016 03:20
post your code ?
Tyler
@Thiggs
Feb 11 2016 03:21
js
function destroyer(arr) {
  var searchArr = arguments[0]; //first given argument is array to be searched


 for (var i = 1; i< arr.length; i++){ //For the provided destroyer items
   for (var j =0; j< searchArr.length; j++){ //search the first array
     if (searchArr[j] === arguments[i]){          //if anything in the search array equals the current number
       searchArr.splice(j, 1); //take that number out of the search array.
     }
   }
 }



  return searchArr; //return the array
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
wait I see it
arugments.length not arr.length!
...that fixed the last one!
Still 2 broken messages
bitgrower
@bitgrower
Feb 11 2016 03:22
that's true!
seriously ... go look at the MDN page on Arguments Object ... you'll see a nice piece of code which will give you all the arguments in an array ...
much easier to deal with ...
(imnsho)
Vik
@vvang044
Feb 11 2016 03:25
guys how many steps are there in "record collections" ?
Ivan Perez
@joannesalfa
Feb 11 2016 03:25
@dcnr thanks for your time
CamperBot
@camperbot
Feb 11 2016 03:25
joannesalfa sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 592 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 11 2016 03:25
thanks too @joannesalfa sorry I'm really not much help about it
CamperBot
@camperbot
Feb 11 2016 03:25
dcnr sends brownie points to @joannesalfa :sparkles: :thumbsup: :sparkles:
:star: 388 | @joannesalfa | http://www.freecodecamp.com/joannesalfa
Norman Dela Cruz
@dcnr
Feb 11 2016 03:26
@joannesalfa I'll keep fiddling on it though, you piqued my interest lol
Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:26

anyone mind giving me a quick rundown on accessing nested arrays in JSON? I'm confused as to what I'm doing wrong, or how I should be accessing the value instead of the key.

// 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[list[1]];

// Change this line

Vik
@vvang044
Feb 11 2016 03:26
lol.....
welcome to my world
CamperBot
@camperbot
Feb 11 2016 03:26

welcome to FreeCodeCamp @vvang044!

Ivan Perez
@joannesalfa
Feb 11 2016 03:26
@dcnr we should reset tomorrow, npm server is acting weird
bitgrower
@bitgrower
Feb 11 2016 03:26
explain format
CamperBot
@camperbot
Feb 11 2016 03:26

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:29
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line
console.log(myPlants.trees);
//var secondTree = myPlants.trees[list[1]]; // Change this line
ichirped
@ichirped
Feb 11 2016 03:29
help seek and destroy
CamperBot
@camperbot
Feb 11 2016 03:29

:point_right: algorithm seek and destroy [wiki]

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:30

my bad ```js
// 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[list[1]]; // Change this line
```

artjia
@artjia
Feb 11 2016 03:30
help profile lookup
CamperBot
@camperbot
Feb 11 2016 03:30

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

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

artjia
@artjia
Feb 11 2016 03:30
'''
CamperBot
@camperbot
Feb 11 2016 03:30
:bulb: to format code use backticks! ``` more info
Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:31
// 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[list[1]];
 // Change this line
my bad for massive fails
rphares
@rphares
Feb 11 2016 03:32
Heya, @bryantheastronaut , you are close, but we have a couple things to fix,
first, myPlants has two parts, right?
artjia
@artjia
Feb 11 2016 03:32
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
Vik
@vvang044
Feb 11 2016 03:32
i will let the experts to explain.......lol
rphares
@rphares
Feb 11 2016 03:32
so you need an index there.... is pine in myPlants[0] or myPLants[1] @bryantheastronaut ?
artjia
@artjia
Feb 11 2016 03:33
any expert can explain where did I do wrong within this code
Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:33
@rphares ahhhhh so pines is in myPlants[1]
Vik
@vvang044
Feb 11 2016 03:34
apart from me there are a few in here but first paste your code in here
rphares
@rphares
Feb 11 2016 03:34
col thats the first part, @bryantheastronaut
so then, if you are using that to get the first object guy, then you dont really need 'trees', now do ya,
Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:35
@rphares thanks
CamperBot
@camperbot
Feb 11 2016 03:35
bryantheastronaut sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2650 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 11 2016 03:36
anytime :)
Vik
@vvang044
Feb 11 2016 03:36
@rphares in the record collection it says i need to write a function that takes id,prop and value.....
rphares
@rphares
Feb 11 2016 03:36
oh boy, I'm lousy at trying to explain this one, but... what have you go so far?
Vik
@vvang044
Feb 11 2016 03:36
for the given id in collection
rphares
@rphares
Feb 11 2016 03:36
ahh, just starting?
Vik
@vvang044
Feb 11 2016 03:37
i didnt even started that one....just reading the instructions and trying to understand what i need to do in here
rphares
@rphares
Feb 11 2016 03:37
okay, well, do remember that I'm not your best resource, i can only tell you how i approached it... which I'm pretty sure isn't the god way, lol
but,
i wrote my ifs first,
Vik
@vvang044
Feb 11 2016 03:37
blind leading the blind.....im ok with that....haha
rphares
@rphares
Feb 11 2016 03:38
looking at the instructions, it gives us three scenarios of sorts,
so i wrote what i though those conditions looked like first,
  1. If value is non-blank (value !== "") and prop is not "tracks"
  1. If the prop is "tracks" and value is non-blank,
  1. If value is blank,
stupid gitter... those say 1,2,3.. sigh
artjia
@artjia
Feb 11 2016 03:39
anyone can help with my code
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
Omar Richardson
@omie86
Feb 11 2016 03:40
var celsius = prompt("Please enter your temperature in celcius");

function convert(celsius) {
  // Only change code below this line
var fahrenheit = (celsius) * 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
alert(convert(celsius));
modified Convert Celsius to Fahrenheit challenge to prompt a user to enter a temperature.. Thought this was kinda cool
Wes
@weslez
Feb 11 2016 03:40
Trying real hard not to look at the solution for challenge "Record Collection". I think I'm really close and need a little help. The following code accomplishes all of the objectives of the challenges, but it won't let me pass. Where did I go wrong?
// 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 (prop === "tracks" && value !== "") {
    return collection[id][prop].push(value); 
}  else if (value !== "" && prop !== "tracks") {
    return collection[id][prop] = value;
}  else if (value === "") {
    return delete collection[id][prop];
}

}
// Alter values below to test your code
update(5439, "artist", "ABBA");
rphares
@rphares
Feb 11 2016 03:40
those by themselves are kinda easy to put into code. take t pretty literally, there's an if and some Ands some keywords, prop, tracks, etc right there, @vvang044 :)
Tyler
@Thiggs
Feb 11 2016 03:40
Got it!
Bryan Gilbraith
@bryantheastronaut
Feb 11 2016 03:41
@omie86 nice!
Vik
@vvang044
Feb 11 2016 03:41
got it and push as well right
Abhisek Pattnaik
@abhisekp
Feb 11 2016 03:41
Got it? :+1: Now say thanks
rphares
@rphares
Feb 11 2016 03:41
, @weslez , i dont think you want to return delete collection[id][prop];
you just want to delete it,
you want to return the collection at the end...
@vvang044 , yep, that comes into the {do stuff} part of the ifs, @vvang044 :)
lol, @abhisekp , are you asking for brownies???
Abhisek Pattnaik
@abhisekp
Feb 11 2016 03:42
:P
artjia
@artjia
Feb 11 2016 03:43
anyone please help on my code :worried:
rphares
@rphares
Feb 11 2016 03:43
@abhisekp shakes head
CamperBot
@camperbot
Feb 11 2016 03:43
rphares sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star: 2064 | @abhisekp | http://www.freecodecamp.com/abhisekp
Tyler
@Thiggs
Feb 11 2016 03:43
I probably didn't do it the right way, but I got it! thanks again @dcnr and @bitgrower
My original code just needed a little j-- love. I forgot that if I'm deleting things, I probably need to reiterate
CamperBot
@camperbot
Feb 11 2016 03:43
thiggs sends brownie points to @dcnr and @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: thiggs already gave dcnr points
:star: 442 | @bitgrower | http://www.freecodecamp.com/bitgrower
Tyler
@Thiggs
Feb 11 2016 03:44
@rphares I think @abhisekp was just reminding me to thank the others.
CamperBot
@camperbot
Feb 11 2016 03:44
thiggs sends brownie points to @rphares and @abhisekp :sparkles: :thumbsup: :sparkles:
:star: 2065 | @abhisekp | http://www.freecodecamp.com/abhisekp
:star: 2651 | @rphares | http://www.freecodecamp.com/rphares
Wes
@weslez
Feb 11 2016 03:44
Thanks @rphares . How about the other return statements in the middle of the function there? Are those alright?
CamperBot
@camperbot
Feb 11 2016 03:44
weslez sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2652 | @rphares | http://www.freecodecamp.com/rphares
Tyler
@Thiggs
Feb 11 2016 03:44
hah! whoops!
Collin
@collinferry
Feb 11 2016 03:44
In this Seek and Destroy code, I understand what the first line does, but I don't understand the stringing together of prototype and call here. I read a few pages on prototype and I think I understand it in theory, but it being used here in practice is melting my brain. Can anyone explain like I'm five?
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  args.splice(0, 1);
  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Sam
@vanaddo
Feb 11 2016 03:44

var myStr= '"I am a \"double quoted\" string inside \"double quotes\""'; // Change this line
I'm trying to figure out what I've done wrong. The code is running properly but I guess something is missing.
Vik
@vvang044
Feb 11 2016 03:44
ok let me try
rphares
@rphares
Feb 11 2016 03:45
happy coding :)
bitgrower
@bitgrower
Feb 11 2016 03:45
okay ... so you are showing off the wiki answer ...
@collinferry -- go look in my profile for my S&D answer -- I have it extensively documented...
I spent hours and hours working on understanding ... :)
rphares
@rphares
Feb 11 2016 03:46
@bryantheastronaut ,save your return till the end,
just update throughout :)
Norman Dela Cruz
@dcnr
Feb 11 2016 03:47
@Thiggs if you're deleting array elements, it's just setting to undefined. You can easily filter those out with filter
Collin
@collinferry
Feb 11 2016 03:47
@bitgrower yeah I realize now that might be foolish of me. Apologies. I'll go look at your solution. Glad you spent hours too :) I don't know how I would have discovered using the prototype or call methods since I'd never encountered either before within FCC (that I remember anyway). Thanks for your help!
CamperBot
@camperbot
Feb 11 2016 03:47
collinferry sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 443 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 03:47
@collinferry they DO give you the arguments object MDN page as a helpful link ... and helpful it is indeed !
they provide that line exactly -- in fact, I think you'll see a link to it in my code ... :)
well, in the comments ...
Collin
@collinferry
Feb 11 2016 03:48
@bitgrower hmm, i'll look at that again. I thought I read the whole thing but apparently I didn't read closely enough!
@bitgrower I fund that to be the hardest algorithm challenge. All the rest I figured out on my own. I'm just now going back to do due diligence
bitgrower
@bitgrower
Feb 11 2016 03:49
LOL ... I know how you feel -- I didn't remember seeing it before, either, but somehow after I was trying to figure out things ... there it was ... i don't even think you have to scroll down ...
Collin
@collinferry
Feb 11 2016 03:49
found*
Abhisek Pattnaik
@abhisekp
Feb 11 2016 03:50
about @bitgrower
CamperBot
@camperbot
Feb 11 2016 03:50
:star: 443 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 03:50
steamroller is another I found a bit challenging ... and I found smallest common multiplier hard, just because I didn't find a good algo to use. When I found the right algo, then it became easier ...
rphares
@rphares
Feb 11 2016 03:51
@vanaddo , the quotes need a bit of tweaking...
Abhisek Pattnaik
@abhisekp
Feb 11 2016 03:51
@bitgrower woaH! that's really well documented. Maybe over-documented :P
bitgrower
@bitgrower
Feb 11 2016 03:51
ACK @abhisekp -- why are you abouting me ... feeds my paranoia ... :)
rphares
@rphares
Feb 11 2016 03:51
you dont need that extra set of ' single quotes you have
@vanaddo
artjia
@artjia
Feb 11 2016 03:51
anyone can help with this
rphares
@rphares
Feb 11 2016 03:51
just deleted the outside single quotes :)
artjia
@artjia
Feb 11 2016 03:51
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
Sam
@vanaddo
Feb 11 2016 03:51
@rphares ok. let me try that
bitgrower
@bitgrower
Feb 11 2016 03:51
hahahahaha -- well ... @abhisekp -- I wanted to document everything I figured out ...
Abhisek Pattnaik
@abhisekp
Feb 11 2016 03:52
@bitgrower and that's a really good thing
rphares
@rphares
Feb 11 2016 03:52
@bitgrower ,right? tis super awkward... how to get people to stop snooping ;)
bitgrower
@bitgrower
Feb 11 2016 03:52
I wouldn't document something like that in production code -- but for myself ... yup!
Abhisek Pattnaik
@abhisekp
Feb 11 2016 03:52
:+1:
artjia
@artjia
Feb 11 2016 03:52
anyone can help with code above
Sam
@vanaddo
Feb 11 2016 03:52
it worked! Thank you @rphares !
CamperBot
@camperbot
Feb 11 2016 03:52
vanaddo sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2654 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 11 2016 03:52
anytime~
bitgrower
@bitgrower
Feb 11 2016 03:53
LOL @rphares -- they can snoop as much as they like ... as long as 1. they tell me why; 2. it's obvious; or 3. I don't know about it ... (I mean, g & fb know more about me than I know about myself, I figure ... )
rphares
@rphares
Feb 11 2016 03:53
lol
bitgrower
@bitgrower
Feb 11 2016 03:54
anyway ... thanks @abhisekp
CamperBot
@camperbot
Feb 11 2016 03:54
bitgrower sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star: 2066 | @abhisekp | http://www.freecodecamp.com/abhisekp
bitgrower
@bitgrower
Feb 11 2016 03:54
oh wait ... they can also snoop if they like my code and come back and give me brownie points ... LOL ...
what can I say, my vanity precedes me ...
rphares
@rphares
Feb 11 2016 03:55
lol
hmm, not having snooped, i still assume i would like your code @bitgrower , so...
CamperBot
@camperbot
Feb 11 2016 03:56
rphares sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 444 | @bitgrower | http://www.freecodecamp.com/bitgrower
rphares
@rphares
Feb 11 2016 03:56
Well, thats a terrible number in China, sorry about that, lol
artjia
@artjia
Feb 11 2016 03:57
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Feb 11 2016 03:57
hahahahaha ... it's not my code, really -- it's FCC's ... I just figured I would spend the time to figure out what it all meant and made it my own ...
artjia
@artjia
Feb 11 2016 03:57
@bitgrower can you help with this
bitgrower
@bitgrower
Feb 11 2016 03:57
yeah, I know @phares -- that's why I've got to get to 500 and beyond quickly ...
@bakio ...
artjia
@artjia
Feb 11 2016 03:58
@bitgrower ```js
bitgrower
@bitgrower
Feb 11 2016 03:58
okay .. @bakio -- it looks pretty good except for one tiny thing ...
artjia
@artjia
Feb 11 2016 03:58
@bitgrower what was that?
bitgrower
@bitgrower
Feb 11 2016 03:59
and that is ... how do you know if the firstname is not found in the objects in the array ?
this is not as much a how to use js question as it is a "how do I define the problem" question ...
artjia
@artjia
Feb 11 2016 04:00
@bitgrower (contacts[i].firstName === firstName)
bitgrower
@bitgrower
Feb 11 2016 04:01
if I have a bag of marbles, and I want to say there isn't a black marble in the bag, how many marbles do I have to look at ?
(this is NOT a trick question...)
artjia
@artjia
Feb 11 2016 04:02
@bitgrower all one by one to make sure the isnt black marble
bitgrower
@bitgrower
Feb 11 2016 04:02
yep ...
so, if you want to know there isn't an object with the given property in the array, what do you have to do ?
@rphares -- I had an extension at work with 444 in it ... and a Chinese co-worker ... LOL ... who said in somewhat a bit of horror ... "HOW did you get that number?!?"
Norman Dela Cruz
@dcnr
Feb 11 2016 04:07
@bitgrower I find it weirder that some hospitals don't have floor 13 :/
bitgrower
@bitgrower
Feb 11 2016 04:08

I interviewed at Adobe in San Jose ... and they DID have a floor 13 ... it was actually the floor I interviewed on ...

I don't know of too many hospitals that even have that many floors ... I don't think SF General does ... LA county might ... Santa Clara County def doesn't ...

Norman Dela Cruz
@dcnr
Feb 11 2016 04:09
@bitgrower I guess it depends on the owner, yes?
bitgrower
@bitgrower
Feb 11 2016 04:10
yeah ... I know it's pretty common with hotels ... or was ... I was surprised about Adobe ...
I used to be a paramedic -- I don't remember too many hospitals (and I went to more than a few ) which had that many floors ... LA Co is about the only one I can remember ... may be more true back East though ... I am a Cali girl ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:12
@bitgrower oh is that so? thank you for your service! :D
CamperBot
@camperbot
Feb 11 2016 04:12
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 445 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 04:13
yw ... twasn't like I was in the military ... just another working stiff ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:15
@bitgrower eh don't be like that, everything we do makes us grow a bit
heh get it grow a bit bitgrower
I'll show myself out.
bitgrower
@bitgrower
Feb 11 2016 04:18
LOL ... too funny ... you needn't show yourself out ... :) I rather enjoyed it ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:19
xD
bitgrower
@bitgrower
Feb 11 2016 04:19
@bakaio -- where are ya ???
seems rather quiet in here tonight ...
I may have to go back and play with my graphics program and come up with something interesting for my portfolio page ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:24
@bitgrower good luck to you!
bitgrower
@bitgrower
Feb 11 2016 04:24
yeah, the code part doesn't intimidate me ... but coming up with something cool to attract people's eye ... well, that's another story ...
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:24
hey can someone help me
bitgrower
@bitgrower
Feb 11 2016 04:25
yes!!!!
I hope
what's up?
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:25
I`m doing the Adding a default option Switch statement lesson
in the Javascript section

my code is this switch (val){
case 1 : val="a"
return "apple";
break;

case 2:val="b"
return "bird";
  break;
case 3: val="c"
return "cat";
  break;
default:
  return"stuff"

}

but it only returns the default
the previous lab was the same thing minus the default and it worked perfect
bitgrower
@bitgrower
Feb 11 2016 04:26
interesting ...
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:26
when I remove the default to create pretty much the same code of the previous lab nothing returns
bitgrower
@bitgrower
Feb 11 2016 04:26
well, look at the example code they provide along the side (or deeper in the page) ... and follow it ..
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:26
lol I did
thats how I got past last lab
bitgrower
@bitgrower
Feb 11 2016 04:27
can you post your previous working code ?
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:27

// Only change code below this line
switch (val){
case 1: val=1
return "alpha";
break;

case 2:(val=2)
return "beta";
  break;
case 3: (val=3)
return "gamma";
  break;
case 4: (val=4) 
return "delta";
  break;

}

// Only change code above this line

in the previous lab we used numbers in this one we are using letters and adding the default condition
bitgrower
@bitgrower
Feb 11 2016 04:28
okay ... you have a problem with your switch/case statement ...
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:28
*default statement
bitgrower
@bitgrower
Feb 11 2016 04:28
think of this like an if statement ...
except once you use the variable at the top of the switch statement, you never have to refer to it again in the switch statement ...
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:29
so in the case do I just put "a" or ="a"
bitgrower
@bitgrower
Feb 11 2016 04:29
yep!
the first one ...
Frawel
@Frawel
Feb 11 2016 04:30
Yes just that
Jason
@carpediem1213
Feb 11 2016 04:30
Evening, all. Is there a reason why array[i].length would be undefined if the array is a split array of strings? (longest word)
bitgrower
@bitgrower
Feb 11 2016 04:30
switch (num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
from the example code in the relevant challenge
just the value ...
@carpediem1213 -- post some code ?
Jason
@carpediem1213
Feb 11 2016 04:31

```js
var array = [];
var currentWord;
function findLongestWord(str) {
var fullStringLength = str.length;
array = str.split(" ");

for (var i = 0; i <= fullStringLength; i++){
currentWord = array[i];

Guannue Bouquia
@GBArchitect
Feb 11 2016 04:31
the statement should be the vale AND the return ?
Jason
@carpediem1213
Feb 11 2016 04:31
oops...
bitgrower
@bitgrower
Feb 11 2016 04:32
@GBArchitect -- what do the instructions say to return ?
Jason
@carpediem1213
Feb 11 2016 04:32
var array = [];
var currentWord;
function findLongestWord(str) {
  var fullStringLength = str.length;
  array = str.split(" ");

  for (var i = 0; i <= fullStringLength; i++){
    currentWord= array[i];
When I use currentWord.length it is showing undefined.
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:33
never mind I see the issue
Jovvi Johnson
@jovjohnson
Feb 11 2016 04:33
if anyone could help me with ajax that would be fantastic
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:33
thank you so much @bitgrower
CamperBot
@camperbot
Feb 11 2016 04:33
gbarchitect sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 446 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 04:33
let us know if you need any more help -- and also if that fixes the problem !!!
Guannue Bouquia
@GBArchitect
Feb 11 2016 04:33
I "over complicated" my code
you bet
bitgrower
@bitgrower
Feb 11 2016 04:33
very common ... happy coding !
@carpediem -- why are you defining the variables outside of the function ?
Jason
@carpediem1213
Feb 11 2016 04:34
I'm still working through the algorithm, but I just want to be able to run the for loop and get the length of the string located at array[i]
@bitgrower I don't know :)
bitgrower
@bitgrower
Feb 11 2016 04:34
use var myVar name ...
you can run into name collisions if you make your variables global (that is, not preceded by var)
Brett Felts
@brettfelts
Feb 11 2016 04:35
Hey, so I'm really having trouble going through the intermediate algorithm challenges. I was wondering if anyone had any suggestions for reading or listening that helped you get into the thought process in a better way. Right now I'm about halfway through the fibonacci challenge and I wrote a loop so infinite it crashed my browser if I even opened the page.
Norman Dela Cruz
@dcnr
Feb 11 2016 04:36
@carpediem1213 don't define your variables outside your function unless it's preset that way. The online tester borks with global vars
Jason
@carpediem1213
Feb 11 2016 04:36
@bitgrower I put the vars inside the function, but still have the same error. TypeError: Cannot read property 'length' of undefined
bitgrower
@bitgrower
Feb 11 2016 04:36
@carpediem1213 -- what does the function call look like, please ?
Tijana Jung
@elsalvadordali
Feb 11 2016 04:36

I need a little bit of help with the Record Collection Challenge.. I have the following error: After update(2548, "artist", ""), artist should not be set.

My code for that part is: ' else if (value === "") {
delete collection[id][prop];
} '

bitgrower
@bitgrower
Feb 11 2016 04:37
help web resources
bitgrower
@bitgrower
Feb 11 2016 04:37
nope that wasn't the page I was looking for :(
Tijana Jung
@elsalvadordali
Feb 11 2016 04:38

Here is the whole function:
`function update(id, prop, value) {
if (prop !== "" && prop !== "tracks") {
collection[id][prop] = value;
}
else if (prop == "tracks" && value !== "") {
collection[id][prop].push(value);

}
else if (value === "") {
delete collection[id][prop];
}

return collection;
}`

bitgrower
@bitgrower
Feb 11 2016 04:38
@brettfelts -- they def are not easy ... but make HEAVY use of the helpful hints pages ... some of those can be answered directly from code on MDN pages ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:38
@brettfelts hi for your crashing code you can take a look at this https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Loop-Protect you might need the Unresponsive Code part
Jason
@carpediem1213
Feb 11 2016 04:38
@bitgrower I haven't really put together a plan for solving this yet. I just wanted to know why I cannot get the length from array[i]
function findLongestWord(str) {
  var largest = 0;
  var array = [];
  var currentWord;
  var nextWord;
  var fullStringLength = str.length;
  array = str.split(" ");

  for (var i = 0; i <= fullStringLength; i++){
    currentWord = array[i].length;
    nextWord = array[i+1].length;


  }

  return largest;
}
bitgrower
@bitgrower
Feb 11 2016 04:39
@carpediem1213 -- plan first, code 2nd ... :)
it still is going to matter what you are passing to the function ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:39
@brettfelts as for resources, I'm sorry I don't really have any, but what helps me the most is by just writing down the key points that I think are needed by the problem description
@brettfelts and I always go step by step
Jason
@carpediem1213
Feb 11 2016 04:39
@bitgrower okay there's a small plan. haha I was going to compare the current and next string
bitgrower
@bitgrower
Feb 11 2016 04:39
the function isn't going to operate without some input ... so what input are you giving it ...
just compare the strings ? or compare the lengths ?
Brett Felts
@brettfelts
Feb 11 2016 04:40
Thanks, @bitgrower and @dcnr
CamperBot
@camperbot
Feb 11 2016 04:40
brettfelts sends brownie points to @bitgrower and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 593 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 447 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 11 2016 04:40
@brettfelts In the case of Fibonacci, I would first research about what it is, and how it works, and what do I need to do with it
Jason
@carpediem1213
Feb 11 2016 04:40
@bitgrower compare the lengths. But I am using the function with "str" and then I split it into "array"
bitgrower
@bitgrower
Feb 11 2016 04:41
yeah, fib, it's easy to confuse the total you are accumulating with the last fib # ...
that's what I did ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:41
@carpediem1213 first of all, i <= fullStringLength will get your for loop indices out of bounds
bitgrower
@bitgrower
Feb 11 2016 04:41
okay .. but I don't know what str should be without seeing what you are passing to the function ?
Jason
@carpediem1213
Feb 11 2016 04:42
"The quick brown fox jumps over the lazy dog" and others
bitgrower
@bitgrower
Feb 11 2016 04:42
indeed, @dcnr -- good catch ...
Brett Felts
@brettfelts
Feb 11 2016 04:42
I understand Fibonacci, but I come from a more arts and humanities sort of background, so I'm having a lot of trouble getting into the proper mindset. The Fibonacci sequence just brought it to a head.
Jason
@carpediem1213
Feb 11 2016 04:42
@dcnr str.length doesn't work after split?
bitgrower
@bitgrower
Feb 11 2016 04:43
okay .. sigh ... i will go look at the challenge ... it really DOES matter EXACTLY what the function call looks like ...
Jason
@carpediem1213
Feb 11 2016 04:43
findLongestWord("The quick brown fox jumped over the lazy dog") should return a number.
bitgrower
@bitgrower
Feb 11 2016 04:43
@carpediem1213 all counts of strings & arrays are zero-based ... so the length of a string is always 1 greater than the last index ...
thanks!!!
Jason
@carpediem1213
Feb 11 2016 04:44
I'm not looking for the answer, really just the way I can access the length of the string after I split up the sentence
@bitgrower oh that's helpful!
Norman Dela Cruz
@dcnr
Feb 11 2016 04:44
@brettfelts times like this, though I don't really advise it, you just find a Fibonacci generation code somewhere and do what you have to do according to the instructions. IIRC it was to sum all odd only?
Brett Felts
@brettfelts
Feb 11 2016 04:44
Yep.
bitgrower
@bitgrower
Feb 11 2016 04:44
combine that with what @dcnr said, I think you have the answer ...
Brett Felts
@brettfelts
Feb 11 2016 04:45
I tried to adjust a code snippet I found online and after oversimplifying, I wrecked the whole thing to a nuke it from space kind of degree.
I relogged in though, and my code was reset, so I get a new shot
bitgrower
@bitgrower
Feb 11 2016 04:46
so, it's not that you can't get the length from array[i].length ... it's that you cannot get it from a particular instantiation of i ... specifically, when i = str.length
instantiation definition, in case it's needed -- it is when a variable takes on a specific value ...
good catch, @dcnr
Jason
@carpediem1213
Feb 11 2016 04:47
so when i=3 it trips up on "fox"?
bitgrower
@bitgrower
Feb 11 2016 04:48
yep ...
Jason
@carpediem1213
Feb 11 2016 04:48
I've added +1 to str.length to get fullStringLength
bitgrower
@bitgrower
Feb 11 2016 04:48
other way around ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:48
ah thanks @bitgrower
CamperBot
@camperbot
Feb 11 2016 04:48
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave bitgrower points
bitgrower
@bitgrower
Feb 11 2016 04:48
yw @dcnr ... thank you ...
CamperBot
@camperbot
Feb 11 2016 04:48
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 594 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 11 2016 04:49
@carpediem1213 wil you post your current code now?
Jason
@carpediem1213
Feb 11 2016 04:49
 var fullStringLength = str.length + 1;
ok here's the entire thing
Jason
@jpr00
Feb 11 2016 04:49
From the profile lookup challenge:function lookUp(firstName, prop){ // Only change code below this line var name = ""; var value = ""; for (var i = 0; i < contacts.length; i++) { if (firstName === contacts[i]["firstName"]) { name = contacts[i]["firstName"]; if (contacts[i][prop]) { value = contacts[i][prop]; } } } if (name === "") { value = "No such contact"; } if (value === "") { value = "No such property"; } return value; // Only change code above this line }
This worked, wondering if anyone had a different way of solving they'd be willing to share though.
Jason
@carpediem1213
Feb 11 2016 04:49

```js
function findLongestWord(str) {
var largest = 0;
var array = [];
var currentWord;
var nextWord;
var fullStringLength = str.length + 1;
array = str.split(" ");

for (var i = 0; i <= fullStringLength; i++){
currentWord = array[i].length;
nextWord = array[i+1].length;

}

return largest;
}

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

bitgrower
@bitgrower
Feb 11 2016 04:49
str[0] = 'f' str1 = 'o' str2 = 'x' .... str3 ==== ???????
blah...
Jason
@jpr00
Feb 11 2016 04:50
function lookUp(firstName, prop){ // Only change code below this line var name = ""; var value = ""; for (var i = 0; i < contacts.length; i++) { if (firstName === contacts[i]["firstName"]) { name = contacts[i]["firstName"]; if (contacts[i][prop]) { value = contacts[i][prop]; } } } if (name === "") { value = "No such contact"; } if (value === "") { value = "No such property"; } return value; // Only change code above this line }
Jason
@carpediem1213
Feb 11 2016 04:50
I am hitting enter too soon. Can you read that? @bitgrower @dcnr
bitgrower
@bitgrower
Feb 11 2016 04:50
yes ... more or less ...
but, what I say still stands ... let me try again ...
Jason
@carpediem1213
Feb 11 2016 04:51
I can't seem to get the length for the current word in the loop after I split the array. I thought array[i].length would do the trick
bitgrower
@bitgrower
Feb 11 2016 04:51
str = 'fox';
str[0] = ?   /// 'f'
str[1] = ? /// 'o'
str[2] = ? /// 'x'
str[3] = ?  /// undefined
does that help ?
Norman Dela Cruz
@dcnr
Feb 11 2016 04:52
@carpediem1213 you can always modify your post hover over the right of the timestamp and click the ...
Jason
@carpediem1213
Feb 11 2016 04:52
@bitgrower are you sure? when I print out array[i} i get each word on a separate line
bitgrower
@bitgrower
Feb 11 2016 04:52
@carpediem1213 -- I am using a separate code example ...
Jason
@carpediem1213
Feb 11 2016 04:53
@bitgrower oh, I see. So it's undefined when I run out of bounds?
bitgrower
@bitgrower
Feb 11 2016 04:53
I'm trying to show you how a string of length 3 looks like and is referenced ...
YES !!!!
Jason
@carpediem1213
Feb 11 2016 04:53
str.length + 1 doesn't do the trick for the loop?
Norman Dela Cruz
@dcnr
Feb 11 2016 04:53
@carpediem1213 aah I see I think you're overcomplicating this. How about setting a "tally" variable. You each examine the words, and compare it to your tally, and if it's longer, than that's the new record!
bitgrower
@bitgrower
Feb 11 2016 04:53
just the opposite ...
str.length + 1 = 4 ...
now you are going to reference 2 elements beyond the end of your string ...
Jason
@carpediem1213
Feb 11 2016 04:55
@bitgrower so str.length - 1? @dcnr Examining the word length is where i am running into trouble
bitgrower
@bitgrower
Feb 11 2016 04:55
well, actually, what you need to do is use i < str.length in your for loop instead of i <= str.length
Norman Dela Cruz
@dcnr
Feb 11 2016 04:56
@bitgrower @carpediem1213 you actually need to use i < array.length xD
bitgrower
@bitgrower
Feb 11 2016 04:56
you don't need to do anything other than reference the value of str.length ... so there's no real reason to create another variable to hold the value ...
Norman Dela Cruz
@dcnr
Feb 11 2016 04:57
@carpediem1213 @bitgrower your array = str.split(" ") is your array of words, that's the one you want to loop over
bitgrower
@bitgrower
Feb 11 2016 04:57
yes -- sorry ... in his code, correct ... :) ...
@jpr00 -- can you post your code in like this
explain format
CamperBot
@camperbot
Feb 11 2016 04:58

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Norman Dela Cruz
@dcnr
Feb 11 2016 04:59
@carpediem1213 here, let's clean it up a little
function findLongestWord(str) {
  largest = 0;
  words_array = str.split(" ");

  for (var i = 0; i < words_array.legnth; i++) {

  }

  return largest;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Marek Slabicki
@thaniri
Feb 11 2016 04:59
function largestOfFour(arr) {

  var holderArray = [];

    for(i = 0; i < arr.length; i++){
        arr[i] = arr[i].sort(function(x,y){
          return y-x; // sorts sub-arrays from highest to lowest
        });
        holderArray.push(arr[i].slice(0,1)); //slices off the trailing elements from the sub arrays
    }
 return holderArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Can anyone help me get my return result in one array and not nested arrays?
my result is [5,[27],[39],[1001]]
[[5], **
Norman Dela Cruz
@dcnr
Feb 11 2016 05:00
@thaniri .slice will give always return an array
bitgrower
@bitgrower
Feb 11 2016 05:00
LOL ... thank you @dcnr ...
CamperBot
@camperbot
Feb 11 2016 05:00
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave dcnr points
Norman Dela Cruz
@dcnr
Feb 11 2016 05:00
@thaniri in this case you can just holderArray.push(arr[i][0]) since you ALWAYS wanted the first one
Marek Slabicki
@thaniri
Feb 11 2016 05:01
ah, im stupid
thanks @dcnr
CamperBot
@camperbot
Feb 11 2016 05:01
thaniri sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 595 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 11 2016 05:01
too fast @dcnr, @thaniri ... LOL ... you're not stupid ... but software IS humbling ...
Matt
@mattbag
Feb 11 2016 05:01
truncate a string, I don't get how much I should slice it.
Norman Dela Cruz
@dcnr
Feb 11 2016 05:02
@thaniri no you're not! stupidity is refusing to acknowledge your shortcomings :D
Matt
@mattbag
Feb 11 2016 05:02
help truncate
CamperBot
@camperbot
Feb 11 2016 05:02

:point_right: algorithm truncate a string [wiki]

Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

:pencil: read more about algorithm truncate a string on the FCC Wiki

Jason
@carpediem1213
Feb 11 2016 05:02
@bitgrower @dcnr Thanks! I'm going to work on this from here. :)
CamperBot
@camperbot
Feb 11 2016 05:02
carpediem1213 sends brownie points to @bitgrower and @dcnr :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 11 2016 05:02
@mattbag -- if you are having problems with just some of the test cases, you need to re-read the instructions ...
CamperBot
@camperbot
Feb 11 2016 05:02
:star: 596 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 448 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 11 2016 05:02
(on that particular exercise ... )
Marek Slabicki
@thaniri
Feb 11 2016 05:02
from dictionary.reference.com :"lacking ordinary quickness and keenness of mind; dull." :P don't worry, i'll try to unstupid myself
Matt
@mattbag
Feb 11 2016 05:02
well I did ;)
bitgrower
@bitgrower
Feb 11 2016 05:03
so post your code ... :)
Norman Dela Cruz
@dcnr
Feb 11 2016 05:03
@carpediem1213 oh hey watch out I had a typo i < words_array.legnth LOL
Matt
@mattbag
Feb 11 2016 05:03
code works, but does not slice in the right spot, i set the middle so far
bitgrower
@bitgrower
Feb 11 2016 05:03
I do know there's a bit of trickery in the way the instructions are written, and it's not exactly what you expect ...
Norman Dela Cruz
@dcnr
Feb 11 2016 05:03
@thaniri I was trying hard to be philosophical :P good luck though! I like your solution
@thaniri though not the functions in the loop part
bitgrower
@bitgrower
Feb 11 2016 05:04
well ... any advise is otherwise shooting in the dark , @mattbag -- gotta see some code ...
Matt
@mattbag
Feb 11 2016 05:04
This message was deleted
miss...
function truncate(str, num) {
  // Clear out that junk in your trunk
  var lengthy = str.length;
  if (lengthy > num){
    var half = str.slice(0, (lengthy/2));
    return half+ "...";
  }
Norman Dela Cruz
@dcnr
Feb 11 2016 05:06
BRB have to eat, I'm famished
Matt
@mattbag
Feb 11 2016 05:07
i guess i am supposed to truncate at num, considering the '...'
@dcnr enjoy!
lpix
@lpix
Feb 11 2016 05:08

Soo...I am getting a weird result and I don't know why

function largestOfFour(arr) {
  // You can do this!
  var array = [];
  var count = 0;
  for (var i = 0; i<arr.length; i++){
    for (var j =0; j<arr[i].length;j++){
       if(arr[i][j]>count){
         count = arr[i][j];
       }

    }array.push(count);

  }
  return array;
}

this returns 5,27,39,1001 when it should be 27,5,39,1001 based on the order of the tested array

any ideas?
bitgrower
@bitgrower
Feb 11 2016 05:08
can you provide the function call ?
lpix
@lpix
Feb 11 2016 05:09
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])
bitgrower
@bitgrower
Feb 11 2016 05:10
I don't see how you can get the right answer at all, tbh ...
ahh ... nvm ... now I do ...
lpix
@lpix
Feb 11 2016 05:10
O.O
oh
Matt
@mattbag
Feb 11 2016 05:10
push()?
lpix
@lpix
Feb 11 2016 05:11
it should be going through the array in order and pushing in order
bitgrower
@bitgrower
Feb 11 2016 05:11
yeah, that looks suspicous, @mattbag
when are you pushing the value, @lpix ?
Matt
@mattbag
Feb 11 2016 05:12
i did it this morning and I don't recall exactly the instructions, I don't remember any push...
bitgrower
@bitgrower
Feb 11 2016 05:12
it's one way of doing it, @mattbag -- you do have to return an array ...
lpix
@lpix
Feb 11 2016 05:12
after the loop that checks the largest number in the sub array
Matt
@mattbag
Feb 11 2016 05:12
ok i guess i did slightly different
bitgrower
@bitgrower
Feb 11 2016 05:12
check where it's happening in your loop ...
so did I @mattbag ...
I still don't know how you are quite getting the results that you are getting, though ...
Matt
@mattbag
Feb 11 2016 05:14
yeah that part was the same for me if i recall
testing every number to be higher than the previous one
lpix
@lpix
Feb 11 2016 05:14
largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) returns [9, 35, 97, 1000000]
bitgrower
@bitgrower
Feb 11 2016 05:14
so @lpix -- you have to find the largest in EACH subarray ... right now you aren't ..
Matt
@mattbag
Feb 11 2016 05:14
keep the highest... then...
lpix
@lpix
Feb 11 2016 05:15
it works with one but not the other
bitgrower
@bitgrower
Feb 11 2016 05:15
you have some of the parts perfect, but some others not quite so much ... :)
lpix
@lpix
Feb 11 2016 05:16
hmm...I'm guessing it's with the push() part
bitgrower
@bitgrower
Feb 11 2016 05:16
This message was deleted
This message was deleted
lpix
@lpix
Feb 11 2016 05:17
"a couple of issues"?
brb
Matt
@mattbag
Feb 11 2016 05:17
if everything white on your block? that's a huge hint for me when I debug
bitgrower
@bitgrower
Feb 11 2016 05:18
I think mainly one ..
LOL ... don't understand that one, @mattbag
Matt
@mattbag
Feb 11 2016 05:18
when you misplace something, or misspell, the word stays white, otherwise it is colored
bitgrower
@bitgrower
Feb 11 2016 05:19
ahhh ...
Matt
@mattbag
Feb 11 2016 05:19
i do a lot of misspelling
I solved mine btw I'll check the next one
bitgrower
@bitgrower
Feb 11 2016 05:20
I'm probably going about this the wrong way, I'm trying to figure out how he's getting the results he's getting ...
@lpix ... I think if you move just one line you'll be alright ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 11 2016 05:21
I am having problems with broken api if there is space(s) in the search text. If only one word, then it works fine..but I believe there is a way to make this work right…in a simple way...http://codepen.io/pkshreeman/pen/yeEorX
HARISH PANDAMANENI
@harish436
Feb 11 2016 05:21

// Setup
function abTest(a, b) {
// Only change code below this line
console.log(a<0, b<0);
return undefined;

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

lpix
@lpix
Feb 11 2016 05:22
@bitgrower I tried that and it plain out doesn't work
@mattbag I checked for misspellings and no..
function largestOfFour(arr) {
  // You can do this!
  var array = [];
  var count = 0;
  for (var i = 0; i<arr.length; i++){
    //go through array once
    for (var j =0; j<arr[i].length;j++){
      //loop to check largest num in sub array
       if(arr[i][j]>count){
         //is it larger?
         count = arr[i][j]; //store it
       }
    }array.push(count); //add largest number to an array

  }
  return array;
}
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:23
@harish436 try if(a<0 &&b<0) instead of console print
bitgrower
@bitgrower
Feb 11 2016 05:24
@lpix -- move your var count = 0 statement ...
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:24
@lpix you have to clear count in every row iteration
Kevin Myrick
@aphextwin234
Feb 11 2016 05:25
can someone help me out with a question
HARISH PANDAMANENI
@harish436
Feb 11 2016 05:25
@abhishekKumar1 ..
abTest(2,2) should return a number
abTest(2,2) should return 8
abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
abTest(2,8) should return 18
abTest(3,3) should return 12
lpix
@lpix
Feb 11 2016 05:25
yeeyy!!! that worked!! thanks @bitgrower @abhishekKumar1 @mattbag !!
CamperBot
@camperbot
Feb 11 2016 05:25
lpix sends brownie points to @bitgrower and @abhishekkumar1 and @mattbag :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 11 2016 05:25
@lpix -- basically, what @aphextwin234 said .. .
CamperBot
@camperbot
Feb 11 2016 05:25
:warning: could not find receiver for mattbag
:star: 319 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
:star: 449 | @bitgrower | http://www.freecodecamp.com/bitgrower
lpix
@lpix
Feb 11 2016 05:26
lolyou said it at the same time!
bitgrower
@bitgrower
Feb 11 2016 05:26
YAY !!!! Happy coding, @lpix -- I'm still puzzled at how you got the results that you did ...
Jason
@carpediem1213
Feb 11 2016 05:26
@bitgrower @dcnr did it! happy to report one local variable and only 3 lines in the for loop
bitgrower
@bitgrower
Feb 11 2016 05:26
YAY @carpediem1213 !!!
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:26
@harish436 it will return that after you change the consle.log statemnt to if statement
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:26
@abhishekKumar1 did u just copy me?
lpix
@lpix
Feb 11 2016 05:27
@bitgrower who knows lol
Norman Dela Cruz
@dcnr
Feb 11 2016 05:27
thanks @mattbag
@carpediem1213 show us! :D
CamperBot
@camperbot
Feb 11 2016 05:27
dcnr sends brownie points to @mattbag and @carpediem1213 :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 11 2016 05:27
really nice going, @carpediem1213 ... ...
CamperBot
@camperbot
Feb 11 2016 05:27
:warning: could not find receiver for mattbag
:star: 253 | @carpediem1213 | http://www.freecodecamp.com/carpediem1213
Ben Codrington
@bencodrington
Feb 11 2016 05:27
Hey, so I'm trying to use the array filter method here, to filter out the values in the first argument that appear in subsequent arguments, but I can't figure out how to pass the arguments to the callback function... any help is appreciated!

function checker(value, index, array) {
for (var i = 1; i < array.length; i++) {
if (value == array[i]) {
return false;
}
return true;
}
}

function destroyer(arr) {
arr.filter(checker());

return arr;
}

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

Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:27
@abhisekp ???
Jason
@carpediem1213
Feb 11 2016 05:27
function findLongestWord(str) {
  var longest = 0;
  words_array = str.split(" ");

  for (var i = 0; i < words_array.length; i++){
    var currentWordLength = words_array[i].length; 
    if (currentWordLength >= longest) {
    longest = currentWordLength;
    }
  }

  return longest;
}
Norman Dela Cruz
@dcnr
Feb 11 2016 05:28
@carpediem1213 NICE! :D
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:28
@abhishekKumar1 i'm the ONE
bitgrower
@bitgrower
Feb 11 2016 05:28
afraid I'm not very good with recursion, @bencodrington , and I don't think you need to use it to solve seek & destroy ...
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:28
@carpediem1213 what's the problem?
Jason
@carpediem1213
Feb 11 2016 05:28
@dcnr @bitgrower thanks!
CamperBot
@camperbot
Feb 11 2016 05:28
carpediem1213 sends brownie points to @dcnr and @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: carpediem1213 already gave bitgrower points
:warning: carpediem1213 already gave dcnr points
lpix
@lpix
Feb 11 2016 05:28
you are catching up to me @carpediem1213 :+1:
bitgrower
@bitgrower
Feb 11 2016 05:29
@abhishekKumar1 -- there is no problem -- he's showing off !!!
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:29
@abhisekp ypu are the one what???
@bitgrower hahaha
Jason
@carpediem1213
Feb 11 2016 05:29
@abhishekKumar1 no problem I'm just over-complicating things. I had 4 variables and else statements before lol
Ben Codrington
@bencodrington
Feb 11 2016 05:29
@bitgrower ...didn't mean to use recursion anywhere, did I?
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:29
@abhishekKumar1 I'm the Original ONE. You're DUPLICATE
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:30
@abhisekp oh nice for you then. :smile:
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:30
@abhishekKumar1 it's an aftereffect of watching Supergirl S01E12 :P
bitgrower
@bitgrower
Feb 11 2016 05:30
oh ... sorry ... you're right ... can you try formatting ...
explain format
CamperBot
@camperbot
Feb 11 2016 05:30

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Norman Dela Cruz
@dcnr
Feb 11 2016 05:30
@carpediem1213 now do it with .reduce() for bonus points! :D
Sarah
@gingersnapp
Feb 11 2016 05:30
anyone want to give some help for Confirm the ending?
bitgrower
@bitgrower
Feb 11 2016 05:31
hahahahahaha ... @dcnr -- give the man an opportunity to bask in his success !!!
sure, @gingersnap ...
Sarah
@gingersnapp
Feb 11 2016 05:31
cool @bitgrower
Ben Codrington
@bencodrington
Feb 11 2016 05:31
function checker(value, index, array) {
  for (var i = 1; i < array.length; i++) {
    if (value == array[i]) {
      return false;
    }
    return true;
  }
}

function destroyer(arr) {
  arr.filter(checker());

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
bitgrower
@bitgrower
Feb 11 2016 05:31
ahhh thank you !!! much better ...
Ben Codrington
@bencodrington
Feb 11 2016 05:32
@bitgrower sorry about that, forgot about the whole formatting thing
Jason
@carpediem1213
Feb 11 2016 05:32
@bitgrower @dcnr Ha!
Sarah
@gingersnapp
Feb 11 2016 05:32
function end(str, target) {
  var substringStr = str.substr(str.length-1);
  Boolean (substringStr == target);

}
Jason
@carpediem1213
Feb 11 2016 05:32
maybe I will try .reduce that allows me to do a certain thing to each object in the array, right?
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:32
@bencodrington you are not passing any arguments in checker function except the array
Sarah
@gingersnapp
Feb 11 2016 05:32
this is what i have so far but it only works with single word strings and not full sentences
Ben Codrington
@bencodrington
Feb 11 2016 05:33
@abhishekKumar1 I get a TypeError if I try and pass any arguments into the callback function
bitgrower
@bitgrower
Feb 11 2016 05:33
@carpediem1213 -- it's a boildown function ... it takes what you give it and tries (?) /does (?) return one value from everything in the array you hand it ...
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:33
@carpediem1213 use Math.max
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:33
@bencodrington use arguments[]
Jason
@carpediem1213
Feb 11 2016 05:33
Math.max?
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:34
help arguments
CamperBot
@camperbot
Feb 11 2016 05:34

:point_right: algorithm arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the sum.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More are ignored.
  • If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.

:pencil: read more about algorithm arguments optional on the FCC Wiki

bitgrower
@bitgrower
Feb 11 2016 05:34
yeah ... that's the super cool way to do it ... with Math.max
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:34
@carpediem1213 yeah! math.max, then map the array to length of each word after splitting it at space
Jason
@carpediem1213
Feb 11 2016 05:35
I am basking in the glory of my for loop
Matt
@mattbag
Feb 11 2016 05:35
help chunky monkey
CamperBot
@camperbot
Feb 11 2016 05:35

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:35
that monkey :monkey:
bitgrower
@bitgrower
Feb 11 2016 05:36
@bencodrington Seek and Destroy is not an easy problem ... one of the things I recommend you do is read the Arguments Object MDN page ... because I suspect you think arr contains all the arguments, and it doesn't ...
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:36
help no repeats please
CamperBot
@camperbot
Feb 11 2016 05:36
no wiki entry for: no repeat please
Abhishek Kumar
@abhishekKumar1
Feb 11 2016 05:36
help no repeats please
CamperBot
@camperbot
Feb 11 2016 05:36

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 11 2016 05:37
@bitgrower @carpediem1213
Never stop! As I always say think of it as
Exp [|||||||||----------------] to Next Level
bitgrower
@bitgrower
Feb 11 2016 05:38
ugh, sorry, not following @dcnr
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:38
@bencodrington use spread operator for seek and destroy
Ben Codrington
@bencodrington
Feb 11 2016 05:38
@bitgrower @abhishekKumar1 @abhisekp
oops
hehe
bitgrower
@bitgrower
Feb 11 2016 05:38
This message was deleted
Ben Codrington
@bencodrington
Feb 11 2016 05:38
I figured it out by realizing you can put a function right into the arr.filter() call
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:38
@bencodrington using spread operator rest param with 2 formal params makes it way easier along with the filter :+1:
Norman Dela Cruz
@dcnr
Feb 11 2016 05:39
@bitgrower leveling up as a programmer :cry:
bitgrower
@bitgrower
Feb 11 2016 05:39
sweet, @bencodrington
yeah, I guess I'm missing the right context ... sorry ... @dcnr :(
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:41
@bitgrower JS only has functional context ;)
how can u miss that :P
bitgrower
@bitgrower
Feb 11 2016 05:41
dunno ...
Abhisek Pattnaik
@abhisekp
Feb 11 2016 05:41
one and only one :+1:
Ben Codrington
@bencodrington
Feb 11 2016 05:42
thanks @abhisekp @bitgrower :)
CamperBot
@camperbot
Feb 11 2016 05:42
bencodrington sends brownie points to @abhisekp and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 2069 | @abhisekp |