These are chat archives for FreeCodeCamp/Help

29th
Jun 2015
Jon Bodnar
@jmichb
Jun 29 2015 00:01

'''
function telephoneCheck(str) {
var check = str.match(/1?\s?(?\d{3})?\s?-?\d{3}-?\s?\d{4}/);

if (check === null || str !== check[0]) {
return false;
}
else {
return true;
}

}
'''

So this is less a request for help and more a request for feedback. If you've solved Validate US Telephone Numbers how did you do it? I struggled with it forever before coming up with the code above. Does anyone have a simpler solution?

ar2g
@ar2g
Jun 29 2015 00:05
@jmichb did that regex work?
Matthew Vogel
@matthewsvm
Jun 29 2015 00:05
Anyone have advice for fixing some issues with my “Arguments Optional” bonfire?
Jon Bodnar
@jmichb
Jun 29 2015 00:05
@ar2g Yeah. It works, as far as passing the bonfire.
Matthew Vogel
@matthewsvm
Jun 29 2015 00:06
function add() {

  function sum2And(num) {
    return add(args[0], num);
  }

  var args = arguments;
  if (arguments.length === 1) {
    return sum2And(3);
  }

  if (isNaN(args[0] + args[1])){
    return undefined; 
  }

  if (args[0] !== Number(args[0]) || args[1] !== Number(args[1])) {
    return undefined;
  }

  return args[0] + args[1];
}

add(2);
Jon Bodnar
@jmichb
Jun 29 2015 00:06
@ar2g I hate to say it but that was like 4 hours of my life there on taht stupid thing. I don’t knwo why but my brain just wouldn’t do it.
ar2g
@ar2g
Jun 29 2015 00:07
@jmichb it took me a while too - but I had an array of regex to handle each format and then foreach'd through them
Jon Bodnar
@jmichb
Jun 29 2015 00:08
Okay. I think I understand. So you checked string against each memer of your array, right?
ar2g
@ar2g
Jun 29 2015 00:09
@jmichb yep... regex101 doesn't validate /1?\s?(?\d{3})?\s?-?\d{3}-?\s?\d{4}/
Jon Bodnar
@jmichb
Jun 29 2015 00:10
What do you mean?
ar2g
@ar2g
Jun 29 2015 00:11
@jmichb but to answer your question yeah it was [/regex1/, /regex2/,...]
@jmichb and then tests.forEach(//do the check);
I mean that I was interested in trying your regex one liner but https://regex101.com/ said it wasn't valid - probably a typo
Jon Bodnar
@jmichb
Jun 29 2015 00:13
Perhaps you’d need to escape the opening and closing ‘(‘. I’ll check it. It worked for the bonfirel though. I’ll look at regex101.com now.
ar2g
@ar2g
Jun 29 2015 00:13
cool
I'm new to regex so would be interested in a one liner for that bonfire
Jon Bodnar
@jmichb
Jun 29 2015 00:14
I’d not seen regex101.com. Awesome!
ar2g
@ar2g
Jun 29 2015 00:14
it is pretty cool
yup escaping the parentheses means it validates
props to you, awesome regex skills
@jmichb you could get rid of the if statement
Jon Bodnar
@jmichb
Jun 29 2015 00:18
@ar2g I don’t know I’d say ‘skill’. I’d say willingness to sit and stare at the computer and pull my hair out for 4 hours.
ar2g
@ar2g
Jun 29 2015 00:19
function telephoneCheck(str) {
  var check = str.match(/1?\s?\(?\d{3}\)?\s?-?\d{3}-?\s?\d{4}/);
  return  (check === null || str !== check[0]);
}
Jon Bodnar
@jmichb
Jun 29 2015 00:19
@ar2g Awesome!!
Much better.
Thanks. Signing off now. Later.
ar2g
@ar2g
Jun 29 2015 00:19
@jmichb cheers, g'night!
rtrom
@rtrom
Jun 29 2015 00:33
Really having a hard time with the Bonfire: Return the Largest number in arrays exercise. Did I miss some key reading or exercises that needed to be done? Here's my code based on reading of the documentation and SO, but I could just some other eyes and suggestions:
function largestOfFour(arr) {
  // You can do this!
  var finalArray = []; 
    for (var i = 0, i < largestOfFour.length, i++) {
      if (largestOfFour[i].subarray[i] > largestOfFour[i-1].subarray[i-1]) {
    finalArray.push(largestofFour[i].subarray[i]);
      }
    }
  return finalArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
*could use
Rasheed Bustamam
@abustamam
Jun 29 2015 00:35
what does it return?
rtrom
@rtrom
Jun 29 2015 00:36
"Unexpected token <"
Rasheed Bustamam
@abustamam
Jun 29 2015 00:36
from what I can see, you're iterating through an array called largestOfFour
which doesn't exist
remember, largest of four is the function name... what's the argument?
rtrom
@rtrom
Jun 29 2015 00:39
I believe it should be (arr)
Rasheed Bustamam
@abustamam
Jun 29 2015 00:40
yes
so how would your code look , using arr?
rtrom
@rtrom
Jun 29 2015 00:41
function largestOfFour(arr) {
    var finalArray = []; 
    for (var i = 0, i < largestOfFour.length, i++) {
      if (arr[i].subarray[i] > arr[i-1].subarray[i-1]) {
    finalArray.push(arr[i].subarray[i]);
      }
    }
  return finalArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Correct?
Rasheed Bustamam
@abustamam
Jun 29 2015 00:42
you still have largestOfFour.length
rtrom
@rtrom
Jun 29 2015 00:43
Oops; fixed
function largestOfFour(arr) {
    var finalArray = []; 
    for (var i = 0, i < arr.length, i++) {
      if (arr[i].subarray[i] > arr[i-1].subarray[i-1]) {
    finalArray.push(arr[i].subarray[i]);
      }
    }
  return finalArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Rasheed Bustamam
@abustamam
Jun 29 2015 00:44
ok
now we're getting closer
let's look at your forloop
what does your program do in your for loop?
rtrom
@rtrom
Jun 29 2015 00:46
What I am trying to accomplish is to cycle through the numbers in the subsets, and take the highest number in the subset, and place it into a new array
Rasheed Bustamam
@abustamam
Jun 29 2015 00:56
yes
Mario Mitchell
@undergroundfx
Jun 29 2015 00:56
Trying to figure out why my Pomodoro Clock won't work in Firefox and Safari
Rasheed Bustamam
@abustamam
Jun 29 2015 00:57
so can you explain to me what your code does @rtrom ?
let's step through one-by-one
first step of for-loop: i = 0
what does your code do at the first step?
@undergroundfx looks find for me in Firefox
rtrom
@rtrom
Jun 29 2015 01:00

@abustamam
What I am trying to accomplish is to cycle through the numbers in the subsets, and take the highest number in the subset, and place it into a new array.

I am assigning the value of 0 to the variable 'i'.

Rasheed Bustamam
@abustamam
Jun 29 2015 01:01
yes
Mario Mitchell
@undergroundfx
Jun 29 2015 01:01
thanks @abustamam
Rasheed Bustamam
@abustamam
Jun 29 2015 01:01
 var finalArray = []; 
    for (var i = 0, i < arr.length, i++) {
      if (arr[i].subarray[i] > arr[i-1].subarray[i-1]) {
    finalArray.push(arr[i].subarray[i]);
      }
    }
  return finalArray;
so at i = 0, here's the code that runs:
if (arr[0].subarray[0] > arr[-1].subarray[-1]) {
  finalArray.push(arr[0].subarray[0]);
}
does that help you get the highest number in the subset?
rtrom
@rtrom
Jun 29 2015 01:06
I would believe so...but maybe only for the first subset? After that, it seems that on the second subset, it would ignore what is at position [0]...but I am not confident in that answers at all.
Rasheed Bustamam
@abustamam
Jun 29 2015 01:08
OK, let's go a bit deeper...
given that arr = [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]
what is arr[0]?
rtrom
@rtrom
Jun 29 2015 01:09
[4, 5, 1, 3]
Rasheed Bustamam
@abustamam
Jun 29 2015 01:09
ok, what would arr[0].subarray[0] be?
rtrom
@rtrom
Jun 29 2015 01:09
[4]
Rasheed Bustamam
@abustamam
Jun 29 2015 01:09
actually, it would return an error
if you want 4, the syntax would be arr[0][0]
since arr[0] return [4,5,1,3] , so the second zero references the 0th element in the array
Grace
@dogbot101
Jun 29 2015 01:11
Not sure if this helps... arr is a set of arrays within an array
rtrom
@rtrom
Jun 29 2015 01:13
@abustamam I see...makes sense why it would error out then; knowing that. I wonder if it would be more efficient if I could sort the subarrays...
Rasheed Bustamam
@abustamam
Jun 29 2015 01:14
absolutely it would; if each subarray were sorted, then you could just pick the last element of each array
however, first you'd have to sort, and that's the tricky part
rtrom
@rtrom
Jun 29 2015 01:17
Ok. Well, I was thinking (still don't know the syntax well) but something along the lines of using the sort() method, and then slice() the element and place it in a new array?
Rasheed Bustamam
@abustamam
Jun 29 2015 01:20
that's a bit complicated
I liked your first method better, iterate through each array, and push the highest element of each array to the finalArray
so let's work on a lower level. how would you get the maximum of a regular array, lets say, [4,5,1,3]
write some code that will do that
rtrom
@rtrom
Jun 29 2015 01:28
var array = [4, 5, 1, 3];
array.max = function( array ){
    return Math.max.apply( Math, array );
};
Rasheed Bustamam
@abustamam
Jun 29 2015 01:28
Haha, kinda cheating, but that works
I think, i'm not sure what array.max would do though
rtrom
@rtrom
Jun 29 2015 01:29
I originally read about that on SO when I started, but I tossed it to the side, thinking it wouldn't be relevant
Rasheed Bustamam
@abustamam
Jun 29 2015 01:29
oh
um
rtrom
@rtrom
Jun 29 2015 01:30
I was unsure how it would apply to the problem, that is, until you asked me.
Rasheed Bustamam
@abustamam
Jun 29 2015 01:30
it doesn't work
Lightwaves
@Lightwaves
Jun 29 2015 01:30
why Math, array
it might be Math.max.apply(null, array)
Rasheed Bustamam
@abustamam
Jun 29 2015 01:30
keep in mind you can play with the javascript console in your browser
Lightwaves
@Lightwaves
Jun 29 2015 01:30
even I'm not completely sure that code works the way it's written but I know what it's supposed to do.
Rasheed Bustamam
@abustamam
Jun 29 2015 01:31
i keep getting -Inifity
let's keep abstractions out of this
so we have the following code:

var array = [4,5,1,3];
// insert a relevant variable here
for (var i = 0; i < array.length; i++) {
  // complete this
}
Iterate through each of the elements of the array, and lets see if you can determine find the largest value
rtrom
@rtrom
Jun 29 2015 01:40
As a side note; note sure how to check JS in the console. Here's my best guess:
var array = [4, 5, 1, 3]
var bigNumber = 0
for (var i = 0; i < array.length; i++) {
      if (array[i].length > bigNumber) {
          bigNumber = array[i].length;
          }
       }
return bigNumber;
*not
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 01:42
@rtrom you can test your code here < repl.it > and select javascript
Rasheed Bustamam
@abustamam
Jun 29 2015 01:43
you're close @rtrom !
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 01:43
or just use cmd+option+j for mac, and i think ctrl+j for windows(not sure)
Rasheed Bustamam
@abustamam
Jun 29 2015 01:44
it's cmd + option + k for firefox on mac (i use both browsers and the hotkeys are different >.<)
but okay, remember that array[0] = 4... what would array[0].length be?
rtrom
@rtrom
Jun 29 2015 01:46
It would be unnecessary; I shouldn't have put that in there
Rasheed Bustamam
@abustamam
Jun 29 2015 01:48
right
so now you can get the maximm value of one array
how would you use that same method to get the maximum value of each array ?
Adam Rehard
@adamrehard
Jun 29 2015 01:52
Does anybody have a reccomended style guide for HTML/CSS/JS?
rtrom
@rtrom
Jun 29 2015 01:53
Not entirely sure, as when I check that code it says an illegal return statement; but I would assume it would be something along the lines of:
array[i][i] > bigNumber
@rtrom getting there
Adam Rehard
@adamrehard
Jun 29 2015 01:55
Damn. Thanks!
Rasheed Bustamam
@abustamam
Jun 29 2015 01:55
no prob!
can you paste your entire code?
rtrom
@rtrom
Jun 29 2015 01:58
var array = [(4, 5, 1, 3), (23, 42, 57, 61)]
var bigNumber = 0
for (var i = 0; i < array[i]; i++) {
      if (array[i][i] > bigNumber) {
          bigNumber = array[i][i];
          }
          return bigNumber;
                }
Rasheed Bustamam
@abustamam
Jun 29 2015 02:03
ok, you're getting closer
a few things
line 1: you have an array, but within your array you have non-arrays
they should be in square brackets [] not round ()
line 3: for (var i = 0; i < array[i]; i++)
can you see what issue can arise from here?
Moisés Man
@moigithub
Jun 29 2015 02:05

any1 doin npm tutorial ??

rtrom
@rtrom
Jun 29 2015 02:06
It will only iterate between the two subarrays, not the values actually in them?
Brett Guillory
@kurzninja
Jun 29 2015 02:07
Can anyone tell me what I'm doing wrong in this functional programming exercise #20? I'm struggling to understand these concepts. I don't want to paste the code here as it's rather long.
Rasheed Bustamam
@abustamam
Jun 29 2015 02:07
remember, what is array[i]?
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:07
@rtrom What are you trying to achieve? highest number in an array?
Rasheed Bustamam
@abustamam
Jun 29 2015 02:07
@kurzninja private message me that ones tough
Brett Guillory
@kurzninja
Jun 29 2015 02:07
thanks @abustamam
Ryan Malm
@Rybar
Jun 29 2015 02:08
Do you want to compare i to the array itself in your for loop, or some property of the array? Maybe something that indicates how many...
rtrom
@rtrom
Jun 29 2015 02:09
@abustamam array[i] is index position 0 at the start
Rasheed Bustamam
@abustamam
Jun 29 2015 02:09
yes, that's right, so array[0] would give you the first array
rtrom
@rtrom
Jun 29 2015 02:10
@andela-bfowotade I'm trying to wrap my head around the Bonfire: Return Largest Numbers in Arrays
Rasheed Bustamam
@abustamam
Jun 29 2015 02:10
so for i = 0, your for statement becomes...
for (var i = 0; i < [4,5,1,3]; i++)
since array[0] = 4,5,1,3
what do you want the condition for i to be?
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:11
oh! @rtrom have you tried using Math.max.apply? or you don’t want to try that?
rtrom
@rtrom
Jun 29 2015 02:13
@abustamam I'm not entirely sure of the question...is it that I need one variable, variable i, to relate to each index, and another variable to relate to the values inside each subarray?
@andela-bfowotade I was discouraged from using that
Rasheed Bustamam
@abustamam
Jun 29 2015 02:16
@andela-bfowotade I think it's really important he learns how to do the algorithm in his head
rather than using a helper function
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:17
Oh! well you are right @abustamam, however sometimes you may need to be familiar with a couple of helper functions that would be helpful in future, instead of writing long lines of code.
Rasheed Bustamam
@abustamam
Jun 29 2015 02:19
yes, i agree completely andela. But finding max value in an array is such a fundamental concept that you need to know how the helper function works... once you know how to do it yourself, you can spare yourself the work by using helper functions
Lightwaves
@Lightwaves
Jun 29 2015 02:20
@abustamam if you understand the methodology doing the algorithm using for loops isn't that bad
Rasheed Bustamam
@abustamam
Jun 29 2015 02:20
its like using calculators in math... anyone can do 123 * 234 in a calculator, but it's still important to know how to do it yourself
Lightwaves
@Lightwaves
Jun 29 2015 02:21
knowing a few math rules isn't bad for problems like that either
makes it so instead of doing it longhand you can do it in your head
Rasheed Bustamam
@abustamam
Jun 29 2015 02:22
i can't do that in my head... lol
Lightwaves
@Lightwaves
Jun 29 2015 02:22
it's possible just really annoying to keep track of the addition in my head
Rasheed Bustamam
@abustamam
Jun 29 2015 02:23
but i'm fine w/ using a calc to find the answer because while i can write it out, im just lazy
but point being, i think @rtrom should understand how to traverse an array, before using helper functions
@rtrom remember that when you traverse an array, the header is something liek .... for (var i = 0; i < array.length; i++)
rtrom
@rtrom
Jun 29 2015 02:24
@abustamam Right
Rasheed Bustamam
@abustamam
Jun 29 2015 02:24
so how would you traverse a nested array?
being that we have var array = [[4, 5, 1, 3], [23, 42, 57, 61]]
Adam Rehard
@adamrehard
Jun 29 2015 02:26
Saving mental energy isn't lazy. It's smart. Once you know how to do something and know the background, why waste time?
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:26
@adamrehard +1
rtrom
@rtrom
Jun 29 2015 02:27
That's where I am stuck; I don't know how to do it with the syntax. I believe that we would need to loop through a second variable that corresponds to the indexes inside of the nested array
Lightwaves
@Lightwaves
Jun 29 2015 02:27
yeah it's true, the point that @abustamam is making that if you don't know the background you need to learn the fundementals before working with higher level abstrtactions
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:27
however i do understand his point, which is a good one.
Lightwaves
@Lightwaves
Jun 29 2015 02:27
otherwise you won't have a clue what the abstractions are doing
Adam Rehard
@adamrehard
Jun 29 2015 02:29
@Lightwaves , you're right. Just saying that once you know the procedure, why bother doing it manually (unless you need to for an edge case) if it can be automated.
Rasheed Bustamam
@abustamam
Jun 29 2015 02:30
yep! i think we're all on different sides of the same coin.
Lightwaves
@Lightwaves
Jun 29 2015 02:30
haha were all agreeing with each other
Rasheed Bustamam
@abustamam
Jun 29 2015 02:30
@rtrom yes, you are correct! more specifically, you'll want a nested array
oops, nested for loop
var array = [[1,2,3,],[4,5,6]];

for (var i = 0; i < array.length; i++) {
  // we are on the first level of the outer array, index 0 being [1,2,3], index 2 being [4,5,6]
  for (var j = 0; j < array[0].length; j++) {
    // now we are inside the first array, indices being the numbers we want
  }

}
rtrom
@rtrom
Jun 29 2015 02:32
Aaahhh...makes perfect sense
Rasheed Bustamam
@abustamam
Jun 29 2015 02:33
Wonderful, now let's apply your newfound knowledge to the problem we're trying to solve
I know we're spending a lot of time on this one problem, and you're probably feeling frustrated, but it's worth the trouble when you finally get it , and understand why it's right
rtrom
@rtrom
Jun 29 2015 02:34
No I really appreciate it...I want to know the how and the why
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:35
@abustamam why aren’t you screenhero? or team viewer?
Rasheed Bustamam
@abustamam
Jun 29 2015 02:35
im turning screenhero on right now
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:36
okay would be better
Rasheed Bustamam
@abustamam
Jun 29 2015 02:36
i thought we were phasing out SH because soon it will be slack specific, but maybe i was mistaken
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:36
naaa, well let’s hope not.lol
Adam Rehard
@adamrehard
Jun 29 2015 02:37
It's closed to new signups at this time. Just tried to signup myself.
Sorry guys :(
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:38
@adamrehard what’s your email
i’d send you an invite
so you’d be able to download it
Rasheed Bustamam
@abustamam
Jun 29 2015 02:39
i just made an account just now
thats weird
anyway, someone add me! rasheed.bustamam@gmail.com
Babajide Fowotade
@andela-bfowotade
Jun 29 2015 02:40
okay
rtrom
@rtrom
Jun 29 2015 02:41
So, using the knowledge that slowly trickled into my thick skull, this is what I have thus far:
function largestOfFour(arr) {
    var finalArray = []; 
    for (var i = 0, i < arr.length, i++) {
        for (var j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > arr[i-1][j-1]) {
    finalArray.push(arr[i][j]);
      }
    }
    }
  return finalArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Rasheed Bustamam
@abustamam
Jun 29 2015 02:42
you are getting so much cloesr!
remember what we learned about finding the max
you start with an initial value, like 0
and then you compare each value in the array with the max value, updating it if the value is bigger
rtrom
@rtrom
Jun 29 2015 02:47

Right...I just am not sure if the line

 if (arr[i][j] > arr[i-1][j-1] {

Actually works in comparing the previous values

Rasheed Bustamam
@abustamam
Jun 29 2015 02:48
let's step through what happens at i=0,j=0, and then at i=0,j=0
if (arr[0][0] > arr[-1][-1]  //this is comparing two consecutive values together){
  finalArray.push(arr[0][0]
}
rtrom
@rtrom
Jun 29 2015 02:50
Well, arr[0][0] is 4, and arr [-1][-1] doesn't actually exist
in the array
Rasheed Bustamam
@abustamam
Jun 29 2015 02:55
right
and also, keep in mind that you'd only be comparing consecutive elemetns
not only that, but also elements from aa different array
[[1,2,][3,4]]
var a = [[1,2],[3,4]];

a[0][0] // gives 1;
a[1][1] // gives 4;
you only care about elements within a single array, so i shouldn't change within j
remember, i selects which array we look at, j selects an element from array i
Khaled Alba.
@ProgaPanda
Jun 29 2015 03:01
ok I'm stuck on Chunky Monkey

`function chunk(arr, size) {
var len = arr.length / size;
var final = [];
var k = 0;
for(i = 0; i<len; i++){
final[i] = new Array(size);
for(j = 0; j<size; i++){
final[i][j]= arr[k];
k++;
}
}
return final;
}

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

Rasheed Bustamam
@abustamam
Jun 29 2015 03:02
alright guys, I'm out
I hope I've been helpful, and please forgive me for any mistakes I may have made. Happy coding! :)
Khaled Alba.
@ProgaPanda
Jun 29 2015 03:02
function chunk(arr, size) {
  var len = arr.length / size;
  var final = [];
  var k = 0;
  for(i = 0; i<len; i++){
    final[i] = new Array(size);
    for(j = 0; j<size; i++){
      final[i][j]= arr[k];
      k++;
    }
  }
  return final;
}

chunk(['a', 'b', 'c', 'd'], 2);
I don't really know what's the problem :worried:
ronaldrdguez
@ronaldrdguez
Jun 29 2015 03:25
@ProgaPanda Inner for loop, should be j++
Khaled Alba.
@ProgaPanda
Jun 29 2015 03:27
@ronaldrdguez Thank You!
ronaldrdguez
@ronaldrdguez
Jun 29 2015 03:29
anytime
John Ellis
@johnmellis
Jun 29 2015 03:29

@johnmellis
Anyone know why this wouldn’t work?

var gulp = require('gulp'),
    uglify = require('gulp-uglify');

gulp.task('default',function(){
    gulp.src(['/public/js/*.js'])
        .pipe(uglify())
        .pipe(gulp.dest('./build'));
});

my javascript folder is public/js and has a file called hello.js
for some reason, it won’t create the ./build folder when ran
but it calls the task when running gulp

Jorge Ruvalcaba
@jorgeruvalcaba
Jun 29 2015 05:13
function palindrome(str) {
  // Good luck!

  var pal = str.replace(/[^\w+\s+$]/, str).toLowerCase();
  console.log(pal);

  var tmpPal = pal.split('').reverse('').join('');
  console.log(tmpPal);

  if(tmpPal === pal){
    return true;
  } else {
    return false;
  }
}



//palindrome("eye");
palindrome("race car");
Anybody know why this doesn’t work?
I’m on Bonfire Check for palindromes
David Wilbanks
@dwilbank68
Jun 29 2015 05:16
you didn't treat tmpPal exactly the same as pal
ie - toLowerCase...
the test results should give a clue as to what they expect and what they are getting instead
Stephen Wanhella
@1hella
Jun 29 2015 06:46
@jorgeruvalcaba If you’re still having trouble, the first place to look is at that Regex
Harshit Anand
@harshitanand
Jun 29 2015 08:22

@jorgeruvalcaba can be written this way

function palindrome(str) {
var len = str.length;
for ( var i = 0; i < Math.floor(len/2); i++ ) {
if (str[i] !== str[len - 1 - i]) {
return false;
}
}
return true;
}

Teejay Parker
@TeejayParker
Jun 29 2015 08:55
CSS question: To resize an image, how would I add the class to <img src='https://bit.ly/fcc-kittens'/> ?
Jack Hsieh
@Powiee
Jun 29 2015 08:57
The selector in css for class would be the dot. For example .someClass
Teejay Parker
@TeejayParker
Jun 29 2015 08:57
right.. i have .smaller-image {
width: 100px;
}
Jack Hsieh
@Powiee
Jun 29 2015 08:57
Then for the html you would have a attribute of class=''someClass"
Teejay Parker
@TeejayParker
Jun 29 2015 08:59
yeah, still no idea.. back to google! lol
Jack Hsieh
@Powiee
Jun 29 2015 09:00
An attribute would be like src.
So <img class="someClass" src= ... >
Teejay Parker
@TeejayParker
Jun 29 2015 09:01
hmm.. alright. Thank you @Powiee
Jack Hsieh
@Powiee
Jun 29 2015 09:05
@Majeye no problem
Mario Mitchell
@undergroundfx
Jun 29 2015 10:18
arrghh my Javascript Calculator that I spent the last few hours creating is working perfectly in js.bin and not doing anything or any errors in codepen? How is this, can someone take a look, thanks.
ohh I think I need to make codepen load the jquery duh..
Yes that fixed it
Mario Mitchell
@undergroundfx
Jun 29 2015 10:23
Passed the extra user cases on the calculator as well.
ar2g
@ar2g
Jun 29 2015 10:38
Morning, would anyone be able to help? I'm failing a couple of tests on arguments optional, principally because of the way I'm checking if an argument is numeric. What's the best way to do this in JS?
I'm currently using isNaN
Stephanie Morrison
@Stephaceae
Jun 29 2015 10:44
looks like a similar topic is being addressed in the FCC chat… not sure if they are exactly the same, as I’ve not progressed that far
Nur Azhar
@nurazhar
Jun 29 2015 10:52
Hey
ar2g
@ar2g
Jun 29 2015 11:19
thanks @Stephaceae I'll take a look
Lightwaves
@Lightwaves
Jun 29 2015 11:51
@ar2g look into isFinite
@ar2g and use both isNaN and isFinite
Jobin Idiculla
@jobini
Jun 29 2015 12:10
Hey everyone! :)
I'm working on "Waypoint: Change the Color of Text". I did manage to change the color of the text, but the "Go to my next challenge" button is still greyed out. Has anyone else faced this?
Placid Rodrigues
@placidrod
Jun 29 2015 12:13
Hi @jobini , what's your code?
Jobin Idiculla
@jobini
Jun 29 2015 12:14
@placidrod : Hey! <h2 style = "color:blue">CatPhotoApp</h2>
Placid Rodrigues
@placidrod
Jun 29 2015 12:16
@jobini , the color needs to be red.
Jobin Idiculla
@jobini
Jun 29 2015 12:17
Wow, that was so stupid of me! I don't even know why blue came into my mind! So sorry for the trouble!
@placidrod
Placid Rodrigues
@placidrod
Jun 29 2015 12:19
No, nothing stupid. Carry on !! @jobini
Desentso
@Desentso
Jun 29 2015 12:42
How can I check if something is number? IsNaN() function doesn't work because I don't want to include string only pure numbers
like IsNaN("3") returns false and I dont want to include strings containing numbers
ronaldrdguez
@ronaldrdguez
Jun 29 2015 12:50
@Desentso `typeof(x) === ‘number'
Desentso
@Desentso
Jun 29 2015 12:54
@ronaldrdguez ah nice, thank you !
ronaldrdguez
@ronaldrdguez
Jun 29 2015 12:54
@Desentso Be aware that not a number « is » a number, that is, the expression above will yield true for some x like 3/‘a’. It’s a pain.
Vos
@KrisVos130
Jun 29 2015 12:56
Could someone help me with a small problem on the Bonfire: Symmetric Difference?
I managed to do what it asks me to do, get an Array with the numbers they want... Just not in the right order. The 2nd, 3rd and 4th test are fine, but the 1st test requires my returned Array [3, 4, 5] to be [3, 5, 4].
ronaldrdguez
@ronaldrdguez
Jun 29 2015 13:00
@KrisVos130 Welcome to the club, I had the same problem and helped someone with also the exact same issue. Try to traverse the arrays top bottom/ left right. The grader is comparing arrays, not sets, and the order in which you build them matters.
Vos
@KrisVos130
Jun 29 2015 13:02
@ronaldrdguez I tried that, but when I do that I don't get why the 2nd test is [1, 4, 5] instead of [1, 5, 4]
ronaldrdguez
@ronaldrdguez
Jun 29 2015 13:09
@KrisVos130 paste your code?
Vos
@KrisVos130
Jun 29 2015 13:10

@ronaldrdguez

function sym(args) {
  var arrays = [];
  //var unsortedArray = [];
  var totalArrays = arguments.length;
  // Puts every array in 2 new arrays
  for (var i = 0; i < totalArrays; i++) {
    arrays.push(arguments[i]);
    //unsortedArray.push(arguments[i]);
  }
  // Sorts all arrays
  arrays = arrays.map(function(arr){
    return arr.sort();
  });
  // Removes duplicates
  arrays = arrays.map(function(arr){
    var unique = [];
    arr.map(function(n){
      if (unique.indexOf(n) < 0) {
        unique.push(n);
      }
    });
    return unique;
  });
  var differences = [];
  var allValues = [];
  // Makes one array with all values
  arrays.map(function(arr){
    allValues = allValues.concat(arr);
  });
  // Check if value is occuring twice
  allValues.map(function(n){
    if (allValues.join("").split(n).length - 1 !== 2) {
      if (differences.indexOf(n) < 0) {
        differences.push(n);
      }
    }
  });


  //differences = differences.sort();


  return differences;
}

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]);

The unsortedArrays thing is what I am currently trying to do with the traversing

ronaldrdguez
@ronaldrdguez
Jun 29 2015 13:19
@KrisVos130 Ill take a look at it, It doesn’t give the right answer. I’m getting [1, 5, 4] for that input, 5 shouldn’t be there.
kefzy
@kefzy
Jun 29 2015 13:21
hello people

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
</style>

<h2 class='red-text'>CatPhotoApp</h2>

<img src="https://bit.ly/fcc-kittens" width="100px"/>

<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

how do i make my img element have the class smaller-image?
i need help plz someone please help
blob
Robert Ozimek
@robertozimek
Jun 29 2015 13:26
@kefzy you need to add a smaller image class between <style> </style>
then just add the class to your image just like with the <p class=”red-text"> </p>
Vos
@KrisVos130
Jun 29 2015 13:28
@ronaldrdguez I managed to finally do it! Thanks for all of your help
ronaldrdguez
@ronaldrdguez
Jun 29 2015 13:30
@KrisVos130 no problem, anyway why the map to sort arrays? doesn’t seem to affect the result at all.
Robert Ozimek
@robertozimek
Jun 29 2015 13:33
@kefzy and actually your not suppose to set the width inside the html tag width but inside the smaller-image class
Vos
@KrisVos130
Jun 29 2015 13:34
@ronaldrdguez I think that was from an earlier attempt, I must have forgotten to remove it... But it was nice with debugging, having the arrays ordered so you can clearly see where a new array starts
Bill Zerega
@dedicatedfuture
Jun 29 2015 13:55
is my code popping up?
im trying to use the help button
can anyone help me with the bonfire" Convert HTML entities?
Vos
@KrisVos130
Jun 29 2015 14:20
@dedicatedfuture Yeah sure
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:20
woo thanks kris

function convert(str) {
// :)
for(var i = 0, newStr = ""; i<str.length; i++){
switch(str[i]){
case "<": newStr += '<'; break;
case ">": newStr += '&rt;'; break;
case "&": newStr += '&'; break;
case "'": newStr += 'a&#769;'; break;
default: newStr += str[i];
}

}

return newStr;
}

thats my code
not sure why its not working
one of the results says that it is not passing
but the output matches whats expected
Steven Leiva
@StevenXL
Jun 29 2015 14:21
Hi - can anyone help me implement the search feature in TwitchTV API?
I'm not even sure where to get started.
Anyone know of a good article I could take a look at?
Vos
@KrisVos130
Jun 29 2015 14:23
@dedicatedfuture I pasted in the code you put, and it is returning undefined, is that the error you are having as well?
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:23
no
im passing hte first 2 and last test
Vos
@KrisVos130
Jun 29 2015 14:25
Could you copy the whole code and put in in between 3 s above your code, and 3s under your code?
`*
That would look like this:
this is code, formatted
@dedicatedfuture
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:26

function convert(str) {
// :)
for(var i = 0, newStr = ""; i<str.length; i++){
switch(str[i]){
case "<": newStr += '<'; break;
case ">": newStr += '&rt;'; break;
case "&": newStr += '&'; break;
case "'": newStr += 'a&#769;'; break;
default: newStr += str[i];
}

}

return newStr;
}

convert('Dolce & Gabbana');

Vos
@KrisVos130
Jun 29 2015 14:27
@dedicatedfuture Good enough, thank you
@dedicatedfuture Your code only passes 1 test for me
@dedicatedfuture Maybe you can copy your text over to a pastebin? I think Gitter is messing with your code http://pastebin.com/
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:29
Vos
@KrisVos130
Jun 29 2015 14:30
@dedicatedfuture Okay, the first 2 tests and the last test are now passing
@dedicatedfuture One mistake is that you are saying > is &rt; while the escaped character code for > is >
& gt;
Vos
@KrisVos130
Jun 29 2015 14:35
@dedicatedfuture Also, you are setting ' to a&#769 instead of setting " to &quot;
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:36
ooo
thank you for those catches
Vos
@KrisVos130
Jun 29 2015 14:37
@dedicatedfuture No problem, if you fix those 2 things it should all work fine
Tom Sun
@tomsun100
Jun 29 2015 14:41
What's the formula for calculating orbital period?
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:41
im still not passing the 4th and 5th test
Miguel Correa
@miguelc1221
Jun 29 2015 14:41
anyone know why in Binary Agents Difficulty my code keeps coming out in like chinese?
function binaryAgent(str) {
  return String.fromCharCode.apply(null, str.split(" ")); 
}

binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111’);
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:41
the schindlars list thing
makes sense cuz i dont even know how to get that 'a character
Vos
@KrisVos130
Jun 29 2015 14:42
@dedicatedfuture Can you post a new pastebin?
Lightwaves
@Lightwaves
Jun 29 2015 14:43
@miguelc1221 you are dealing with binary what does charcode deal with for inputs?
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:44
Vos
@KrisVos130
Jun 29 2015 14:45
@dedicatedfuture The escaped character code for " is &quot;
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:45
ooo
Vos
@KrisVos130
Jun 29 2015 14:45
Not a&#769
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:45
getting closer
now all tests pass except for the schinlers list test
assert.strictEqual(convert("Shindler's List"), 'Shindler's List', 'should escape characters');should escape characters: expected 'Shindler\'s List' to equal 'Shindler's List'
Tom Sun
@tomsun100
Jun 29 2015 14:47
@KrisVos130 is a == avgAlt?
Vos
@KrisVos130
Jun 29 2015 14:48
@tomsun100 a === earthRadius + avgAlt
@tomsun100
Maybe this will help:
// T = 2 PI sqrt ((earthRadius+ avgAlt) ^ 3)/GM) );
// 2\pi\sqrt{a^3/\mu}
// 2 PI SQRT{((earthRadius + avgAlt) ^ 3/GM)}
It's a little bit easier
@dedicatedfuture Shindler\'s List has to be Shindler's List, so you are putting an extra \ somewhere most likely
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:51
i just tried to make a case for \ but it didnt work
Vos
@KrisVos130
Jun 29 2015 14:53
@dedicatedfuture Can you post your current code in a pastebin again?
Bill Zerega
@dedicatedfuture
Jun 29 2015 14:54
Tom Sun
@tomsun100
Jun 29 2015 14:54
@KrisVos130 do you mind critiquing my code
function orbitalPeriod(arr) {
  var resultArr = [];
  var GM = 398600.4418;
  var earthRadius = 6367.4447;

  function calculateT(alt){
    return 2 * Math.PI() * (Math.sqrt(Math.pow(alt+earthRadius, 3) / GM));
  }
  for(var i=0; i<arr.length; i++){
    resultArr.push({
      name: arr[i][name],
      orbitalPeriod: calculateT(arr[i][avgAlt])
    });
  }
  return resultArr;
}
I'm getting the problem that name is not defined
Vos
@KrisVos130
Jun 29 2015 15:01
@tomsun100 That's because you are not defining name anywhere
@tomsun100 Instead of having name: arr[i][name] you should have name: arr[i].name
And the same goes for the orbitalPeriod
@tomsun100 Also, Math.PI() should be Math.PI
Lightwaves
@Lightwaves
Jun 29 2015 15:23
question
function fearNotLetter(str) {
  str=str.split("");
  charrange = str.map (function(x){return x.charCodeAt();});
  missingletters = [];
  var len = charrange.length;
  for (var i = 0; i < len; i++ ){
    if(charrange[i]+1 !== charrange[i+1]){
      missingletters.push(charrange[i]);

    }  

  }
  return missingletters;

}

fearNotLetter('abce');
actually wait hold on
eh probably wouldn't work
Tom Sun
@tomsun100
Jun 29 2015 15:39
@KrisVos130 thanks it worked.
Lightwaves
@Lightwaves
Jun 29 2015 15:40
I think I got it but honestly I'd want to find all missing letters not just one so if I get this to work and someone has a more robust solution I'd love to see.
Vos
@KrisVos130
Jun 29 2015 15:42
@tomsun100 No problem, glad I could help :)
Lightwaves
@Lightwaves
Jun 29 2015 15:44
Got it
Lightwaves
@Lightwaves
Jun 29 2015 16:26
ouch! that's terrible.
Grace
@dogbot101
Jun 29 2015 17:26
Can anyone help explain obtaining the greatest common divisor using the Euclidean algorithm?
I'm getting confused at the next step after there is a remainder and you have to go through it again
Tom DeFrank
@TomDeFrank
Jun 29 2015 17:35
@dogbot101 while (array[i] % something != 0){ do stuff }
are you looping like that?
drd13
@drd13
Jun 29 2015 17:37

Hey so when I run my code for http://www.freecodecamp.com/challenges/bonfire-drop-it
In the left hand console it says my result is [3,4] but the tests register an array of [] do any of you know why that might be?

Here is my code if you want to check for yourselves

function drop(arr, func) {
  while (arr.some(func)){
    arr.splice(0,1);
  }
  console.log(arr);
  return arr;
}

drop([1, 2, 3, 4], function(n) {return n < 3; });
Grace
@dogbot101
Jun 29 2015 17:38
I'm actually experimenting with an if else statement, where if the remainder is zero, that would be the gcd
I've been reading that if the remainder is not zero, then you would switch the numbers and divide, I think, the second number by the remainder
drd13
@drd13
Jun 29 2015 17:42
@dogbot101 if you show the code maybe I can tell you where you have gone wrong
Grace
@dogbot101
Jun 29 2015 17:45
sure... it's a work in progress
function smallestCommons(arr) {
  //eucildean formula , LCM is X divided by Y. 
  // if x = product of two numbers, i.e. 1 and 5
  // if y = greatest common divisor of 1 and 5

  //for sorting array from smallest to largest
  function sortedArr(a, b) {
  return a - b;
  }
  //created array with low number through highest number 
 function settupArr(arr){
    var numArr = arr.sort(sortedArr); 
   for(i = arr[0]; i<= arr[1]; i++) {
    numArr.push(i);
    }
  }
  //function to find greatest common divisor or gcd
  function gcdfunction(a,b) {
    var gcd;
    //if number divides without a remainder, that is the gcd 
        if (b===0) {
      gcd = a;
      return gcd;     
    } else {
    // if there is a remainder, change the numbers passing through 
    // instead of a, it will be b, and instead of b it will be remainder a%b
      gcd = gcdfunction(b, a%b); 
      return gcd;
      }
  }

  function lcmbyeuclid(a,b) {
 return ((a*b)/ gcdfunction(a,b));} 


}


smallestCommons([1,5]);
drd13
@drd13
Jun 29 2015 17:55
eerm im not sure how to work it exactly with the euclidian algorithm but it seems that the euclidian algorithm is used to find the gcd of two numbers only (i might be wrong). While here you need to find the gcd of a list
Grace
@dogbot101
Jun 29 2015 17:56
yes, So lets see, my example is wrong it should read something like
//eucildean formula , LCM is X divided by Y.
// if x = product of two numbers, i.e. 30, 45
// if y = greatest common divisor of both numbers is 15
At first I tried using getting the LCM through prime factorialization, and realized it was taking a lot of steps...
drd13
@drd13
Jun 29 2015 18:02
prime factorilazation isn't actually that bad
because you can use your code for the sum of numbers and easily change it to the producty
This message was deleted
Grace
@dogbot101
Jun 29 2015 18:03
hmm
I'll have to try that next
drd13
@drd13
Jun 29 2015 18:04
you can see my code http://www.freecodecamp.com/drd13 if you want
Grace
@dogbot101
Jun 29 2015 18:07
Nice.. Not nearly as complicated as my original attempt at prime factorilazation.
oretib
@oretib
Jun 29 2015 18:21
hey, can some1 help me on Bonfire: Return Largest Numbers in Arrays?
Prathmesh Khedekar
@Optimus101
Jun 29 2015 18:21
@oretib yes what kind of help?
oretib
@oretib
Jun 29 2015 18:22
in the result i'm getting an array - [10000]
and it should be a number in a string
[ '9', '35', '97', [ 1000000 ] ]
in an array not string :)
Prathmesh Khedekar
@Optimus101
Jun 29 2015 18:23
can you paste your code here?
oretib
@oretib
Jun 29 2015 18:23

function largestOfFour(arr) {
var newArr = [];
for (i=0;i<arr.length;i++){
newArr[i] = [arr[i][0]];
for(j=0;j<arr[i].length;j++){
if (newArr[i] < arr[i][j]){
newArr[i] = arr[i][j].toString();
}
}
}
return newArr;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [10000, 1001, 857, 1]]);

any ideas?
@Optimus101 ?
Prathmesh Khedekar
@Optimus101
Jun 29 2015 18:28
going through it
pls w8
function largestOfFour(arr) {
var newArr = [];
for (i=0;i<arr.length;i++){
newArr[i] = arr[i][0];
console.log(newArr[i]);
for(j=0;j<arr[i].length;j++){
if (newArr[i] < arr[i][j]){
newArr[i] = arr[i][j];
}
}
}

return newArr;
}
largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [10000, 1001, 857, 1]]);
check here it woks now
newArr[i] = arr[i][0] instead you used newArr[i] = [arr[i][0]]
oretib
@oretib
Jun 29 2015 18:33
thanks, I'll check it out!
Prathmesh Khedekar
@Optimus101
Jun 29 2015 18:33
ok
Grace
@dogbot101
Jun 29 2015 18:36
So... My Lowest Common Multiple Bonfire has too much recursion...
function smallestCommons(arr) {
  //eucildean formula , LCM is X divided by Y. 
  // if x = product of two numbers, i.e. 30 * 45 = 1350
  // if y = greatest common divisor of both numbers = 15 
  // i.e. LCM is 90 or 1350 /15

  //for sorting array from smallest to largest
  function sortedArr(a, b) {
    return a - b;
  }
   var numArr = arr.sort(sortedArr); 
  //created array to put all numbers between the numbers inside.  
   var newArr=[]; 
   for(i = numArr[0]; i<= numArr[1]; i++) {
          newArr.push(i);}

 return newArr.reduce(lcmbyeuclid);
}

  // the actual euclidean algorithm 
  function lcmbyeuclid(a,b) {
     return (a*b)  / gcdf(a,b);
  }

  //function to find greatest common divisor or gcd
  function gcdf(a,b) {
    var gcd;
    //if number divides without a remainder, that is the gcd 
        if (b===0) {
      gcd = a;
      return gcd;     
    } else {
    // if there is a remainder, change the numbers passing through 
    // instead of a, it will be b, and instead of b it will be remainder a%b
      gcd = gcdf(b, a%b); 
      return gcd;
      }



    }



lcmbyeuclid([1,5]);
Nevermind.. I just fixed it
Arthur Zhuk
@ug02fast
Jun 29 2015 18:41
Anyone mind helping me with understanding why I’m getting a TypeError on my code where I have “capitalized.join”?
function titleCase(str) {
  var arrayOfWords = str.split(" ");
  var word;
  var capitalized;
  arrayOfWords.forEach(function(word){
    var capitalized = word.charAt(0).toUpperCase() + word.substring(1);
    console.log(capitalized);
  });
    var upperCasedWords = capitalized.join(" ");
    console.log(upperCasedWords);
}

titleCase("I'm a little tea pot");
TypeError: undefined is not an object (evaluating 'capitalized.join’) is the error im getting
Krzysztof Miąsko
@kmiasko
Jun 29 2015 18:42
join works for arrays
capitalized is string in your code
Justin Walters
@FFX01
Jun 29 2015 18:43
I'm having a bit of difficulty with "Bonfire: Arguments Optional". I'm not really sure what it's asking me to in: "For example, add(2, 3) should return 5, and add(2) should return a function that is waiting for an argument so that var sum2And = add(2); return sum2And(3); // 5"
function add() {
  for(var i=0;i<arguments.length;i++){
    if(isNaN(arguments[i])){
      return undefined;
    }
  }
  if(arguments.length<2){
    var sumNAnd=add(arguments[10]);
    return sumNand(arguments[1]);
  }
  else{
    return arguments[0]+arguments[1];
  }
}

add(2,3);
Krzysztof Miąsko
@kmiasko
Jun 29 2015 18:44
you can do var capitalized = [] ; and then capitalized.push(word.charAt(0).toUpperCase() + word.substring(1));
Justin Walters
@FFX01
Jun 29 2015 18:44
that's what i have so far
Krzysztof Miąsko
@kmiasko
Jun 29 2015 18:44
and you're overwriting your capitalized from other scope
remove var in capitalized assignment
Arthur Zhuk
@ug02fast
Jun 29 2015 18:44
@kmiasko thanks
drd13
@drd13
Jun 29 2015 18:44
This message was deleted
Ryan Miller
@rjmill
Jun 29 2015 18:45
@FFX01 it basically means you should be able to do add(2)(3) to get 5
Justin Walters
@FFX01
Jun 29 2015 18:45
@rjmill ok, so I have to make the function call itself if only one argument is passed?
drd13
@drd13
Jun 29 2015 18:45

Hey so when I run my code for http://www.freecodecamp.com/challenges/bonfire-drop-it
In the embbed console it says my result is [3,4] but the tests register an array of [] do any of you know why that might be?

Here is my code if you want to check for yourselves

function drop(arr, func) {
  while (arr.some(func)){
    arr.splice(0,1);
  }
  console.log(arr);
  return arr;
}

drop([1, 2, 3, 4], function(n) {return n < 3; });
Ryan Miller
@rjmill
Jun 29 2015 18:46
@FFX01 you're going to want to return an anonymous function call
like so:
or actually,
Justin Walters
@FFX01
Jun 29 2015 18:47
@drd13 that exercise is actually really simple if you do the right way. Try using filter()
Jonathan Niles
@jniles
Jun 29 2015 18:47
@drd13 , I am not certain why your code is failing specifically, but anytime you are using a functional iteration (such as arr.some()), you should not modify the array within the iteration or unexpected behavior may occur. I would try using a while loop or something similar.
drd13
@drd13
Jun 29 2015 18:48
ok
Steven Leiva
@StevenXL
Jun 29 2015 18:48
Hi everyone.
I am stuck on implementing the search bar in the TwitchTV API.
Can someone point me in the right direction?
Ryan Miller
@rjmill
Jun 29 2015 18:48
for add(2) you'll want to return something equivalent to function(y) {return 2 + y};
drd13
@drd13
Jun 29 2015 18:48
but its still very weird that the terminal and the tests have different results
Justin Walters
@FFX01
Jun 29 2015 18:49
@rjmill I see. ok. Thank you.
drd13
@drd13
Jun 29 2015 18:49
but thanks alot :D
Arthur Zhuk
@ug02fast
Jun 29 2015 18:49
@kmiasko That works. I didn’t realize the variable wasn’t an array after I did the split :) . This got me moving forward thanks again.
Ryan Miller
@rjmill
Jun 29 2015 18:49
@FFX01 no prob!
Jonathan Niles
@jniles
Jun 29 2015 18:49
:S
Krzysztof Miąsko
@kmiasko
Jun 29 2015 18:49
@ug02fast np, good luck
Jonathan Niles
@jniles
Jun 29 2015 18:49
@drd13 , yeah I do not have a good explanation for that. Must be something with FCC's evaluation methods
Miguel Correa
@miguelc1221
Jun 29 2015 18:52
i am i the only one that always needs to look up slice, splice and subStr? lol
Ryan Miller
@rjmill
Jun 29 2015 18:53
@miguelc1221 nah, I still to keep the documentation open while I program and look up functions that I should probably have memorized now
it doesn't really matter if you don't memorize all the function names as long as you can find them quickly and use them properly
Miguel Correa
@miguelc1221
Jun 29 2015 18:54
i know splice mutates i just get confuse with the arguments
Ryan Miller
@rjmill
Jun 29 2015 18:57
@miguelc1221 I hear you. I have 3 different contract jobs right now in 3 different languages, so the struggle of having to look up "how do I do x thing in y language" is pretty much a constant issue
but googling it takes two seconds and nobody really cares as long as I can write good code
Steven Leiva
@StevenXL
Jun 29 2015 19:02
Hi guys. I am trying to implement the search bar in the TwitchTV API. My code is here: https://github.com/StevenXL/TwitchTV_API.git
I'm not sure where to get started with this.
I was wondering if anyone could help me out.
Justin Walters
@FFX01
Jun 29 2015 19:06
@StevenXL I wish I could help, but I'm still doing the bonfires
Krzysztof Miąsko
@kmiasko
Jun 29 2015 19:06
i've done it in agular, so hard for me to help with jquery, but a hint would be.. paste actual codepen url
it's easier to help with live code
than just by reading it
Steven Leiva
@StevenXL
Jun 29 2015 19:21
@FFX01 thanks, and no worries.
Good luck with them.
Miguel Correa
@miguelc1221
Jun 29 2015 19:45
i think i am going to skip Sum All Primes and Smallest Common Multiple…only 2 i need in the basic bonfires
Lightwaves
@Lightwaves
Jun 29 2015 19:45
@miguelc1221 hey miguel looking to pair and those bonfires aren't actually too bad.
@miguelc1221 I could help you with them I'm actually on my final 6 for the basic bonfires.
Miguel Correa
@miguelc1221
Jun 29 2015 19:46
i just draw a blank on those 2
Lightwaves
@Lightwaves
Jun 29 2015 19:48
They are a little bit more math-y then the others that's all, I can definitely help you with them.
Miguel Correa
@miguelc1221
Jun 29 2015 19:49
sure
Lightwaves
@Lightwaves
Jun 29 2015 19:55
alright
tjstinso
@tjstinso
Jun 29 2015 19:58
@StevenXL For the search bar, take your array of streams, filter and filter it with regex.
You should wrap that filter inside of an event listener. Every time the event is fired, you should update your list of streams, similar to how clicking online, offline or all will update your list
Steven Leiva
@StevenXL
Jun 29 2015 20:03
@tjstinso Thanks!
@biancamihai was able to help me out with the project.
I've updated the repo to add the functionality. It still needs a bit of work, but I at least understand what I'm doing out there.
I decided to go with a simple string.indexOf in terms of the actual matching.
The one item that I don't like is that it will search all the users, regardless of what "button" was clicked beforehand.
I can fix that easily, but keeping track of what the current users are, but not sure I want to. :-)
Jessi L Wasell
@JessiW
Jun 29 2015 20:08
Hi - I'm working on the Bonfire Seek and Destroy - I'm having trouble as my code continues to return an empty array - like this: [ ]. Can someone have a look at my code?
function destroyer(arr) {
  var array = [];

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

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
creynolds911
@creynolds911
Jun 29 2015 20:12
Having some issues beginning the Pomodoro Clock zipline. Don't really feel like waypoints that were prior really prepared me for this zipline. Don't even know where to start
gravesr1993
@gravesr1993
Jun 29 2015 20:13
thought it might be good to post this here;so I was wondering about handling garbage collection in js compared to languages like c++ where I can do things such as gcnew objects, and was reading https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management , the reference cycling seems kind of a shocker to me, and is does anyone know if there's a way to explicitly garbage collect, or can point me to more literature on the subject?
Lightwaves
@Lightwaves
Jun 29 2015 20:14
@JessiW arguments[0] is the array [1,2,3,1,2,3]
Jessi L Wasell
@JessiW
Jun 29 2015 20:14
okay
just a sec...
Steven Leiva
@StevenXL
Jun 29 2015 20:15
Hi Jessi. I think you are on the right track. You should read up on the arguments object on MDN. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:16
Hey there! Is anyone available to help out with a few screen hero bonfire challenges?
Steven Leiva
@StevenXL
Jun 29 2015 20:16
As @Lightwaves mentioned, arguments[0] is the array that you are trying to filter.
Jessi L Wasell
@JessiW
Jun 29 2015 20:17
@StevenXL Thanks - I have had that link up in my browser and have been referencing it throughout. :+1:
so I changed my code a bit - still getting the empty array....
Steven Leiva
@StevenXL
Jun 29 2015 20:20
OK
Can you explain to me how you think your code is working
Or should be working.
Jessi L Wasell
@JessiW
Jun 29 2015 20:23
I need my code to remove the elements in the array that the same value as the arguments following the array...
so I figured I would loop through the arguments - and filter out the 2,3 s and leave the other numbers that don't match those arguments...
Steven Leiva
@StevenXL
Jun 29 2015 20:24
OK.
Jessi L Wasell
@JessiW
Jun 29 2015 20:24
But it seems like it might be removing all of the numbers instead of just the ones that match those two arguments.
not sure though - that's just how I can justify seeing an empty array! :)
Steven Leiva
@StevenXL
Jun 29 2015 20:25
haha - no worries, we'll walk through it.
So, if I understand you correctly, the variable array is supposed to contain the numbers that you want to delete from the original array passed in?
So in the case of destroyer([1, 2, 3, 1, 2, 3], 2, 3);, that would be the numbers 2 and 3?
Jessi L Wasell
@JessiW
Jun 29 2015 20:26
I think its supposed to contain the numbers that are left over after I delete 2 and 3 - which would be 1.
in that case...
Steven Leiva
@StevenXL
Jun 29 2015 20:28
Yea, but I'm speaking specifically about the variable in your code called array. What is that supposed to contain when we call it using destroyer([1, 2, 3, 1, 2, 3], 2, 3)
Jessi L Wasell
@JessiW
Jun 29 2015 20:29
1 and 5 it seems
I changed my code again - here's what it looks like now - I have one test returning correctly....
function destroyer(arr) {
  var array = [];

  for (var i = 1; i<arguments.length; i++) {
        array.push(arguments[i]);
    }
  return arguments[0].filter(function(element, index, array) {
    return array.indexOf(element)<1;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Steven Leiva
@StevenXL
Jun 29 2015 20:32
OK, so when we call the function (last line of your code), then array is going to be [1, 3]
I'm sorry, [2, 3].
Jessi L Wasell
@JessiW
Jun 29 2015 20:32
its returning [1,1] now which is good but the other test is still not returning correctly.
Steven Leiva
@StevenXL
Jun 29 2015 20:32
You did everything right except for return array.indexOf(element) < 1'
Jessi L Wasell
@JessiW
Jun 29 2015 20:33
okay - what should it be?
Steven Leiva
@StevenXL
Jun 29 2015 20:33
Remember what the docs say - array.indexOf(element) is going to return -1 if the element is not found.
Jessi L Wasell
@JessiW
Jun 29 2015 20:33
right
Steven Leiva
@StevenXL
Jun 29 2015 20:33
But index 0 is still valid.
Jessi L Wasell
@JessiW
Jun 29 2015 20:34
I just changed it back to <0 and its returning an empty array again....
Steven Leiva
@StevenXL
Jun 29 2015 20:38
hm..
Can you paste it again?
strange, just ran the code and when i put 0 in there it gives me [1, 1]
Jessi L Wasell
@JessiW
Jun 29 2015 20:40
okay - here it is again -
function destroyer(arr) {
  var array = [];

  for (var i = 1; i<arguments.length; i++) {
        array.push(arguments[i]);
    }
  return arguments[0].filter(function(element, index, array) {
    return array.indexOf(element)<0;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:40
function destroyer(arr) {
  var array = [];
  for (var i =1; i<arguments.length; i++) {
        array.push(arguments[i]);
  }
    console.log(arguments[0].filter(function(element, index, a) {
        console.log(array.indexOf(element)+' ' + element);
        return array.indexOf(element)===-1;
  }));
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Lightwaves
@Lightwaves
Jun 29 2015 20:40
I got 1,1 as well
that is weird
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:41
works now
can you please verify?
Jessi L Wasell
@JessiW
Jun 29 2015 20:41
should I refresh after copying my code?
Lightwaves
@Lightwaves
Jun 29 2015 20:41
blob
try refreshing
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:41
function destroyer(arr) {
  var array = [];
  for (var i =1; i<arguments.length; i++) {
        array.push(arguments[i]);
  }
  return arguments[0].filter(function(element, index, a) {
        console.log(array.indexOf(element)+' ' + element);
        return array.indexOf(element)===-1;
  });
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
sorry the old one contained console.log instead of return
@JessiW could you please check it?
Jessi L Wasell
@JessiW
Jun 29 2015 20:43
@Optimus101 - that code did work - thanks - but not exactly sure why?
@Lightwaves - I did try the refresh with my original code and it still returned incorrect:)
Lightwaves
@Lightwaves
Jun 29 2015 20:44
lol what the heck /confuzzled
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:45
@JessiW since you were using array in function as well as you defined it in function destroyer too
Justin Walters
@FFX01
Jun 29 2015 20:45
can anyone help me get my anonymous function call working? I'm pretty new to this concept and I'm having a bit of difficulty: http://repl.it/languages/JavaScript
Jessi L Wasell
@JessiW
Jun 29 2015 20:45
me to @Lightwaves
too I meant :)
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:45
function(element, index, a) was previously function(element, index, array)
Justin Walters
@FFX01
Jun 29 2015 20:45
wrong link, meant: http://repl.it/uio
Lightwaves
@Lightwaves
Jun 29 2015 20:45
oh aliasing
Jessi L Wasell
@JessiW
Jun 29 2015 20:45
okay - that makes sense @Optimus101 - thank you :)
Lightwaves
@Lightwaves
Jun 29 2015 20:46
that could possibly be it but that still seems weird
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:46
@JessiW welcome
Jessi L Wasell
@JessiW
Jun 29 2015 20:46
I'll remember that :)
thanks to all of you - @Lightwaves @Optimus101 @StevenXL :+1:
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:47
@Lightwaves try console.log in filter function and print the array
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:47
Hey guys
Lightwaves
@Lightwaves
Jun 29 2015 20:47
@StevenXL did most of the work walking you through the thinking process
hey
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:47
Think anyone would be able to help me out on the Bonfires now?
I'd really appreciate it :D
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:49
@Lightwaves the array in the filter function refers to the current array i guess
Justin Walters
@FFX01
Jun 29 2015 20:49
@JelaniThompson which one?
Jessi L Wasell
@JessiW
Jun 29 2015 20:49
which one @JelaniThompson ?
Lightwaves
@Lightwaves
Jun 29 2015 20:50
@Optimus101 wow that is weird, I just checked yeah it was an aliasing issue. I'll keep that one in mind.
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:50
@JessiW due to your error i got to learn filter function :smile: . Thanks
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:51
String reversal
I was planning on doing multiple though
Mind if I get your screen hero emails?
Jessi L Wasell
@JessiW
Jun 29 2015 20:51
I think we all learned something - @Optimus101 - that's great - welcome :)
Lightwaves
@Lightwaves
Jun 29 2015 20:51
lol
yeah I know I did lol
@Optimus101 javascript has some very very weird scoping
Steven Leiva
@StevenXL
Jun 29 2015 20:52
that's good to know
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:52
@Lightwaves yeah
Steven Leiva
@StevenXL
Jun 29 2015 20:52
Also going to keep that on in mind!
Lightwaves
@Lightwaves
Jun 29 2015 20:52
@JessiW one other issue I didn't notice it should have been array.indexOf(element) < 0
or honestly just do array.indexOf(element) === -1
Justin Walters
@FFX01
Jun 29 2015 20:52
@JelaniThompson , I think there is a special button on the bonfires to send out a pair request.
Jessi L Wasell
@JessiW
Jun 29 2015 20:52
@JelaniThompson - Oh, I've already done that one - my screen hero doesn't work well - but I'd be happy to walk you through...
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:53
Awesome, that would be great :D
Jessi L Wasell
@JessiW
Jun 29 2015 20:53
Yes - @lightwaves - I agree :)
Justin Walters
@FFX01
Jun 29 2015 20:54
Can't get this to work: http://repl.it/uio/1
Jessi L Wasell
@JessiW
Jun 29 2015 20:54
Sorry - @JelaniThompson - I just realized the time - I have leave for an appt - I'm so sorry :(
Justin Walters
@FFX01
Jun 29 2015 20:54
keep getting a type error "add(...) is not a function.
Jessi L Wasell
@JessiW
Jun 29 2015 20:54
I'd be happy to help you later if you still need it :)
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:55
It's fine XD
So, this is what I have so far guys
```
function reverseString(str) {
  var reverseArray = [];
  str = reverseArray.reverse();
  return str;
}

reverseString('hello');
creynolds911
@creynolds911
Jun 29 2015 20:55
trying to set font to bold and typed: font-weight: bold; i got no responce
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:55
But it returns empty brackets
Anyone know why?
Justin Walters
@FFX01
Jun 29 2015 20:56
@JelaniThompson the array isn't populated with anything
Rasheed Bustamam
@abustamam
Jun 29 2015 20:56
@FFX01 your function header should look like function add()
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:56
Oh crap
Rasheed Bustamam
@abustamam
Jun 29 2015 20:56
since arguments optional, we do not initialize with args
Jelani Thompson
@JelaniThompson
Jun 29 2015 20:56
That was a major oversight oops lol
Should I use array.push?
Justin Walters
@FFX01
Jun 29 2015 20:57
@abustamam thanks. Still doesn't work though. I think it has something to do with my anonymous function call
Rasheed Bustamam
@abustamam
Jun 29 2015 20:57
yes
remember you want to return a function
not evaluate
so you should return something liek
return function (b) {
...

}
Prathmesh Khedekar
@Optimus101
Jun 29 2015 20:58
@FFX01 add(2,3); not add(2)(3);
Justin Walters
@FFX01
Jun 29 2015 20:58
@Optimus101 that's actaully one of the test inputs
creynolds911
@creynolds911
Jun 29 2015 20:58
trying to get my title bold and typed in
Justin Walters
@FFX01
Jun 29 2015 20:58
add (2,3) works fine
ciper99
@ciper99
Jun 29 2015 21:02
hey everyone!
anyone need help with anything?
Justin Walters
@FFX01
Jun 29 2015 21:02
@ciper99 this: http://repl.it/uio/2
keep getting a type error.
Jelani Thompson
@JelaniThompson
Jun 29 2015 21:03
yeah, trying to figure out how to reverse this string
ciper99
@ciper99
Jun 29 2015 21:03
what do you want to do?
@JelaniThompson
I know I can help you with that
but first, I'll give you a couple of hints
while you can probably loop through a string to reverse it
Justin Walters
@FFX01
Jun 29 2015 21:03
@ciper99 The exercise is asking me to create an anonymous function call so that add(2)(3); equals 5
ciper99
@ciper99
Jun 29 2015 21:03
there is already a method to reverse arrays
it is called Array.reverse() and it reverses the array
Jelani Thompson
@JelaniThompson
Jun 29 2015 21:04
Well, here's what I have so far
function reverseString(str) {
  var reverseArray = [];
  reverseArray.push(str);
  return reverseArray;
}

reverseString('hello');
ciper99
@ciper99
Jun 29 2015 21:04
so, my advice for you @JelaniThompson is to turn your string into an array of characters
Jelani Thompson
@JelaniThompson
Jun 29 2015 21:04
So right now, it's pushing into the array
But like, now I just gotta figure out how to reverse XD
Ah OK :D
I'll try that
ciper99
@ciper99
Jun 29 2015 21:05
:)
Justin Walters
@FFX01
Jun 29 2015 21:05
@JelaniThompson you're pushing the whole string into the array as a single element.
ciper99
@ciper99
Jun 29 2015 21:05
@FFX01 I don't know a lot about anonymous functions :(
is it a bonfire
Justin Walters
@FFX01
Jun 29 2015 21:05
@ciper99 yeah. It's hard
ciper99
@ciper99
Jun 29 2015 21:05
@JelaniThompson
the whole point of the bonfires
Robert Ozimek
@robertozimek
Jun 29 2015 21:06
@FFX01 the sum2and is an example
ciper99
@ciper99
Jun 29 2015 21:06
is for you to learn the built in methods of JavaScript
so, I'm going to give you another tip, can I?
Robert Ozimek
@robertozimek
Jun 29 2015 21:06
your suppose to generalize it to be the number pass in along with the extra argument
ciper99
@ciper99
Jun 29 2015 21:07
the split method of Javascript turns a string into an array
you can read the description of the method and how to use it in that link :)
so, you already have a method that turns a string into an array
Jelani Thompson
@JelaniThompson
Jun 29 2015 21:08
Awesome, thanks :D
ciper99
@ciper99
Jun 29 2015 21:08
and one that reverses arrays
now, you need one to turn your arrays into strings, don't you?
or do you know it?
Jelani Thompson
@JelaniThompson
Jun 29 2015 21:08
No, haha
:)
the thing is, while it is great to think about how to solve these things, there is no point in reinventing the wheel
there is a reason for those built in methods
it's because many developers need to do those things lots of times
take the time to study them, the MDN (mozilla developer network) will be your best friend!
Prathmesh Khedekar
@Optimus101
Jun 29 2015 21:11
@FFX01 I think you should return function from your function to satisfy add(2)(3)
Jelani Thompson
@JelaniThompson
Jun 29 2015 21:12
I'm confused
What are separator and limit supposed to be?
In str.split([separator[, limit]])
This is why I've kinda avoided MDN, really complicated stuff in it
Justin Walters
@FFX01
Jun 29 2015 21:13
@Optimus101 this is what I have now, and it's still coming up with a type error: http://repl.it/uio/3
ciper99
@ciper99
Jun 29 2015 21:14
@JelaniThompson have you checked out the examples?
read the whole pages to understand it
I'll explain it to you this time because I'm on a really good mood today :) but the MDN is easy to understand
don't be afraid that you don't understand it at first, read through it all, experiment, and then ask for help
so, the separator and limit are arguments to the split method
the separator is something you can put between the characters of a string
Mario Mitchell
@undergroundfx
Jun 29 2015 21:17
My calculator is done everything works perfect except you can't put a decimal in the second number
Robert Ozimek
@robertozimek
Jun 29 2015 21:17
@FFX01 shouldn’t you be || not && the typeof check
nvm
Tony Keovongphet
@TSKeo
Jun 29 2015 21:18
Hey What's up guys.
Robert Ozimek
@robertozimek
Jun 29 2015 21:18
misread your code
Tony Keovongphet
@TSKeo
Jun 29 2015 21:18
anyone here working basics algorithm: mutations?
Justin Walters
@FFX01
Jun 29 2015 21:18
@robertozimek damn! haha. I'm dumb. Now it returns 6. it seems like it's multiplying the inputs now.
Tony Keovongphet
@TSKeo
Jun 29 2015 21:19
Robert Ozimek
@robertozimek
Jun 29 2015 21:23
@FFX01 also your if statement if(typeof arguments[0]==="number"&&typeof arguments[1]==="number”) will fail in this case and return undefined in the case of add(2)(3)
because argument[1] is undefined when you call add(2)(3)
Jonathan Archer
@j0narch3r
Jun 29 2015 21:26
hey folks, i'm stuck on the Twitch zipline. I'm sure parts of my code are atrocious (and some I had no choice but to crib from the example...), but hopefully someone can take a look and tell me what I'm doing wrong? http://codepen.io/jonarcher/pen/gpGoqN/
Justin Walters
@FFX01
Jun 29 2015 21:26
@robertozimek thanks. Let me try and rework it.
Jonathan Archer
@j0narch3r
Jun 29 2015 21:27
Main issue is duplication in the arrays.
Justin Walters
@FFX01
Jun 29 2015 21:31
@Optimus101 Thanks! Just what I needed!
Robert Ozimek
@robertozimek
Jun 29 2015 21:35
@j0narch3r you have a for loop inside a .forEach
your nesting your for loop inside users.forEach(function(stream) { which is causing to add the duplicates
Jonathan Archer
@j0narch3r
Jun 29 2015 21:38
@robertozimek ah — so how do I loop through the 3 arrays based on streaming status?
Robert Ozimek
@robertozimek
Jun 29 2015 21:41
@j0narch3r well I would say you don’t use the 3 arrays but just add them right away based on streaming status
gravesr1993
@gravesr1993
Jun 29 2015 21:44
I have a question about for in loops in javascript, referring to http://www.w3schools.com/js/js_loop_for.asp as documentation , this looks very similar to foreach loops in c#, and I was wondering if the iterators in javascript can be objects as they can be in c#(I find it very useful to iterate with objects for a lot of things), or are they iterated purely on integers?
ciper99
@ciper99
Jun 29 2015 21:45
@gravesr1993, don't use w3fools, use mdn!
Justin Walters
@FFX01
Jun 29 2015 21:45
@robertozimek : got it:http://repl.it/uio/4
Jonathan Archer
@j0narch3r
Jun 29 2015 21:45
@robertozimek Hm, ok. Thanks. I'll see what I can do.
Justin Walters
@FFX01
Jun 29 2015 21:45
thanks for your help
@Optimus101 thanks to you as well.
Robert Ozimek
@robertozimek
Jun 29 2015 21:45
nice np
ciper99
@ciper99
Jun 29 2015 21:46
but yes, @gravesr1993 I think you can iterate through objects with it
gravesr1993
@gravesr1993
Jun 29 2015 21:47
well, not iterate through objects, but have the iterator BE an object instead, not sure how to explain myself correctly sorry
for example, in the loop:
for (var key in arr) {
s += key + ": " + arr[key];
s += "<br />";
} taken from https://msdn.microsoft.com/library/55wb2d34(v=vs.94).aspx if it's possible for var key to be an object in arr
Robert Ozimek
@robertozimek
Jun 29 2015 21:48
@gravesr1993 I suppose if they are objects inside a object it shoud work
tjstinso
@tjstinso
Jun 29 2015 21:48
you could probably find a library that allowed you to create an iterator object
i think its abstracted away for the most part, however
ciper99
@ciper99
Jun 29 2015 21:51
not sure I get binary agents bonfire
all the methods mentioned work with unicode points
not binary
?
anyone solved it? can you give a couple hints?
Justin Walters
@FFX01
Jun 29 2015 21:52
@ciper99 I got that one. You just need to translate the binary into base 10 numbers
the base ten number is the unicode character
ciper99
@ciper99
Jun 29 2015 21:52
ohhhhhhh
Justin Walters
@FFX01
Jun 29 2015 21:52
@ciper99 look up parseInt()
ciper99
@ciper99
Jun 29 2015 21:52
thanks hehe, now I gotta find me a translator from binary to unicode
Justin Walters
@FFX01
Jun 29 2015 21:53
@ciper99 parseInt will do that
ciper99
@ciper99
Jun 29 2015 21:53
thanks a lot mate!
anyone solved it without parseInt?
because it isn't listed in the helpful bonfire methods
it is easier to find the necessary array and string methods, but harder to find the normal functions
Robert Ozimek
@robertozimek
Jun 29 2015 21:54
@ciper99 well I don’t see how that would be possible since the argument comes as a string
ciper99
@ciper99
Jun 29 2015 21:55
hmmm, how did y'all find parseInt?
Justin Walters
@FFX01
Jun 29 2015 21:55
@ciper99 you would have to use a lot of nested iterations and essentially create your own parsing function
@ciper99 i used google
ciper99
@ciper99
Jun 29 2015 21:55
yeah, me too, but I mean
TopEgret
@topegret
Jun 29 2015 21:55
iam getting stuck on Bonefire: Convert HTML Entities
ciper99
@ciper99
Jun 29 2015 21:55
what did you search for?
gravesr1993
@gravesr1993
Jun 29 2015 21:55
well, never done it before and just looked at it, you can convert the binary numbers to ASCII assign the ASCII to character/strings then output that, not sure how would work in JS though
TopEgret
@topegret
Jun 29 2015 21:56
anyone wants to pair
Jonathan Archer
@j0narch3r
Jun 29 2015 21:56
@robertozimek Ah well, now I totally broke it. Time to step away from the computer...
ciper99
@ciper99
Jun 29 2015 21:56
hey @topegret, a second and I'll help you
Robert Ozimek
@robertozimek
Jun 29 2015 21:56
@ciper99 how to cast a string as an integer
ciper99
@ciper99
Jun 29 2015 21:56
cast?
Justin Walters
@FFX01
Jun 29 2015 21:56
@ciper99 i looked for converting binary to unicode js
ciper99
@ciper99
Jun 29 2015 21:56
thanks!
Robert Ozimek
@robertozimek
Jun 29 2015 21:56
@j0narch3r yeah sometimes the best solution is to step away for a bit and come back with a clear head hahaha
TopEgret
@topegret
Jun 29 2015 21:57
thanks @ciper99
Robert Ozimek
@robertozimek
Jun 29 2015 21:57
@ciper99 yeah that’s the term used in programming for converting one type to another
TopEgret
@topegret
Jun 29 2015 21:57
i am not good at regexp
not sure I understand how js regexp works
Robert Ozimek
@robertozimek
Jun 29 2015 21:58
yeah it takes some getting use to
gravesr1993
@gravesr1993
Jun 29 2015 21:58
it's very helpful, you can cast chars into ints, then perform encryption methods on the ints, recast it to chars, assemble the string again, and you have an encrypted string :)
ciper99
@ciper99
Jun 29 2015 21:59
@robertozimek thanks
Robert Ozimek
@robertozimek
Jun 29 2015 21:59
np
ciper99
@ciper99
Jun 29 2015 22:06
ok @topegret I can help you now
what is your problem?
gravesr1993
@gravesr1993
Jun 29 2015 22:07
always seem to have problems with codeacademy, any ideas? http://i.imgur.com/xipf46y.png
ciper99
@ciper99
Jun 29 2015 22:08
shouldn't you have ; after the return statements?
gravesr1993
@gravesr1993
Jun 29 2015 22:08
returns without ; in javascript for some reason
ciper99
@ciper99
Jun 29 2015 22:08
what?
Grace
@dogbot101
Jun 29 2015 22:08
Maybe try switch get review
I mean switch(getReview)
TopEgret
@topegret
Jun 29 2015 22:09
@ciper99.... I think I didn't understand js regexp...
Robert Ozimek
@robertozimek
Jun 29 2015 22:09
@gravesr1993 you missed the and in ”Cool animation, and funny turtles."
gravesr1993
@gravesr1993
Jun 29 2015 22:09
all of the JS that FCC has redirected me to on codeacademy hasn't needed a single ; for some reason
ciper99
@ciper99
Jun 29 2015 22:10
maybe automatic semicolon insertion?
TopEgret
@topegret
Jun 29 2015 22:10
need read more about regexp. now I don't have any clue put down the code
gravesr1993
@gravesr1993
Jun 29 2015 22:10
ah, that's what it was @robertozimek
Matt Trifilo
@itxchy
Jun 29 2015 22:10
@gravesr1993 I don't think you need "break;" in the default case.
gravesr1993
@gravesr1993
Jun 29 2015 22:10
it might have automatic semicolon insertion, I eventually stopped caring for semicolons in codeacademy because they automatically were removing them when I went to the next lesson
ciper99
@ciper99
Jun 29 2015 22:10
@gravesr1993 maybe it's that thing I just listed, about the ;
gravesr1993
@gravesr1993
Jun 29 2015 22:12
ah, yeah, maybe, still very foreign to me
creynolds911
@creynolds911
Jun 29 2015 22:15
I think my training schedule got a little mixed up. It has me doing a zipline on my first day?
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:16
Hey, would someone be able to help describe the concept of recursion in JavaScript?
It's a term I've heard before, but never fully researched
And it's like used everywhere, haha
ciper99
@ciper99
Jun 29 2015 22:19
I can say what it is
and show you 2 examples
but, I also don't understand it ;p
I mean, I know what it is
but I can't write recursive code
I'm waiting for waypoint functional programming to help me with that hehe
if anyone understands recursion well, please explain it
in the meanwhile
recursion is when you call a function inside itself
basically, if you have
function recur(){
    recur();
}
it is recursion
Robert Ozimek
@robertozimek
Jun 29 2015 22:21
@JelaniThompson recursion is when a function calls itself, you need a base case, which is the point in which it stops calling itself, it’s like it loops inside itself
ciper99
@ciper99
Jun 29 2015 22:21
now, the thing is, this might seem unimpressive
but it can be very powerful (and beautiful)
Robert Ozimek
@robertozimek
Jun 29 2015 22:22
@JelaniThompson maybe check out this youtube video https://www.youtube.com/watch?v=Mv9NEXX1VHc
ciper99
@ciper99
Jun 29 2015 22:22
I have a recursive solution for the factorial bonfire
which you are struggling with
however
I won't give it to you first
anything you can solve recursively
you can solve iteratively
gravesr1993
@gravesr1993
Jun 29 2015 22:22
iterative solutions are probably better most times haha
ciper99
@ciper99
Jun 29 2015 22:22
so, I want you to try to solve it iteratively first, and then I'll show you the recursive solution
to show you how powerful it is
Robert Ozimek
@robertozimek
Jun 29 2015 22:23
well recursion for factorials in most programming langugages is inefficient
it’s just the most used to help explain recursion
ciper99
@ciper99
Jun 29 2015 22:23
@gravesr1993 a LISP programmer died because of that, you know?
hehehe
Robert Ozimek
@robertozimek
Jun 29 2015 22:24
the iterative solution is actually more efficient than the recusion, because recursion does dulpicate work when doing factorials
Jonathan Archer
@j0narch3r
Jun 29 2015 22:28
@robertozimek Think I'm getting closer. Still buggy but things are showing up now. Btw, do you know if Codepen has an issue when repeatedly accessing an API? It's interminably trying to Process Request.
Makes it hard to verify accuracy when it won't load :(
Robert Ozimek
@robertozimek
Jun 29 2015 22:29
@j0narch3r I’m not sure but earlier I had a similar problem, it kept refreshing the page into an infinite loop
so might be a bug at times
thats why I prefer to work on it locally and then paste it in later
Justin Walters
@FFX01
Jun 29 2015 22:30
Finally got the curried functions thing!
Matt Trifilo
@itxchy
Jun 29 2015 22:30

Pig Latin

function translate(str) {

  var strArr = str.split('');
  var pushed = [];

  var vowels = 'a' && 'e' && 'i' && 'o' && 'u';

  // if first letter isn't a vowel, push the 
  // consonants to the end followed by "ay"
  if (strArr[0] !== vowels) {

      var consonants = strArr[0].toString();

      // if second letter is a consonant, include it in 
      // the consonants variable
      if (strArr[1] !== vowels) {
        var secondConsonant = strArr[1].toString();
        consonants += secondConsonant;
        str = str.substr(2)
      } else {
        str = str.substr(1);
      }

      strArr = str.split('');
      pushed = strArr.push(consonants + "ay");
      str = strArr.join('');

  } else {
    // if first letter is a vowel, push "way" to the end 
      pushed = strArr.push("way");
      str = strArr.join('');
  }

 return str;
}

translate("consonant");

My conditions in both if statements are not working. Is there a better way to check for vowels?

Jonathan Archer
@j0narch3r
Jun 29 2015 22:31
@robertozimek Maybe I should try that. It's showing up sometimes in debug mode, but not in Editor or Full Screen.
Jeff Wilkey
@JeffWilkey
Jun 29 2015 22:31
maybe using the || operator instead of &&?
jlin14
@jlin14
Jun 29 2015 22:31
@itxchy no character is going to satisfy A and E and I and O and U
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:32
Yeah, it's just that with the factorial bonfire, I have no idea what the question even is lol
Robert Ozimek
@robertozimek
Jun 29 2015 22:32
@j0narch3r yeah pretty frustrating to work in codepen for me
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:32
Like, what does it want me to accomplish? lol
Grace
@dogbot101
Jun 29 2015 22:32
Maybe use an array of vowels?
Robert Ozimek
@robertozimek
Jun 29 2015 22:32
@itxchy you can also create an array of vowels and then use the .indexOf
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:32
I know it wants me to return the factorial, but the question is just bleh lool
Matt Trifilo
@itxchy
Jun 29 2015 22:32
@dogbot101 @robertozimek I'll give that a shot. Thanks!
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:34
nvm, got it
All these bonfires bringing up all these words I haven't heard of before @_@
Palindromes
Googles desperately
lol
gravesr1993
@gravesr1993
Jun 29 2015 22:39
palindromes sounds fun, could substring to string.length/2 and compare to string.length/2->string.length haha :)
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:41
"fun"
You said fun
gravesr1993
@gravesr1993
Jun 29 2015 22:42
fun, along with my initial thoughts on it that should work very well if you account for odds and evens :)
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:42
How is this FUN
Lol
Robert Ozimek
@robertozimek
Jun 29 2015 22:43
hahaha yeah or if you do it the simple way just reverse and match
gravesr1993
@gravesr1993
Jun 29 2015 22:44
yeah, there's probably some sort of built in reverse method, but that's not as.....FUN :)
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:44
@_@
lol
Robert Ozimek
@robertozimek
Jun 29 2015 22:44
hahaha
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:45
Oh crap
I have to use regEX to solve this Palindrome thing, but I forgot it all @_@
It's weird how the brain remembers dumb things, but forgets important things
Lightwaves
@Lightwaves
Jun 29 2015 22:46
you can reverse it using a for loop by iterating by array.length-1-i
if starting from 0
Jelani Thompson
@JelaniThompson
Jun 29 2015 22:46
Oh crap
Smart
Lightwaves
@Lightwaves
Jun 29 2015 22:46
or i if start from length and decrementing
Jonathan Archer
@j0narch3r
Jun 29 2015 22:47
@robertozimek Sorry to keep bugging you but this has me puzzled. Code is working as it should now, but some users are coming through undefined while others come through fine. How is that possible, since they're running through the same code?
Lightwaves
@Lightwaves
Jun 29 2015 22:47
yes there is a reverse method though to save you the trouble haha
Robert Ozimek
@robertozimek
Jun 29 2015 22:49
@j0narch3r I’m thinking maybe it’s the obj not staying in memory
not entirely sure, have you tried adding console.log outputs at different points in your code to see where they might become undefined
Jonathan Archer
@j0narch3r
Jun 29 2015 22:53
@robertozimek Ya, I was doing that a lot earlier in Codepen but then it stopped responding. It might be something like that. All I'm getting in console is 404 errors from the server.
Robert Ozimek
@robertozimek
Jun 29 2015 22:54
@j0narch3r maybe parts of codepen are down, or they have a limit on api requests
although I just checked your code and put in console.log(obj) in every if statement and there was less undefined users, maybe obj is for some reason getting dereference from memory too early.
Jonathan Archer
@j0narch3r
Jun 29 2015 23:03
I think I found it — the $.getJSON() call for the users was apparently closed too early, and so some of the obj.name calls were dropping (if that's the right word). Move the }); (enclosure?) to the end of the script and it's now returning all the correct usernames.
@robertozimek Now to figure out how to insert a placeholder image if a logo is missing... :smile:
Robert Ozimek
@robertozimek
Jun 29 2015 23:04
hahaha I think there was a site that does the placeholders for you
Don
@raydancer
Jun 29 2015 23:04
Should the "Smallest Common Multiple" bonfire really be 2 out of 5 flames? This one seems SO much more difficult than any other bonfire I've done...
Robert Ozimek
@robertozimek
Jun 29 2015 23:05
@j0narch3r actually found it https://placeholdit.imgix.net/~text?txtsize=10&txt=Icon&w=50&h=50 just need to change the parameters
there is also http://placehold.it/
@raydancer what specifically about this one are you having difficulty with? maybe I can help
Jonathan Archer
@j0narch3r
Jun 29 2015 23:18
@robertozimek Yeah, I know placeholder.it (and more entertainingly, https://placekitten.com) but not sure how to trigger it to replace an img with src="null"
gravesr1993
@gravesr1993
Jun 29 2015 23:18
apparently i've earned 175 points on code academy today haha
Robert Ozimek
@robertozimek
Jun 29 2015 23:19
@j0narch3r well you can check if there exists an image first, and if not then use the placeholder image instead
for example stream.logo = (stream.logo) ? stream.logo : "http://placehold.it/50x50“
gravesr1993
@gravesr1993
Jun 29 2015 23:22
are there any other helpful ternary operators like that?
Don
@raydancer
Jun 29 2015 23:22
@robertozimek I wish I could explain why I'm finding it difficult. I just don't see a concise way to do it. I've got to a point where I have an array for the full set of numbers to be evaluated and an array for the prime numbers within that array. I've studied up on primality tests, but none of them seem simple to apply. Any tips?
Lightwaves
@Lightwaves
Jun 29 2015 23:23
@raydancer if you have a way to test for prime make a function and test each number to see if it's prime
Robert Ozimek
@robertozimek
Jun 29 2015 23:25
@raydancer wait so your doing the “Sum All Primes” bonfire or “Smallest Common Multiple"
Jonathan Archer
@j0narch3r
Jun 29 2015 23:25
@robertozimek Hm. Tried doing this but it doesn't take.
 if (obj.logo === "null"){
        obj.logo = 'https://placekitten.com/g/50/50';
      } else {
      obj.logo = data.logo;
      }
nvm! Just realized the error. Should be
     if (data.logo === null){
        obj.logo = 'https://placekitten.com/g/50/50';
      } else {
      obj.logo = data.logo;
      }
Don
@raydancer
Jun 29 2015 23:27
@robertozimek Smallest Common Multiple; I'm going in this direction: https://en.wikipedia.org/wiki/Least_common_multiple#A_method_using_a_table
Robert Ozimek
@robertozimek
Jun 29 2015 23:28
@raydancer so you have arrays for each number in the range?
you can use the .indexOf to check the array against each other if thats the case
ahh I see, I haven’t seen this method done before
Don
@raydancer
Jun 29 2015 23:31
@robertozimek No...but I should probably give that way a try. It just seems a bit brute force.
Robert Ozimek
@robertozimek
Jun 29 2015 23:33
yeah so you can use a while loop for this with a forEach maybe
then have an extra array that keeps track of the numbers you used to divide the arrays
Don
@raydancer
Jun 29 2015 23:34
@robertozimek Yeah, I've got the two arrays...I'm just going crosseyed trying to use them to do what the tables do; I'll figure it out, I'm sure, but I've been working on this one for far too long
Robert Ozimek
@robertozimek
Jun 29 2015 23:35
@raydancer yeah sometime, you need to step back, give your mind a rest and come back to it later when your mind is clear
but I definitely see this working with 3 arrays a While loop and Two forEach loops
gravesr1993
@gravesr1993
Jun 29 2015 23:47
cherry MX blues > browns, need maximum tikataka :)