These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Feb 2016
Davinw
@Davinw
Feb 28 2016 00:00
@PhotoGeek1
// think that needs to be:
String.fromCharCode(str.charCodeAt(i));
bitgrower
@bitgrower
Feb 28 2016 00:01
@don't know, @KrisTarling -- haven't been playing with it ...
Norman Dela Cruz
@dcnr
Feb 28 2016 00:01
@RPaez09 there might be extra spaces that you didn't notice, or if it's an array, there might be undefined values
L Yeh
@PhotoGeek1
Feb 28 2016 00:01
@Davinw Thank you!! it worked!!
CamperBot
@camperbot
Feb 28 2016 00:01
photogeek1 sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 276 | @davinw | http://www.freecodecamp.com/davinw
Alex N.
@N0bl3
Feb 28 2016 00:01
bf smallest common multiple
CamperBot
@camperbot
Feb 28 2016 00:01

:fire:Bonfire: Smallest Common Multiple :link:

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

Find the smallest number that is evenly divisible by all numbers in the provided range.

more info:  bf details | bf links | hint

Alex N.
@N0bl3
Feb 28 2016 00:01
hint smallest common multiple
CamperBot
@camperbot
Feb 28 2016 00:01
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Davinw
@Davinw
Feb 28 2016 00:02
@PhotoGeek1 Yw!
bitgrower
@bitgrower
Feb 28 2016 00:02
@N0bl3 -- my recommendation is you find the description of various LCD finder algos on the dummies site ...
Kris Tarling
@KrisTarling
Feb 28 2016 00:02
@bitgrower yeah, it's definitely broken. You even add a number to your answer. Pressing + clears everything
*can't even
Alex N.
@N0bl3
Feb 28 2016 00:04
@bitgrower the dummies site? ^^ I'm just looking for the mathematical thing for the moment
Ogechi Ike
@BlackMG27
Feb 28 2016 00:04
@bitgrower I tried to iterate, but it still gives me 1.
// Only change code below this line
    for(var i=0; i < arr.length; i++){
      for(var j=0; j < arr[i].length; j++){
        return product * arr[i][j];
      }
    }
  // Only change code above this line
Paul Brown
@paulbwd
Feb 28 2016 00:05
@PhotoGeek1 your first test is && should that be OR ?
bitgrower
@bitgrower
Feb 28 2016 00:05
can you post your full code, @BlackMG27 ?
Norman Dela Cruz
@dcnr
Feb 28 2016 00:05
@BlackMG27 remove the return (inside your for loop) because it causes your function to immediately terminate
Devin
@devblanchard
Feb 28 2016 00:05
so i'm checking for palindromes. i don't feel like i have that flipLow function worked out quite right, but i am having difficulty figuring out how to arrange what i am trying to make happen.
function palindrome(s
 var flipLow = function(){
   str.replace(/\s/g,'').toLowerCase();
   return str.split('').reverse().join('');
 };

  if(str===flipLow){
  return true;  
  }
 return false;
}



palindrome("eye");
Paul Brown
@paulbwd
Feb 28 2016 00:05
less than 65 and more than 91?
adamboyer
@adamboyer
Feb 28 2016 00:06
can someone please help me with the profile lookup challenge!? I've stuck for hours!!!!
//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++){
  while (contacts[i].hasOwnProperty(firstName)){
     while(contacts[i].hasOwnProperty(prop)){
       return contacts[i][prop];
       }
    return "No such property";
  }
} return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "likes");
bitgrower
@bitgrower
Feb 28 2016 00:06
@paulbwd -- sounds about right ... :)
Kris Tarling
@KrisTarling
Feb 28 2016 00:06
@adamboyer your returns are breaking the loops
Paul Brown
@paulbwd
Feb 28 2016 00:07
:D
alpox
@alpox
Feb 28 2016 00:07

@adamboyer

while(contacts[i].hasOwnProperty(prop)){
       return contacts[i][prop];
       }

whuat :D

bitgrower
@bitgrower
Feb 28 2016 00:07
excellent catch @dcnr ...
Norman Dela Cruz
@dcnr
Feb 28 2016 00:08
@bitgrower @Davinw caught it :P I just repeated
adamboyer
@adamboyer
Feb 28 2016 00:10
@KrisTarling I'm still totally confused...
And @alpox I don't understand what you are trying to tell me
How am I supposed to have multiple outcomes if I don't use return
Kris Tarling
@KrisTarling
Feb 28 2016 00:13
@adamboyer sorry, brainfart - I was looking at the wrong place.
@adamboyer Your problem is what alpox was pointing to
adamboyer
@adamboyer
Feb 28 2016 00:14
what is wrong with that code
Kris Tarling
@KrisTarling
Feb 28 2016 00:14
@adamboyer You don't want to use while
adamboyer
@adamboyer
Feb 28 2016 00:14
@KrisTarling how come?
Norman Dela Cruz
@dcnr
Feb 28 2016 00:15
oh that's some makeshift if!
Stefan
@st3fun1
Feb 28 2016 00:15
@adamboyer use if
adamboyer
@adamboyer
Feb 28 2016 00:17
I don't understand, I thought the point of while() was to not have to use as many if's.
MajorPain14
@MajorPain14
Feb 28 2016 00:17
I am getting a red dot in the console output. Does anyone know what that is about?
Norman Dela Cruz
@dcnr
Feb 28 2016 00:18
@adamboyer while is a loop like for only with a simpler construct
while (/* this is true */) {
  // do this
}
Alex N.
@N0bl3
Feb 28 2016 00:19
@adamboyer the best thing to do is i think looking at the doc : (https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Instructions/return)
@adamboyer note that return keywords closes its scope returning the value. so your whil loop executes only once
adamboyer
@adamboyer
Feb 28 2016 00:22
@N0bl3 I only wanted it to execute once, or not at all.
Alex N.
@N0bl3
Feb 28 2016 00:24
@adamboyer then just use an if statement like if(blabla &&bloblo){return x;} and put the return "wrong" after the for loop like you did so that if the first didnt execute, this one will do
@adamboyer the while will keep looping if something is true even if the other while is false meaning it will be blocked in an infinite loop
@adamboyer and im sure you want to do something like console.log , not return which breaks the function?
Kris Tarling
@KrisTarling
Feb 28 2016 00:28
@N0bl3 actually, his returns are OK if the ifs they are in evaluate to true
@N0bl3 no need to keep looping if it's found the entry
if he uses 'if' obviously
Alex N.
@N0bl3
Feb 28 2016 00:30
@KrisTarling so he has to return prop? i don't remember his challenge.
Caleb Martin
@caleb272
Feb 28 2016 00:30
sorry for the long link here is a new one http://www.freecodecamp.com/challenges/arguments-optional
bitgrower
@bitgrower
Feb 28 2016 00:31
my first recommendation would be to solve what you understand ...
adamboyer
@adamboyer
Feb 28 2016 00:32
@KrisTarling I tried this and it still is not working.. Please help :worried:
//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].hasOwnProperty(firstName) && contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
      }else if (contacts[i].hasOwnProperty(firstName)){
        return "No such property";
      }

} return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "likes");
Kris Tarling
@KrisTarling
Feb 28 2016 00:32
@N0bl3 he has to find: person > property > value and return either the value, or a failure message
Caleb Martin
@caleb272
Feb 28 2016 00:32
help arguments optional
CamperBot
@camperbot
Feb 28 2016 00:32

: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

rybka02
@rybka02
Feb 28 2016 00:36
Finally completed Where art thou! After 4 days. :(
Caleb Martin
@caleb272
Feb 28 2016 00:36
holly shit ^
bitgrower
@bitgrower
Feb 28 2016 00:37
congrats, @rybka02 -- quick, right down what you learned while it's still fresh in your mind ...
rybka02
@rybka02
Feb 28 2016 00:37
Finished it with no hints. but still
The whole concept of objects i struggle with.
Well using it with filter() that is.
bitgrower
@bitgrower
Feb 28 2016 00:38
excellent!
Alex N.
@N0bl3
Feb 28 2016 00:39

@KrisTarling oh ok
@adamboyer imo the problem is what you check.

if(contacts[i].hasOwnProperty(firstName) && contacts[i].hasOwnProperty(prop)){

should be something else.
you need to look at one specific object checking it has the right name then check if it has the prop.
What you do is look at all objects that have a firstname then check if they have prop.
You don't look at if it is the RIGHT name.

bitgrower
@bitgrower
Feb 28 2016 00:39
ah ... I didn't use filter ... certain would be possible ...
Alex N.
@N0bl3
Feb 28 2016 00:40
@rybka02 nice! Did you have a look at the docs though? ;)

@adamboyer something like

if(contacts[i].hasOwnProperty(firstName) && contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){

which you could rework

@rybka02 how did yu do , using filter()?
rybka02
@rybka02
Feb 28 2016 00:42
@N0bl3 Yes. I looked at the filter() readme file

function where(collection, source) {

function filterMe(obj){
    var srcKeys = Object.keys(source);
    for (i=0;i<srcKeys.length;i++){
          if (obj[srcKeys[i]] === source[srcKeys[i]]){
              if (obj[srcKeys[i]] === undefined || obj[srcKeys[i+1]] === source[srcKeys[i+1]]){
                return obj;
            }
        }
      }
    return false;
}

var filtered = collection.filter(filterMe);
return filtered;

}
Alex N.
@N0bl3
Feb 28 2016 00:42
@rybka02 that's definitively the best place to look at ;) Thanks for sharing, i'll compare with my solution
CamperBot
@camperbot
Feb 28 2016 00:42
n0bl3 sends brownie points to @rybka02 :sparkles: :thumbsup: :sparkles:
:star: 360 | @rybka02 | http://www.freecodecamp.com/rybka02
Abhishek Challa
@abhishekchalla
Feb 28 2016 00:42

Hi, I am working on the "check for palindromes using java script", I got it working

however, I believe my code has lot of redundancy, can anyone share optimized code.
Anyone who has completed this task please ping me.

Alex N.
@N0bl3
Feb 28 2016 00:43
@rybka02
function where(collection, source) {
  var arr = [];
  var sourceKeys = Object.keys(source);

  for( var i = 0, l= collection.length; i<l; i++){
    var count = 0;
    var itemKeys = Object.keys(collection[i]);
    for (var j = 0, m=sourceKeys.length; j<m; j++){
      if (collection[i].hasOwnProperty(sourceKeys[j])){

        if(collection[i][sourceKeys[j]] === source[sourceKeys[j]] ){
          count++;

        }
      }
    }
    if(count === sourceKeys.length){
      arr.push(collection[i]);
    }
  }
    return arr;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Andrew Charlebois
@andrewchar
Feb 28 2016 00:43
working on bonfire Sum all numbers in a range. i got everything working up to the reduce part. im not sure i understand whats going on with the .reduce i keep getting arr1.reduce is not a function.
function sumAll(arr) {



  var highNum = Math.max(arr[0], arr[1]);  
 // console.log(highNum);

  var lowNum = Math.min(arr[0], arr[1]);
  //console.log(lowNum);


  var arr1= [];

  for (var i = lowNum ; i <= highNum; i++); {
       arr1 += i;

  } console.log(arr1);   

  arr1.reduce(function(a,b) {
    return a + b;
  });




 // console.log(arr1);


}

sumAll([1, 4]);
Alex N.
@N0bl3
Feb 28 2016 00:44
@rybka02 if you want to have a look at another solution as i love to do all the time haha
Caleb Martin
@caleb272
Feb 28 2016 00:45
can someone help me with the arguments optional campfire
?
rybka02
@rybka02
Feb 28 2016 00:45
sure man
bitgrower
@bitgrower
Feb 28 2016 00:45
@caleb272 -- solve the parts you konw ...
Caleb Martin
@caleb272
Feb 28 2016 00:45
i don’t know how to do this add(2)(3)
bitgrower
@bitgrower
Feb 28 2016 00:45
if you have 1 argument, and the argument is a number, you need to return... what ?
MajorPain14
@MajorPain14
Feb 28 2016 00:45
Need some help with the cipher algorithm
Caleb Martin
@caleb272
Feb 28 2016 00:46
nothnig
Abhishek Challa
@abhishekchalla
Feb 28 2016 00:46
anyone done with "Check for Palindromes"?????????
MajorPain14
@MajorPain14
Feb 28 2016 00:46
Any idea why this isn't working?
function rot13(str) { // LBH QVQ VG!
  var i = 0;
  var newArr = [];
  var codeStr;
  var string;


 for(i; i < str.length;i++){
    var c = str.charAt(i);
    var d = c.charCodeAt();
    if(d >= 78) {
      newArr.push(d-13);
    }else if (d >= 66){
      newArr.push(d+13);
    }else {
      newArr.push(d);
    }
 }

 codeStr = newArr.toString();

 string = String.fromCharCode(string);

 return string;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
rybka02
@rybka02
Feb 28 2016 00:46
@N0bl3 Why do you have l= collection.length; i<l;
uriznik
@uriznik
Feb 28 2016 00:47
@andrewchar use .push to append to an array, += coerces the array to a string it seems
rybka02
@rybka02
Feb 28 2016 00:47
@MajorPain14 I believe string is a reserved word
try str instead
bitgrower
@bitgrower
Feb 28 2016 00:48
@caleb272 -- you basically have 4 conditions to deal with ...
  1. 0 arguments passed -- easy to respond to that
  2. 2 arguments passed -- easy
  3. 1 argument passed -- if the first argument is a number, you pass a function ... you have to define the function you are pass ... and that function will validate a 2nd argument and then perform the appropriate operation
Alex N.
@N0bl3
Feb 28 2016 00:48
@MajorPain14 the problem is here
codeStr = newArr.toString();

 string = String.fromCharCode(string);
bitgrower
@bitgrower
Feb 28 2016 00:48
@rybka02 -- I believe all reserve words are syntax colored as red ...
Andrew Charlebois
@andrewchar
Feb 28 2016 00:49
@uriznik oh ok. that got rid of my error. i guess the .reduce only works on arrays
Alex N.
@N0bl3
Feb 28 2016 00:49
@rybka02 string is not reserved however String is
Caleb Martin
@caleb272
Feb 28 2016 00:49

@bitgrower

function add() {
  last = null;

  for (var a=0; a < arguments.length; a++) {
    if (typeof arguments[a] != "number") {
      return undefined;
    }
  }

  if (arguments.length == 2) {
    return arguments[0] + arguments[1];
  }

  if (arguments.length == 1) {
    if (last === null) {
      last = arguments[0];
    } else {
      return last + arguments[0];
    }
  }

}

add(2, 3);

this is what i have so far

Alex N.
@N0bl3
Feb 28 2016 00:50
@rybka02 that's because i was recently on a course where the subject was optimization and they recommended to declare vars before. However i think this is a very minor change considering my function lol
bitgrower
@bitgrower
Feb 28 2016 00:51
so, instead of returning last, you have to define a function,, and then return the function to the caller, along with the first variable ...
rybka02
@rybka02
Feb 28 2016 00:52
@N0bl3 But why not just i<collection.length;
Ogechi Ike
@BlackMG27
Feb 28 2016 00:52
@bitgrower Sure
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
    for(var i=0; i < arr.length; i++){
      for(var j=0; j < arr[i].length; j++){
         product * arr[i][j];
      }
    }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
rybka02
@rybka02
Feb 28 2016 00:53
use reduce() for that challenge
Devin
@devblanchard
Feb 28 2016 00:53
i'm confused on how to use replace with toLowerCase
Alex N.
@N0bl3
Feb 28 2016 00:54
@rybka02 because the way they taught me is that it reads collection.length only once whereas in what you say it checks collection.length at every iteration. Meaning that in a collection of thousands of datas it may have a negative impact on performance
bitgrower
@bitgrower
Feb 28 2016 00:54
@BlackMG27 -- you're pretty close, I think ... in your loop, your multiplication does nothing ...
I mean, it creates a value -- but does nothing with the value ...
Caleb Martin
@caleb272
Feb 28 2016 00:54
//1 argument passed -- if the first argument is a number, you pass a function ... you have to define the function you are pass ... and that function will validate a 2nd argument and then perform the appropriate operation

function add() {

  for (var a=0; a < arguments.length; a++) {
    if (typeof arguments[a] != "number") {
      return undefined;
    }
  }

  if (arguments.length == 2) {
    return arguments[0] + arguments[1];
  }

  function test() {
    var first = arguments[0];
  }

  if (arguments.length == 1) {
    if (last === null) {
      last = arguments[0];
    } else {
      return test;
    }
  }

}

add(2, 3);
but how do i add them when its passed back to me
rybka02
@rybka02
Feb 28 2016 00:55
@N0bl3 Oh ok. Interesting.
bitgrower
@bitgrower
Feb 28 2016 00:55

you have to do something like ...

return function { <define function here> }

that function needs to accept a variable, check it for being a number, and then, if so, perform the required operation ...
Ogechi Ike
@BlackMG27
Feb 28 2016 00:57
@bitgrower should I make var j add to arr[i].length instead of j++?
@bitgrower I removed return like @dcnr suggested, and I still get 1 in the console.
Caleb Martin
@caleb272
Feb 28 2016 00:59
//1 argument passed -- if the first argument is a number, you pass a function ... you have to define the function you are pass ... and that function will validate a 2nd argument and then perform the appropriate operation

function add() {

  for (var a=0; a < arguments.length; a++) {
    if (typeof arguments[a] != "number") {
      return undefined;
    }
  }

  if (arguments.length == 2) {
    return arguments[0] + arguments[1];
  }

  if (arguments.length == 1) {
    if (last === null) {
      last = arguments[0];
    } else {
      return function(second) {
        var first = arguments[0];

        if(typeof second === "number") {
          return first + second;
        } else {
          return undefined;
        }

      };
    }
  }

}

add(2)(3);
its returning 6
Norman Dela Cruz
@dcnr
Feb 28 2016 00:59
@BlackMG27 will you post your entire code again?
@caleb272 arguments[0] in your closure refers to your closure's arguments object so you're getting 3 + 3
Caleb Martin
@caleb272
Feb 28 2016 01:00
o ok
Norman Dela Cruz
@dcnr
Feb 28 2016 01:00
@caleb272 if you want to do var first = arguments[0] it has to be (somewhere) in the main body of add()
bitgrower
@bitgrower
Feb 28 2016 01:01
@BlackMG27 -- if I want to iterate over a bunch of values ... and add them together ...
Ogechi Ike
@BlackMG27
Feb 28 2016 01:02
@dcnr Sure
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
    for(var i=0; i < arr.length; i++){
      for(var j=0; j < arr[i].length; j++){
         product * arr[i][j];
      }
    }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Norman Dela Cruz
@dcnr
Feb 28 2016 01:02
@BlackMG27 oh you're not "catching" the value produced by product * arr[i][j]
bitgrower
@bitgrower
Feb 28 2016 01:02
@BlackMG27 -- you fix the one multiplication line, you'll have it ...
Moisés Man
@moigithub
Feb 28 2016 01:03
@BlackMG27 u need to store the result of that calculation somewhere or it will be lost
bitgrower
@bitgrower
Feb 28 2016 01:03
but, right now ... it does a multiplication and does nothing with it ... so, as @moigithub says -- it will be lost
Caleb Martin
@caleb272
Feb 28 2016 01:03

@bitgrower thanks i got it

//1 argument passed -- if the first argument is a number, you pass a function ... you have to define the function you are pass ... and that function will validate a 2nd argument and then perform the appropriate operation

function add() {
  var firstAdd = arguments[0];

  for (var a=0; a < arguments.length; a++) {
    if (typeof arguments[a] != "number") {
      return undefined;
    }
  }

  if (arguments.length == 2) {
    return arguments[0] + arguments[1];
  }

  if (arguments.length == 1) {
    if (last === null) {
      last = arguments[0];
    } else {
      return function(second) {
        var first = firstAdd;

        if(typeof second === "number") {
          return first + second;
        } else {
          return undefined;
        }

      };
    }
  }

}

add(2)(3);

but why would someone make such an ugly implementation

CamperBot
@camperbot
Feb 28 2016 01:03
caleb272 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 655 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 28 2016 01:04
awesome ! yw @caleb272
Andrew Charlebois
@andrewchar
Feb 28 2016 01:04
my console log showing the answers that the exercise wants but its not passing the test.
function sumAll(arr) {



  var highNum = Math.max(arr[0], arr[1]);  
 // console.log(highNum);
  var lowNum = Math.min(arr[0], arr[1]);
  //console.log(lowNum);

  var arr1= [];

  for (var i = lowNum ; i <= highNum; i++); {
       arr1.push(i);
  } //console.log(arr1);   

   var arr2 = arr1.reduce(function(previousValue, currentValue) {
  return previousValue + currentValue;
});



 console.log(arr2);


}

sumAll([1, 4]);
Brian
@sludge256
Feb 28 2016 01:04
lol
Moisés Man
@moigithub
Feb 28 2016 01:04
@caleb272 u made a "last" variable.. but .. where u using that ?
Caleb Martin
@caleb272
Feb 28 2016 01:05
//1 argument passed -- if the first argument is a number, you pass a function ... you have to define the function you are pass ... and that function will validate a 2nd argument and then perform the appropriate operation

function add() {
  var last = arguments[0];

  for (var a=0; a < arguments.length; a++) {
    if (typeof arguments[a] != "number") {
      return undefined;
    }
  }

  if (arguments.length == 2) {
    return arguments[0] + arguments[1];
  }

  if (arguments.length == 1) {
    if (last === null) {
      last = arguments[0];
    } else {
      return function(second) {
        var first = last;

        if(typeof second === "number") {
          return first + second;
        } else {
          return undefined;
        }

      };
    }
  }

}

add(2)(3);
oops i fixed it hahah
Moisés Man
@moigithub
Feb 28 2016 01:06
@andrewchar u have a extra semicolon at end for() ; <--
Norman Dela Cruz
@dcnr
Feb 28 2016 01:06
@caleb272 you could have also just moved it like this:
else {
  var first = arguments[0];
  return function(second) {
    // etc
bitgrower
@bitgrower
Feb 28 2016 01:07
@andrewchar -- which challenge is that ...
Andrew Charlebois
@andrewchar
Feb 28 2016 01:07
@moigithub oh did not catch that thank you. but still not giving correct answer
CamperBot
@camperbot
Feb 28 2016 01:07
andrewchar sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 674 | @moigithub | http://www.freecodecamp.com/moigithub
Ogechi Ike
@BlackMG27
Feb 28 2016 01:07
@dcnr @bitgrower @moigithub I had to use product twice. Thanks!
CamperBot
@camperbot
Feb 28 2016 01:07
blackmg27 sends brownie points to @dcnr and @bitgrower and @moigithub :sparkles: :thumbsup: :sparkles:
Andrew Charlebois
@andrewchar
Feb 28 2016 01:07
@bitgrower sum all numbers in range
CamperBot
@camperbot
Feb 28 2016 01:07
:star: 741 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 656 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 675 | @moigithub | http://www.freecodecamp.com/moigithub
Norman Dela Cruz
@dcnr
Feb 28 2016 01:07
awesome! :D @BlackMG27 thanks too
CamperBot
@camperbot
Feb 28 2016 01:07
dcnr sends brownie points to @blackmg27 :sparkles: :thumbsup: :sparkles:
:star: 127 | @blackmg27 | http://www.freecodecamp.com/blackmg27
bitgrower
@bitgrower
Feb 28 2016 01:07
@BlackMG27 -- what does that line look like now ?
Andrew Charlebois
@andrewchar
Feb 28 2016 01:08
@bitgrower my console is printing the numbers 10 and 45 so im not sure whats going on
bitgrower
@bitgrower
Feb 28 2016 01:08
which challenge is it ?
Norman Dela Cruz
@dcnr
Feb 28 2016 01:08
@andrewchar you've yet to return arr2
Andrew Charlebois
@andrewchar
Feb 28 2016 01:09
@bitgrower sum all numbers in range
Norman Dela Cruz
@dcnr
Feb 28 2016 01:09
@andrewchar rather than console.log shouldn't you return arr2;? :D
Andrew Charlebois
@andrewchar
Feb 28 2016 01:09
@dcnr LOL
bitgrower
@bitgrower
Feb 28 2016 01:10
This message was deleted
Andrew Charlebois
@andrewchar
Feb 28 2016 01:10
@dcnr thanks
CamperBot
@camperbot
Feb 28 2016 01:10
andrewchar sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 742 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 28 2016 01:10
you're welcome, thanks too @andrewchar
CamperBot
@camperbot
Feb 28 2016 01:10
dcnr sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 323 | @andrewchar | http://www.freecodecamp.com/andrewchar
Andrew Charlebois
@andrewchar
Feb 28 2016 01:11
@dcnr i thought my return in the .reduce function was returning arr2
Norman Dela Cruz
@dcnr
Feb 28 2016 01:11
@andrewchar ahah :P
bitgrower
@bitgrower
Feb 28 2016 01:12
This message was deleted
@andrewchar -- THAT return is returning control back from the callback function you called in arr1.reduce
adamboyer
@adamboyer
Feb 28 2016 01:13
Success!!!!!!!! just finished the profile lookup!!! literally took me 6 hours...
Andrew Charlebois
@andrewchar
Feb 28 2016 01:14
im wondering a way to make this now so i dont have to use 2 variables
instead of taking info from var arr1, putting it into arr2 and then returning that
Norman Dela Cruz
@dcnr
Feb 28 2016 01:14
congrats! :D @adamboyer
Nick Robson
@nickrobson
Feb 28 2016 01:14
function sum(arr) {
   var lo = Math.min(...arr);
   var hi = arr[1-arr.indexOf(lo)];
   return Array.apply(null, {length: hi-lo+1}).map(Number.call, Number).map(a => a+lo).reduce((p,c) => p+c);
}
Alternate solution to @andrewchar 's question. :)
philipsiu
@philipsiu
Feb 28 2016 01:15
Can anyone help with the challenge "Caesars Cipher"?
Norman Dela Cruz
@dcnr
Feb 28 2016 01:15
@nickrobson oh that's close to my solution! :D
Andrew Charlebois
@andrewchar
Feb 28 2016 01:15
@nickrobson not even sure what to make of that lol
adamboyer
@adamboyer
Feb 28 2016 01:16
Thanks @dcnr I almost broke my laptop over my knee at one point...
CamperBot
@camperbot
Feb 28 2016 01:16
adamboyer sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 743 | @dcnr | http://www.freecodecamp.com/dcnr
Nick Robson
@nickrobson
Feb 28 2016 01:16
@dcnr Nice, haha! I like the idea of using a sorted array.
Andrew Charlebois
@andrewchar
Feb 28 2016 01:16
your solutions are so much shorter then mine lol
Norman Dela Cruz
@dcnr
Feb 28 2016 01:16
@adamboyer ahah always take a break! :P
@andrewchar it's not always about how short it is though :D
@nickrobson I think Math.min's faster than this sort, even though it's just two element array
Moisés Man
@moigithub
Feb 28 2016 01:17
@adamboyer 6 hours not bad ... im doin an exercise.. and still working on it... gonna be a whole month next week n didnt finish yet :)
Nick Robson
@nickrobson
Feb 28 2016 01:17
function sum(arr) {
   arr.sort();
   return Array.apply(null, {length: arr[1]-arr[0]+1}).map(Number.call, Number).map(a => a+arr[0]).reduce((p,c) => p+c);
}
That's a shorter one, combining both of ours :)
Andrew Charlebois
@andrewchar
Feb 28 2016 01:19
well it still counts that i got it right? haha
Norman Dela Cruz
@dcnr
Feb 28 2016 01:19
@nickrobson ooh I haven't used that! destructuring? I forgot what it's called lol
Nick Robson
@nickrobson
Feb 28 2016 01:19
@dcnr Do you mean the ... ?
Krista Handel
@meloncatty
Feb 28 2016 01:19
hello all! I'm doing the record collection challenged with JSON and I'm just wondering if I need to loop through the collection in order to update it
Andrew Charlebois
@andrewchar
Feb 28 2016 01:20
@dcnr for your solution what is this.. / exports /
module.exports = sumAll;
Norman Dela Cruz
@dcnr
Feb 28 2016 01:20
@nickrobson the {length:} part, I knew I saw it somewhere while I was looking up something, and the last thing I looked up was destructuring
@nickrobson just can't remember what that's called
@andrewchar that's for node, I'm exporting my function so I can use it as a module (my test runner)
Nick Robson
@nickrobson
Feb 28 2016 01:21
const sum = arr => Array.apply(null, {length: arr.sort()[1]-arr[0]+1}).map(Number.call, Number).map(a => a+arr[0]).reduce((p,c) => p+c);
sum([1,4]); // 10
Moisés Man
@moigithub
Feb 28 2016 01:23
didnt knew about {length: x} argument.. only saw examples like this
Array.apply(null, new Array(5)) to generate array
Norman Dela Cruz
@dcnr
Feb 28 2016 01:24
@nickrobson this part Array.apply(null, {length: arr.sort()[1]-arr[0]+1}), it's a destructuring assignment right?
via argument defaults
Nick Robson
@nickrobson
Feb 28 2016 01:25
const sum=b=>Array.apply(null,{length:b.sort()[1]-b[0]+1}).map(Number.call,Number).map(a=>a+b[0]).reduce((p,c)=>p+c);
@dcnr Array.apply takes an object with a length property.
bitgrower
@bitgrower
Feb 28 2016 01:26
@meloncatty is your request getting lost in all this ES6 play ?
Nick Robson
@nickrobson
Feb 28 2016 01:26
new Array(n) returns an array which has a length property.
(which is why that also works)
Norman Dela Cruz
@dcnr
Feb 28 2016 01:26
@nickrobson ooh I see!
Krista Handel
@meloncatty
Feb 28 2016 01:27
@bitgrower sure.
Nick Robson
@nickrobson
Feb 28 2016 01:27
new Array(n)
{length:n}
I use the second because it's shorter xD
Andrew Charlebois
@andrewchar
Feb 28 2016 01:27
@dcnr do you work for fcc?
@dcnr volunteer i mean
philipsiu
@philipsiu
Feb 28 2016 01:28
function rot13(str) {
    var strNum = [];
    var newArr = [];
    for (var h = 0; h < str.length; h++) {
        strNum.push(str[h].charCodeAt());
    }
    for (var i = 0; i < strNum.length; i++) {
        if (strNum[i] !== 32 && strNum[i] > 77) {
            newArr.push(String.fromCharCode(strNum[i] - 13));
        } else if (strNum[i] !== 32 && strNum[i] > 64) {
            newArr.push(String.fromCharCode(strNum[i] + 13));
        } else if (strNum[i] === 32) {
            newArr.push(String.fromCharCode(strNum[i]));
        }
    }
    console.log(newArr.join(""));
}

rot13("SERR YBIR?");
I'm doing something wrong here with Caesar's Cipher.
Norman Dela Cruz
@dcnr
Feb 28 2016 01:28
@andrewchar no I don't, why you ask though?
bitgrower
@bitgrower
Feb 28 2016 01:28
post your code @meloncatty -- that will get more attention ...
Norman Dela Cruz
@dcnr
Feb 28 2016 01:28
thanks for the tip @nickrobson !
CamperBot
@camperbot
Feb 28 2016 01:28
dcnr sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 402 | @nickrobson | http://www.freecodecamp.com/nickrobson
Andrew Charlebois
@andrewchar
Feb 28 2016 01:28
@dcnr just looking at your git. thought you were adding content and stuff from what i seen
Norman Dela Cruz
@dcnr
Feb 28 2016 01:29
@andrewchar ah no :P it's just my solution repo
bitgrower
@bitgrower
Feb 28 2016 01:29
@philthyfill -- post your code, please !
philipsiu
@philipsiu
Feb 28 2016 01:29
@bitgrower Just posted it.
bitgrower
@bitgrower
Feb 28 2016 01:30
where? Not seeing it, @philthyfill
Andrew Charlebois
@andrewchar
Feb 28 2016 01:30
@bitgrower f5
Krista Handel
@meloncatty
Feb 28 2016 01:30
// Only change code below this line
function update(id, prop, value) {

//if value is non-blank and prop is not "tracks", update/set value for prop
  if(value !== "" && prop !== "tracks"){
    collection[id].artist = value;
  }

//if prop is "tracks" and value is non-blank, push value onto end of tracks array
  if(value !== "" && prop === "tracks"){
    collection[id].tracks = value;
  } else {

  }

//if value is blank, delete the prop

  return collection;
}
philipsiu
@philipsiu
Feb 28 2016 01:30
function rot13(str) {
    var strNum = [];
    var newArr = [];
    for (var h = 0; h < str.length; h++) {
        strNum.push(str[h].charCodeAt());
    }
    for (var i = 0; i < strNum.length; i++) {
        if (strNum[i] !== 32 && strNum[i] > 77) {
            newArr.push(String.fromCharCode(strNum[i] - 13));
        } else if (strNum[i] !== 32 && strNum[i] > 64) {
            newArr.push(String.fromCharCode(strNum[i] + 13));
        } else if (strNum[i] === 32) {
            newArr.push(String.fromCharCode(strNum[i]));
        }
    }
    console.log(newArr.join(""));
}

rot13("SERR YBIR?");
Nick Robson
@nickrobson
Feb 28 2016 01:30
Put ```js instead of just the three backticks to fix the syntax colouring please, @meloncatty
Andrew Charlebois
@andrewchar
Feb 28 2016 01:30
@dcnr you long have you been coding
@dcnr just curious
Nick Robson
@nickrobson
Feb 28 2016 01:31
@philthyfill You need to check if the character is a letter before you shift it.
bitgrower
@bitgrower
Feb 28 2016 01:31
@meloncatty -- you need to post all the code ... including the data structures, etc ...
Krista Handel
@meloncatty
Feb 28 2016 01:32
ok
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

//if value is non-blank and prop is not "tracks", update/set value for prop
  if(value !== "" && prop !== "tracks"){
    collection[id].artist = value;
  }

//if prop is "tracks" and value is non-blank, push value onto end of tracks array
  if(value !== "" && prop === "tracks"){
    collection[id].tracks = value;
  } else {

  }

//if value is blank, delete the prop


  return collection;
}

// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");
Nick Robson
@nickrobson
Feb 28 2016 01:32
@meloncatty You're using this, which sets the tracks value to the given value, NOT appending it.
collection[id].tracks = value;
Krista Handel
@meloncatty
Feb 28 2016 01:33
ok
Nick Robson
@nickrobson
Feb 28 2016 01:33
You need to use Array#push instead.
Similarly, in the first part, you need to set the prop property, not the "artist" property.
Norman Dela Cruz
@dcnr
Feb 28 2016 01:33
@andrewchar I don't really know, it's more like a hobby. And there are years that I didn't even touch it. I first started with C around 2001 though
philipsiu
@philipsiu
Feb 28 2016 01:34
@nickrobson What string function do I use to check if it's a character?
Nick Robson
@nickrobson
Feb 28 2016 01:34
@philthyfill There isn't one, you need to compare the char code.
Hint: 'a' char code < 'z' char code, and 'A' char code < 'Z' char code. They're in alphabetical order.
CamperBot
@camperbot
Feb 28 2016 01:34
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Nick Robson
@nickrobson
Feb 28 2016 01:35
A = 65, Z = 90
a = 97, z = 122
Krista Handel
@meloncatty
Feb 28 2016 01:35
@nickrobson okay that brings me back to my original question. do i need to loop through the collection in order to update it? would that be more efficient??
Nick Robson
@nickrobson
Feb 28 2016 01:35
@meloncatty No.
Krista Handel
@meloncatty
Feb 28 2016 01:36
@nickrobson thanks
CamperBot
@camperbot
Feb 28 2016 01:36
meloncatty sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 403 | @nickrobson | http://www.freecodecamp.com/nickrobson
philipsiu
@philipsiu
Feb 28 2016 01:38
function rot13(str) {
    var strNum = [];
    var newArr = [];
    for (var h = 0; h < str.length; h++) {
        strNum.push(str[h].charCodeAt());
    }
    // console.log(strNum);
    for (var i = 0; i < strNum.length; i++) {
        if (strNum[i] !== 32 && strNum[i] > 77) {
            newArr.push(String.fromCharCode(strNum[i] - 13));
        } else if (strNum[i] !== 32 && strNum[i] > 64) {
            newArr.push(String.fromCharCode(strNum[i] + 13));
        } else if (strNum[i] < 64) {
            newArr.push(String.fromCharCode(strNum[i]));
        }
    }
    return newArr.join("");
}

rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
@nickrobson Thanks. The method I used was kinda hacked together to get the solution.
CamperBot
@camperbot
Feb 28 2016 01:39
philthyfill sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 404 | @nickrobson | http://www.freecodecamp.com/nickrobson
Nick Robson
@nickrobson
Feb 28 2016 01:43
Short solution I came up with:
var rot13=s=>s.split('').map(i=>i.charCodeAt()).map(i=>i<65||i>90?i>96&&i<123?((i-97)+13)%26+97:i:((i-65)+13)%26+65).map(i=>String.fromCharCode(i)).join``;
Moisés Man
@moigithub
Feb 28 2016 01:47
using regex probably will be a lot shorter
Alex N.
@N0bl3
Feb 28 2016 01:47
the steamroller challenge is something
bitgrower
@bitgrower
Feb 28 2016 01:48
@philthyfill -- first get it working, then you can make it better ... :)
Nick Robson
@nickrobson
Feb 28 2016 01:50
wiki steamroller
CamperBot
@camperbot
Feb 28 2016 01:50

:point_right: algorithm steamroller [wiki]

Explanation:

This problem seems simple but you need to make sure to flatten any array, regardless of the level which is what adds a bit of difficulty to the problem.

:pencil: read more about algorithm steamroller on the FCC Wiki

Moisés Man
@moigithub
Feb 28 2016 01:52
var rot13=(str)=>{ return str.replace(/[a-z]/gi,c=>String.fromCharCode((c.charCodeAt(0)-65+13) %26+65))}
Alex N.
@N0bl3
Feb 28 2016 01:53
Guys i found the solution to steamroller ... almost by random but hey that's SO REFRESHING!
@nickrobson you need help?i'm not sure i can help you considering the function you design haha
Nick Robson
@nickrobson
Feb 28 2016 01:55
@moigithub nice! didn't even think about using a callback like that
Andrew Charlebois
@andrewchar
Feb 28 2016 01:56
you guys think its cheating that once you complete an algorithm that you check the answer to compare
bitgrower
@bitgrower
Feb 28 2016 01:56
no ... not at all ... I consider it a way of advancing your knowledge ...
Nick Robson
@nickrobson
Feb 28 2016 01:58
@moigithub
var rot13=s=>s.replace(/[a-z]/gi,c=>String.fromCharCode((c.charCodeAt(0)-(c.charCodeAt(0)<91?65:97)+13)%26+(c.charCodeAt(0)<91?65:97)));
Yours doesn't work with lowercase.
Moisés Man
@moigithub
Feb 28 2016 01:59
nope no lowercase... think the exercise only had uppercases characters
Nick Robson
@nickrobson
Feb 28 2016 02:02
var rot13=s=>s.replace(/[A-Z]/g,c=>String.fromCharCode((c.charCodeAt(0)-65+13)%26+65));
In that case you could reduce it by a lot more chars!
Moisés Man
@moigithub
Feb 28 2016 02:05
var rot13=(str)=> str.replace(/[a-z]/gi,c=>{var a=c.toUpperCase()==c?0:32; return String.fromCharCode((c.charCodeAt(0)-65+13) %26+65+a)})
probably should handle lowercases too, should be doing the same thing as urs (didnt test)
Alex N.
@N0bl3
Feb 28 2016 02:06
bf binary
CamperBot
@camperbot
Feb 28 2016 02:06

:fire:Bonfire: Binary Agents :link:

function binaryAgent(str) {
  return str;
}

binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');

Return an English translated sentence of the passed binary string.

more info:  bf details | bf links | hint

Alex N.
@N0bl3
Feb 28 2016 02:06
HUm, is there some built in functions for Binary codes like in Node JS Buffers or so?
Nicolas Accetta
@niconiahi
Feb 28 2016 02:07
hello guys
if i wanna get out of a loop
can i use return;
and just return;
AudioGen
@AudioGen
Feb 28 2016 02:07
I'm on the queue exercise, how does this work?
Alex N.
@N0bl3
Feb 28 2016 02:07
@niconiahi you can.
Moisés Man
@moigithub
Feb 28 2016 02:08
parseInt ?? with base 2 ? @N0bl3
bitgrower
@bitgrower
Feb 28 2016 02:08
to get out of a loop ... break; ... to get out of an iteration: continue
Alex N.
@N0bl3
Feb 28 2016 02:08
@moigithub lol? I would better go to sleep......... thx
CamperBot
@camperbot
Feb 28 2016 02:08
n0bl3 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 676 | @moigithub | http://www.freecodecamp.com/moigithub
AudioGen
@AudioGen
Feb 28 2016 02:09
Anyone know how the queue works?
bitgrower
@bitgrower
Feb 28 2016 02:09
@AudioGen -- you need to know 2 Array functions ... you can read about the various array functions on Mozilla Developer Network (MDN) ... many are quite nice ... once you find the 2 functions (aka methods) the problem is very easy to solve ...
AudioGen
@AudioGen
Feb 28 2016 02:10
.pop() and .push() ?
Moisés Man
@moigithub
Feb 28 2016 02:10
queue = FIFO
bitgrower
@bitgrower
Feb 28 2016 02:10
close ... @AudioGen -- but not quite right ...
AudioGen
@AudioGen
Feb 28 2016 02:10
hmmm
Andrew Charlebois
@andrewchar
Feb 28 2016 02:11
@bitgrower wow their solutions... omg it was so simple. i overthink things way to much lmao
Alex N.
@N0bl3
Feb 28 2016 02:12
@andrewchar how do you know other people solutions after having completed a bf? I would like to have a look at more experienced people answer
Andrew Charlebois
@andrewchar
Feb 28 2016 02:13
@N0bl3 algorithms hints/tips/solutions are posted in fcc wiki
Alex N.
@N0bl3
Feb 28 2016 02:13
@andrewchar okay! thanks ! :)
CamperBot
@camperbot
Feb 28 2016 02:13
n0bl3 sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 325 | @andrewchar | http://www.freecodecamp.com/andrewchar
Andrew Charlebois
@andrewchar
Feb 28 2016 02:14
np
AudioGen
@AudioGen
Feb 28 2016 02:15
@bitgrower yah I'm not getting it. I'm using .push() and .shift() but I don't know how to structure the arguments. The exercise is asking me to write in the function
bitgrower
@bitgrower
Feb 28 2016 02:16
post your code, @AudioGen -- let's see if we can't see what the problem is ...
it's helpful to read the pages on each of those functions so you understand what they do to the array, as well as what they may or may return ...
@andrewchar -- which challenge are you looking at the solution of ... ?
Ryan Price
@rsprice
Feb 28 2016 02:17
var fs   = require('fs');
var path = require('path');

module.exports = function (dir, extStr, callback) {
  fs.readdir(dir, function(err, data) {
    if (err) {
      return callback(err);
    }
    data.forEach(function(file) {
      if (path.extname(file) === '.' + extStr) {
        callback(null, file);
      }
    });
  });
};
AudioGen
@AudioGen
Feb 28 2016 02:17

function queue(arr, item) {
// Your code here
item.push(); / My addition /
arr.shift(); / My addition /
return item; // Change this line
}

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

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

Ryan Price
@rsprice
Feb 28 2016 02:17
var filterExtNames = require('./ex6b');
var dirName        = process.argv[2];
var extName        = process.argv[3];

filterExtNames(dirName, extName, function(err, data) {
  if (err) {
    console.log(err);
  }
  console.log(data);
});
Andrew Charlebois
@andrewchar
Feb 28 2016 02:17
@bitgrower sum all number in a range
AudioGen
@AudioGen
Feb 28 2016 02:18
Yes I understand the functions for the most part
Ryan Price
@rsprice
Feb 28 2016 02:18
Can anyone see any errors in my logic? I'm getting this error from learnyounode : TypeError: Cannot read property 'call' of undefined
AudioGen
@AudioGen
Feb 28 2016 02:18
The native functions I'm referring to
Ryan Price
@rsprice
Feb 28 2016 02:19
apparently callback(null, file) in the forEach loop I'm using is what is causing it. Halp!
@AudioGen
help format
CamperBot
@camperbot
Feb 28 2016 02:19

: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

Ryan Price
@rsprice
Feb 28 2016 02:20
Also, learnyounode is telling me that my expected output and my actual output are exactly the same!
Moisés Man
@moigithub
Feb 28 2016 02:22
@rsprice r u sure u need to use console.log instead returning ?
dont remember the exersice.. was too long ago :D
bitgrower
@bitgrower
Feb 28 2016 02:22
it's a backend exercise ...
Caleb Martin
@caleb272
Feb 28 2016 02:22
nice you are no the backend tuts
Ryan Price
@rsprice
Feb 28 2016 02:22
@moigithub "Print the
list of files (one file per line) to the console. You must use
asynchronous I/O."
@bitgrower mhmmm it is. Is that bad? :D
bitgrower
@bitgrower
Feb 28 2016 02:23
I'm not impressed with learnyounode .. I think that's why FCC tells you where their github is located ...
Ryan Price
@rsprice
Feb 28 2016 02:24
lol
bitgrower
@bitgrower
Feb 28 2016 02:25
@AudioGen ... how are you doing ... ?
AudioGen
@AudioGen
Feb 28 2016 02:26

```<function queue(arr, item) {
// Your code here
item.push();
arr.shift();
return item; // Change this line
}

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

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

```

:D
not good apparently
bitgrower
@bitgrower
Feb 28 2016 02:26
close on the formatting -- edit your message so that you have ```js on a line by itself ..
This message was deleted
Moisés Man
@moigithub
Feb 28 2016 02:28
@rsprice ok i know.. if err.. u only console.log..
but u NOT stopping the execution.. so it continuing...
Ryan Price
@rsprice
Feb 28 2016 02:28
@moigithub I tried that :)
Moisés Man
@moigithub
Feb 28 2016 02:29
to.. console.log(data);
which its undefined... probably if err
return console.log(err)
bitgrower
@bitgrower
Feb 28 2016 02:30

okay ... on this example you have arr = [1.2.3.4.5] and item = 6 ...

you need to push item onto arr ...

how do you do that ?
Ryan Price
@rsprice
Feb 28 2016 02:30
@moigithub it simply cannot be return console.log(err)
there is no way
Vik
@vvang044
Feb 28 2016 02:30
arr.push[]
Moisés Man
@moigithub
Feb 28 2016 02:31
did u tried ? :)
Ryan Price
@rsprice
Feb 28 2016 02:31
I also tried return err, throw err, and console.log(err)
bitgrower
@bitgrower
Feb 28 2016 02:31
@vvang -- asking @AudioGen ...
AudioGen
@AudioGen
Feb 28 2016 02:31
@bitgrower arr.push(item);
bitgrower
@bitgrower
Feb 28 2016 02:31
cool ... so, put that in your code ...
Ryan Price
@rsprice
Feb 28 2016 02:31
@moigithub yeah that doesn't work either
Andrew Charlebois
@andrewchar
Feb 28 2016 02:32
If anyone is doing intermediate algorithms and wants to pair program pm me. im currently just starting the second one in the list
bitgrower
@bitgrower
Feb 28 2016 02:33
@andrewchar -- I think there may be a room for folks wanting to pair program ...
help rooms
CamperBot
@camperbot
Feb 28 2016 02:33

:point_right: help rooms [wiki]

Help Rooms

Choose the right room for your question!

:pencil: read more about help rooms on the FCC Wiki

bitgrower
@bitgrower
Feb 28 2016 02:33
nope, don't see it there ... but I thought there was one ..
Caleb Martin
@caleb272
Feb 28 2016 02:33
i want a pair programming room
bitgrower
@bitgrower
Feb 28 2016 02:34
FCC has a BOATLOAD of rooms ...
help pair programming
CamperBot
@camperbot
Feb 28 2016 02:34

:point_right: pair programming and why it is special [wiki]

Pair Programming is an Agile Development practice that was born out of the Extreme Programming movement.

Working as a team of [exactly] two, at a single computer, the pair will slide the keyboard and mouse back-and-forth throughout a "pairing session". This increases the code quality by providing a "greater than the sum of its parts" effect of two developers working on a single problem domain.

The increase in quality of the code, combined with the effect of knowledge and understanding on the project being spread across multiple developers, can produce a large savings in cost on the project as a whole.

In a Test Driven Development (TDD) shop, it is most common for each member of the pair to take turns a) writing a test and b) writing code to pass the test. This "ping pong" yields a cumulative effect on the overall quality of the final product.

To be most effective it is important that pairs are intermixed; not the same couple of developers always working together.

Pair programming is considered to be very "social". It can be akin to a marriage because you learn to cooperate with a peer in a close, give-and-take relationship. As such it is often very difficult to become comfortable with pair programming. Some developers simply NEVER feel quite at-home. In the end, the willingness to share, be a bit vulnerable and work cooperatively toward a better product will make you a far better developer (and a better person overall).

:pencil: read more about pair programming and why it is special on the FCC Wiki

bitgrower
@bitgrower
Feb 28 2016 02:37
hmmm ... no mention there of a room ... alas ...
Vik
@vvang044
Feb 28 2016 02:38
how to do the exercise "split strings with split?
understood the example.....
Ryan Price
@rsprice
Feb 28 2016 02:39
@bitgrower @moigithub thanks, lol I figured it out
CamperBot
@camperbot
Feb 28 2016 02:39
rsprice sends brownie points to @bitgrower and @moigithub :sparkles: :thumbsup: :sparkles:
:star: 677 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 657 | @bitgrower | http://www.freecodecamp.com/bitgrower
Moisés Man
@moigithub
Feb 28 2016 02:39
@rsprice what was ?
bitgrower
@bitgrower
Feb 28 2016 02:40
Awesome -- thanks @moigithub -- how'd you find it ?
CamperBot
@camperbot
Feb 28 2016 02:40
bitgrower sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 678 | @moigithub | http://www.freecodecamp.com/moigithub
bitgrower
@bitgrower
Feb 28 2016 02:40
hint sum all numbers in a range
CamperBot
@camperbot
Feb 28 2016 02:40
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Ryan Price
@rsprice
Feb 28 2016 02:40
@moigithub it wanted me to return the files as a filtered array, or at least that's how I made it work
Moisés Man
@moigithub
Feb 28 2016 02:41
@bitgrower i joined long ago,, so its on my list :)
Ryan Price
@rsprice
Feb 28 2016 02:41
@moigithub I think it only wanted to execute the callback from the main program once, and I was doing it for every element I was iterating over
Vik
@vvang044
Feb 28 2016 02:41
anyone?
bitgrower
@bitgrower
Feb 28 2016 02:41
@vvang044 -- post where you're at .. (eg, your code) ...
Alex N.
@N0bl3
Feb 28 2016 02:42
Thanks all today was very useful i managed to walk through all Intermediate challenges partly thanks to you ;)
bitgrower
@bitgrower
Feb 28 2016 02:43
wow ... that's awesome, @N0bl3 -- congrats ...
Vik
@vvang044
Feb 28 2016 02:44
var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split();
Moisés Man
@moigithub
Feb 28 2016 02:45
@vvang044 split requires an argument...
Vik
@vvang044
Feb 28 2016 02:45
i have to use split to create an array of words
bitgrower
@bitgrower
Feb 28 2016 02:45
okay ... how does the split method work ?
Moisés Man
@moigithub
Feb 28 2016 02:45
if u dont know how to.. best way is to check the documentation... (i always do, easy forget )
demipixel
@demipixel
Feb 28 2016 02:45
@bitgrower It takes a string and splits it into an array
demipixel
@demipixel
Feb 28 2016 02:46
This message was deleted
bitgrower
@bitgrower
Feb 28 2016 02:46
This message was deleted
demipixel
@demipixel
Feb 28 2016 02:47
I think @moigithub got fooled too lol
bitgrower
@bitgrower
Feb 28 2016 02:47
and I agree with @moigithub -- refer to the documentation ... it can be of enormous help ...
Vik
@vvang044
Feb 28 2016 02:47
@demipixel i was reading what you wrote
bitgrower
@bitgrower
Feb 28 2016 02:48
@vvang044 -- you can find the info he wrote in the documentation ...
seriously --- go check out the Mozilla Developer Network page or the link @moigithub has posted, and you should have your answer quickly ...
Vik
@vvang044
Feb 28 2016 02:49
let me do that
gottdammit.......lol
Alex N.
@N0bl3
Feb 28 2016 02:50
@bitgrower MDN is definitively the website i visited the most during the last 6 months haha and probably 90% of us too
bhagwant
@sagit2002
Feb 28 2016 02:50
hi everybody
Vik
@vvang044
Feb 28 2016 02:50
when i first did that....it did with no space between
Alex N.
@N0bl3
Feb 28 2016 02:50
@sagit2002 hi!
Vik
@vvang044
Feb 28 2016 02:50
@moigithub thank you
CamperBot
@camperbot
Feb 28 2016 02:50
vvang044 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
bhagwant
@sagit2002
Feb 28 2016 02:50
```js
bitgrower
@bitgrower
Feb 28 2016 02:51
hello @sagit2002
CamperBot
@camperbot
Feb 28 2016 02:51
:star: 679 | @moigithub | http://www.freecodecamp.com/moigithub
bhagwant
@sagit2002
Feb 28 2016 02:51
@bitgrower I am stuck with a problem
AudioGen
@AudioGen
Feb 28 2016 02:51
@bitgrower Hi I got it, I don't know if I fully understand it still, but thanks for your help!
CamperBot
@camperbot
Feb 28 2016 02:51
audiogen sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 658 | @bitgrower | http://www.freecodecamp.com/bitgrower
bhagwant
@sagit2002
Feb 28 2016 02:52
function palindrome(str) {
  // Good luck!
  var stripped = str.toLowerCase().replace(/[^a-z]/g, '');
  var reversed = stripped.split('').reverse().join('');
  if (stripped === reversed){
    return true;
  } else {
    return false;
  }
}
demipixel
@demipixel
Feb 28 2016 02:52
@sagit2002 Which test is it not passing?
bitgrower
@bitgrower
Feb 28 2016 02:52
awesome ... @audioGen 00 sometimes if you just pencil and paper what you think is going on & based on the documentation, you'll see ...
bhagwant
@sagit2002
Feb 28 2016 02:52
palindrome("1 eye for of 1 eye.")
demipixel
@demipixel
Feb 28 2016 02:52
@sagit2002 Well
@sagit2002 What will "stripped" contain in that situation
bitgrower
@bitgrower
Feb 28 2016 02:53
let me guess ... the test that isn't passing is the last one, right ?
bhagwant
@sagit2002
Feb 28 2016 02:53
second last
Alex N.
@N0bl3
Feb 28 2016 02:54
@sagit2002 the replace function takes care of the numbers. You might want to have a look at your RegExp
demipixel
@demipixel
Feb 28 2016 02:54
@sagit2002 What will the stripped variable contain for that situation?
bitgrower
@bitgrower
Feb 28 2016 02:54
and if you want to konw what it's returning ... use console.log .... more reliable than what other programmers will tell you ;)
Alex N.
@N0bl3
Feb 28 2016 02:55
@bitgrower +1 for this! Do you use Firebug or the standard console?
demipixel
@demipixel
Feb 28 2016 02:55
@bitgrower Annoying though, there really needs to be a way to make this go into the left console
bitgrower
@bitgrower
Feb 28 2016 02:55
I use chrome ...
demipixel
@demipixel
Feb 28 2016 02:55
Even if this means having a custom "log" function
Alex N.
@N0bl3
Feb 28 2016 02:56
@demipixel well he could just modify the call to the function with the arguments he wants.
demipixel
@demipixel
Feb 28 2016 02:56
@N0bl3 What do you mean?
bhagwant
@sagit2002
Feb 28 2016 02:57
Well I thing digits are not to be negated to pass this test
Alex N.
@N0bl3
Feb 28 2016 02:58
return "a";  // logs "a" in left console
So you can pass different parameters to your function call in your challenges and you'll see on the left what is returned by the function.
bhagwant
@sagit2002
Feb 28 2016 02:58
sorry its think not thing
I am using console.log to debug
demipixel
@demipixel
Feb 28 2016 02:58
@N0bl3 I know but that doesn't really work for large amounts of data
Alex N.
@N0bl3
Feb 28 2016 02:58
@sagit2002 exactly so you should correct your Regexp to let numbers pass.
bhagwant
@sagit2002
Feb 28 2016 02:59
@N0bl3 any suggestions
Alex N.
@N0bl3
Feb 28 2016 02:59
@demipixel actually no, just the returned value :( Most other Online interactive courses like CodeSchool etc.. use the console though.
@sagit2002 what does you RegExp do now? what do you want it to do?
demipixel
@demipixel
Feb 28 2016 03:00
@N0bl3 Yeah but it wouldn't be too hard to make a custom "log" function so we can use the left console
bhagwant
@sagit2002
Feb 28 2016 03:01
i think it should exclude digits
Alex N.
@N0bl3
Feb 28 2016 03:01
@demipixel like console.fcc() ? hum one could add this in a pull Request. I'll try to make one if i have time this week :)
demipixel
@demipixel
Feb 28 2016 03:02
@N0bl3 Could you make it shorter though haha
Alex N.
@N0bl3
Feb 28 2016 03:02
@demipixel do you have an idea for the name? ^^
demipixel
@demipixel
Feb 28 2016 03:03
eh
log/print/something
Alex N.
@N0bl3
Feb 28 2016 03:03
@sagit2002 actually no you want to keep the numbers :)
demipixel
@demipixel
Feb 28 2016 03:03
Actually, overwritng print would be really nice
Because print() in javascript brings up the print prompt
bhagwant
@sagit2002
Feb 28 2016 03:03
sorry i went other way
demipixel
@demipixel
Feb 28 2016 03:04
mmmm
Well idk... You want to make the code still work if somebody copies it to codepen
bhagwant
@sagit2002
Feb 28 2016 03:04
@N0bl3 I tried ^a-z0-9 but not working any suggestion
demipixel
@demipixel
Feb 28 2016 03:05
It should..
Nick Robson
@nickrobson
Feb 28 2016 03:05
@demipixel Override console.log to use both the old function and the left console.
Alex N.
@N0bl3
Feb 28 2016 03:05
@demipixel well maing a print() method wouldnt overwrite window.print anyway :)
@sagit2002 can you send your new code plesae?
Nick Robson
@nickrobson
Feb 28 2016 03:05
@sagit2002 You need to use /[^a-z0-9]/i
demipixel
@demipixel
Feb 28 2016 03:06
@nickrobson I know but then outside of FCC people don't know how to use it
bhagwant
@sagit2002
Feb 28 2016 03:06
@nickrobson I just done it on my own thanks anyway
CamperBot
@camperbot
Feb 28 2016 03:06
sagit2002 sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 405 | @nickrobson | http://www.freecodecamp.com/nickrobson
demipixel
@demipixel
Feb 28 2016 03:06
@N0bl3 No, print() is a javascript function
Nick Robson
@nickrobson
Feb 28 2016 03:06
@demipixel How so?
demipixel
@demipixel
Feb 28 2016 03:06
@nickrobson Go to google chrome console and type print()
Nick Robson
@nickrobson
Feb 28 2016 03:07
@demipixel If you made print() be overridden, people would use it thinking that it will function the same way as in FCC..
demipixel
@demipixel
Feb 28 2016 03:07
@nickrobson I already said it was a bad idea
Nick Robson
@nickrobson
Feb 28 2016 03:07
I think console.log is a far better idea.
demipixel
@demipixel
Feb 28 2016 03:07
I also think if we overwrite console.log that people won't know how to use it outside of FCC
It may be better just to correct teach people how to use console.log
Since we only say it exists, not how to get the information
Nick Robson
@nickrobson
Feb 28 2016 03:08
(function() {
   var old_console_log = console.log;
   console.log = function() {
      old_console_log(arguments);
      append_left_console(arguments);
   };
})();
Alex N.
@N0bl3
Feb 28 2016 03:08
@demipixel i see a print() method belonging to window object but what is the native print() method?
Nick Robson
@nickrobson
Feb 28 2016 03:08
easy lol
demipixel
@demipixel
Feb 28 2016 03:09
@N0bl3 It opens the "print" dialog
Nick Robson
@nickrobson
Feb 28 2016 03:09
@demipixel Just because it opens the print dialog, doesn't mean it should be overridden.
demipixel
@demipixel
Feb 28 2016 03:09
@nickrobson I already said it was a bad idea
I've already told you this before
Caleb Martin
@caleb272
Feb 28 2016 03:09
the chat is slow this hour
Nick Robson
@nickrobson
Feb 28 2016 03:10

@demipixel
Actually, overwritng print would be really nice
Because print() in javascript brings up the print prompt

I thought you were suggesting it, though?

demipixel
@demipixel
Feb 28 2016 03:11
Well idk... You want to make the code still work if somebody copies it to codepen
@nickrobson I already said it was a bad idea
Nick Robson
@nickrobson
Feb 28 2016 03:11
mk
Alex N.
@N0bl3
Feb 28 2016 03:11
Well the print() method you use is not native to JS it is part of the browser window object. If you try to use it in a native JS app it doesnt exist
demipixel
@demipixel
Feb 28 2016 03:11
I can change my mind
Nick Robson
@nickrobson
Feb 28 2016 03:11
well, if you overrode console.log as I was saying, it still would :)
demipixel
@demipixel
Feb 28 2016 03:11
I also think if we overwrite console.log that people won't know how to use it outside of FCC
Alex N.
@N0bl3
Feb 28 2016 03:12
@demipixel @nickrobson Why don't you like these functions they need love too!
Nick Robson
@nickrobson
Feb 28 2016 03:13
wat
It would still print to console.
It would just also print to the FCC left terminal..
Alex N.
@N0bl3
Feb 28 2016 03:15
good night
Caleb Martin
@caleb272
Feb 28 2016 03:15
so I’m guessing for this challenge Smallest Common Multiple you just create a really slow algorithm to find the number or is there a trick
Nick Robson
@nickrobson
Feb 28 2016 03:15
night
Caleb Martin
@caleb272
Feb 28 2016 03:15
to find it
help Smallest Common Multiple
CamperBot
@camperbot
Feb 28 2016 03:15

:point_right: algorithm smallest common multiple [wiki]

Explanation:

The smallest common multiple between two numbers is the smallest number that
both numbers can divide into. This concept can be extended to more than two
numbers as well.

We can first start with just finding the smallest common multiple between two
numbers. Naively, you can start writing out multiple of each number until you
write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The
first smallest number we run into in both lists is 12 so this is the smallest
common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common
multiple of just the two numbers but forget the keyword range. However, this
means that if you are given [1,5], then you have to check for the smallest
common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by
all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

Caleb Martin
@caleb272
Feb 28 2016 03:18
wtf they give you the solution in that link ^ that is stupid
Andrew Charlebois
@andrewchar
Feb 28 2016 03:21
hint Diff Two Arrays
CamperBot
@camperbot
Feb 28 2016 03:21
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:21
bonfire Pig Latin
CamperBot
@camperbot
Feb 28 2016 03:21

:fire:Bonfire: Pig Latin :link:

function translate(str) {
 return str;
}

translate("consonant");

Translate the provided string to pig latin.

more info:  bf details | bf links | hint

Sidharth Kriplani
@sidkrip
Feb 28 2016 03:22
function translate(str) {

  var ret=[];
  var way="way";
  var ay="ay";
  var subs;
  var substwo;
  ret=str.split("");
    if((ret[0]=="a")||(ret[0]=="e")||(ret[0]=="i")||(ret[0]=="o")||(ret[0]=="u")) {
      str+=way;
    }
    for(var i=0; i<ret.length; i++) {
      if((ret[i]=="a")||(ret[i]=="e")||(ret[i]=="i")||(ret[i]=="o")||(ret[i]=="u")) {
        break;}
        subs=str.substr(0, i+1)+ay;
        substwo=str.substr(i+1, str.length);
        substwo+=subs;
        str=substwo;
      }


  return str;
}
the only problem with my code is that it cant form the pig latin for a word which starts with a consonant cluster
Andrew Charlebois
@andrewchar
Feb 28 2016 03:22
help Diff Two Arrays
CamperBot
@camperbot
Feb 28 2016 03:22

:point_right: algorithm diff two arrays [wiki]

Explanation:

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

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

Sidharth Kriplani
@sidkrip
Feb 28 2016 03:22
help someone?
CamperBot
@camperbot
Feb 28 2016 03:22
no wiki entry for: someone
Caleb Martin
@caleb272
Feb 28 2016 03:23
are you just trying to return what the first array doesn’t have from the second array
apklip
@apklip
Feb 28 2016 03:25

function myFunction() {
'use strict';

var myVar = 3;
console.log(myVar);
}
myFunction();

// run and check the console
// myVar is not defined outside of myFunction
console.log(myVar);

// now remove the console log line to pass the test

Why does this not work?
Monty
@webdev8183
Feb 28 2016 03:26
argh this mutations is killing me, I can get one test to pass with one code block, and the other tests to pass with the other but for some reason I cannot manage to get both to run. I could use a hand.. since I am not sure where I am going wrong
Andrew Charlebois
@andrewchar
Feb 28 2016 03:26
@DarkPigeons remove the console.log line
Monty
@webdev8183
Feb 28 2016 03:28
runs around waving his blaster trying to kill the mutant strings
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:28
is someone done with the Pig Latin bonfire?
Caleb Martin
@caleb272
Feb 28 2016 03:30
ya i did it what do you need help with
ya the mutant string one is hard
Monty
@webdev8183
Feb 28 2016 03:31
if these are basic i am scared of the pig, you are way ahead of me, much respect..(bows to caleb272)
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:32

@caleb272

function translate(str) {

  var ret=[];
  var way="way";
  var ay="ay";
  var subs;
  var substwo;
  ret=str.split("");
    if((ret[0]=="a")||(ret[0]=="e")||(ret[0]=="i")||(ret[0]=="o")||(ret[0]=="u")) {
      str+=way;
    }
    for(var i=0; i<ret.length; i++) {
      if((ret[i]=="a")||(ret[i]=="e")||(ret[i]=="i")||(ret[i]=="o")||(ret[i]=="u")) {
        break;}
        subs=str.substr(0, i+1)+ay;
        substwo=str.substr(i+1, str.length);
        substwo+=subs;
        str=substwo;
      }


  return str;
}

this is my code. I cant convert strings which start with a consonant cluster into their Pig Latin

otherwise, its working fine
Caleb Martin
@caleb272
Feb 28 2016 03:35
is the for loop for putting the constant cluster at the end of the str
?
@sidkrip
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:38
yep
it breaks the loop as soon as it finds the first vowel
Robert Valmassoi
@valmassoi
Feb 28 2016 03:39
This message was deleted
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:40
and then from the starting position to the position just before wehre the vowel was found, it makes a substring out of it and assigns it to subs and the rest two substwo. then I concatenate. With glove, its returning "vegayloay"
@caleb272
*where
Robert Valmassoi
@valmassoi
Feb 28 2016 03:40
//plan make an array with all numbers in numerical order
//iterate thru array

function smallestCommons(arr) {

  //array of all numbers
  if(arr[0] < arr[1]){
    for (i=1; i<arr[1]-1; i++){
      arr.push(arr[0]+i);
    }
  }
  else{
    for (i=1; i<arr[0]-1; i++){
      arr.push(arr[1]+i);
    }
  }

  //order array
  arr.sort();
  var multiples =[];

  //arrays of multiples
  for (var j in arr){
    multiples.push([]);
    for (var z=1; z<35; z++){// do i just set to a high number?
      var multi = arr[j]*z;
      multiples[j].push(multi);
    }
  }

  multiples = multiples.slice(1);//dont need 1st

  for (var q=0; q<35; q++){
    for (var w in multiples){
      //HOW DO I MAKE THIS FOR ALL 'w' instead of manually?
      if ($.inArray(multiples[3][q], multiples[2])!==-1 && $.inArray(multiples[3][q], multiples[1])!==-1 && $.inArray(multiples[3][q], multiples[0])!==-1){
        return multiples[3][q];
      }
    }
  }
  return "error";
}

smallestCommons([1, 13]); //doesnt work
//smallestCommons([1,5]); //works
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:40
*rest to substwo
Caleb Martin
@caleb272
Feb 28 2016 03:40
what should it return
Robert Valmassoi
@valmassoi
Feb 28 2016 03:40
can someone help me finish Smallest Common Multiple challenge
Caleb Martin
@caleb272
Feb 28 2016 03:41
nope I’m on the same one valmassoi
@sidkrip what is the test
Robert Valmassoi
@valmassoi
Feb 28 2016 03:42
@caleb272 im close. look at the two '?' i have on there
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:42
@caleb272 it should return oveglay instead of vegayloay
Caleb Martin
@caleb272
Feb 28 2016 03:43
you are taking off o too you shouldn’t be doing that
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:43
Oh, I get it now why it is returning that
Caleb Martin
@caleb272
Feb 28 2016 03:43
ya
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:43
let me figure it out once again
Caleb Martin
@caleb272
Feb 28 2016 03:43
you are returning on too late
i think
*one
tell me if that work
s
@sidkrip did that work
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:45
manually trying to work glove through my code
Caleb Martin
@caleb272
Feb 28 2016 03:46
try
if((ret[i+1]=="a")||(ret[i]=="e")||(ret[i]=="i")||(ret[i]=="o")||(ret[i]=="u")) {
        break;}
@sidkrip
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:47
didnt work @caleb272
Caleb Martin
@caleb272
Feb 28 2016 03:48
subs=str.substr(0, i+1)+ay;
you could just pop it off and add it to the other array
that you add to the end
that is what i did i believe
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:49
code please?
Caleb Martin
@caleb272
Feb 28 2016 03:50
what do you mean?
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:50
This message was deleted
This message was deleted
please post the code for it?
Caleb Martin
@caleb272
Feb 28 2016 03:50
i am working on a different project i can’t go back
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:53
okay so I think the problem in my code is with the subs part. It is working I dont know at all why for all the words beginning with a consonant and the second word being a vowel but its not working for words beginning with a consonant cluster
@caleb272
Caleb Martin
@caleb272
Feb 28 2016 03:53
you are taking an extra letter off that you shouldn’t be taking look at the differences of your return str and the test
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:54
maybe I could make a third case of if else for it and change the current code like this? :
 if((ret[1]=="a")||(ret[1]=="e")||(ret[1]=="i")||(ret[1]=="o")||(ret[1]=="u")) {
        break;}
the third case can have a different code for the consonant clusters I think
Caleb Martin
@caleb272
Feb 28 2016 03:55
its not there you are taking a vowel off of the start and moving it to the end when you shouldn’t bee
*be
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:55
alright. I will work upon that and get back to you
Caleb Martin
@caleb272
Feb 28 2016 03:56
its something to do with your substr math i think
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:57
for both the subs and the substwo?
Caleb Martin
@caleb272
Feb 28 2016 03:58
why do you have 2
i guess you can do it that way but its the subs that goes to the end of your str
Sidharth Kriplani
@sidkrip
Feb 28 2016 03:59
oh I got it! I think. Wait a second
I was mistaking the second parameter of the substr function as something else and I read the documentation again. So I think I will be able to work it out now. Thanks @caleb272
CamperBot
@camperbot
Feb 28 2016 04:01
sidkrip sends brownie points to @caleb272 :sparkles: :thumbsup: :sparkles:
:star: 313 | @caleb272 | http://www.freecodecamp.com/caleb272
Caleb Martin
@caleb272
Feb 28 2016 04:02
ok cool
i used shift and push for mine if i remember right
Vik
@vvang044
Feb 28 2016 04:07
im doing my first bonfire and i think i messed it up big time can anyone look at it.....?
demipixel
@demipixel
Feb 28 2016 04:07
@vvang044 which one?
Vik
@vvang044
Feb 28 2016 04:08
reverse a string
Caleb Martin
@caleb272
Feb 28 2016 04:08
use the function str.reverse()
^
demipixel
@demipixel
Feb 28 2016 04:08
That's not a function
Caleb Martin
@caleb272
Feb 28 2016 04:08
what is it
demipixel
@demipixel
Feb 28 2016 04:09
bf Reverse
CamperBot
@camperbot
Feb 28 2016 04:09

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

more info:  bf details | bf links | hint

demipixel
@demipixel
Feb 28 2016 04:09
bf links
demipixel
@demipixel
Feb 28 2016 04:09
That
Caleb Martin
@caleb272
Feb 28 2016 04:09
o its for an array
ya i remember that one
Vik
@vvang044
Feb 28 2016 04:09
well it says first i need to change it to array and then reverse
and use join
demipixel
@demipixel
Feb 28 2016 04:09
yep
Vik
@vvang044
Feb 28 2016 04:10
so here is my code.....don't make fun of it.....:(
Sidharth Kriplani
@sidkrip
Feb 28 2016 04:10
@caleb272 I think my code is correct logically, but the problem is with breaking the loop once the "first" vowel is found
Rita Alfonso
@alfonsotech
Feb 28 2016 04:10
@vvang044 :thumbsup:
Vik
@vvang044
Feb 28 2016 04:10
function reverseString(str) {
  var array = [];
  var string= "";
  var newArray = [];
  var newString='';

  array = string.split(" ");
  newArray = array.reverse();
  newString = newArray.join(" ");

  return str;
}

reverseString("hello");
Caleb Martin
@caleb272
Feb 28 2016 04:11
that is what i have been trying to tell you its not breaking early enough or you are taking an extra character @sidkrip
demipixel
@demipixel
Feb 28 2016 04:11
@vvang044 That would reverse the order of words in a sentence
Vik
@vvang044
Feb 28 2016 04:12
hmmm
demipixel
@demipixel
Feb 28 2016 04:12
Well first, you want to split the string passed in right?
Vik
@vvang044
Feb 28 2016 04:12
first im changing that into array.....
demipixel
@demipixel
Feb 28 2016 04:12
@vvang044 Right, but you made an extra var string = "" variable which you don't need
Vik
@vvang044
Feb 28 2016 04:12
so i would use array=string.split.... right?
demipixel
@demipixel
Feb 28 2016 04:13
You can just do str.split(
Sidharth Kriplani
@sidkrip
Feb 28 2016 04:13

@caleb272
now this is my curent code:

function translate(str) {

  var ret=[];
  var way="way";
  var ay="ay";
  var subs;
  var substwo;
  ret=str.split("");
    if((ret[0]=="a")||(ret[0]=="e")||(ret[0]=="i")||(ret[0]=="o")||(ret[0]=="u")) {
      str+=way;
    }
    for(var i=0; i<ret.length; i++) {
      if((ret[i]=="a")||(ret[i]=="e")||(ret[i]=="i")||(ret[i]=="o")||(ret[i]=="u")) {
        break;}

        subs=str.substr(0, i)+ay;
        substwo=str.substr(i, str.length-i);
        substwo+=subs;
        str=substwo;
      }


  return str;
}

how would you modify it to make it work without using any other extra function?

Andrew Charlebois
@andrewchar
Feb 28 2016 04:13
oh man "Diff Two Arrays" got me really thinking hard lol
Vik
@vvang044
Feb 28 2016 04:16
what about the rest of the code
demipixel
@demipixel
Feb 28 2016 04:16
@vvang044 Do you know what .split() does?
Vik
@vvang044
Feb 28 2016 04:18
it splits the word hello to "h" "e" "l" "l" "o"
?
demipixel
@demipixel
Feb 28 2016 04:18
@vvang044 Look at this example:
var str = "Hello there sir!";
str.split(" ") == ["Hello", "there", "sir!"];
However:
var str = "hello";
str.split(" ") == ["hello"];
Vik
@vvang044
Feb 28 2016 04:20
str.split...... changed it into an array
demipixel
@demipixel
Feb 28 2016 04:20
right but you wanted:
["h", "e", "l", "l", "o"];
It's because whatever is between the () in the split is what it is going to split the string into
Since there are no spaces in "hello" it'll stay in one piece
So what you really want to do is split and join with ""
Vik
@vvang044
Feb 28 2016 04:22
hmmm
demipixel
@demipixel
Feb 28 2016 04:22
Because that does it between every character
David Bruskin
@kidimi
Feb 28 2016 04:24

js```
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;
var player = testObj[16];
console.log(player);
```js

Vik
@vvang044
Feb 28 2016 04:24
we still need to use reverse the string
David Bruskin
@kidimi
Feb 28 2016 04:24
Y playerNumber should be a number
Y The variable player should be a string
Y The value of player should be "Montana"
N You should use bracket notation to access testObj
Am I
demipixel
@demipixel
Feb 28 2016 04:24
@vvang044 Well, you can convert it to an array, reverse the array, and then convert it back to a string
@kidimi you don't need a "js" at the end of your ```
Only at the start
David Bruskin
@kidimi
Feb 28 2016 04:25

Oh, thanks.

Am I not using bracket notation?

demipixel
@demipixel
Feb 28 2016 04:25
You are but I think they want you to use the playerNumber variable
David Bruskin
@kidimi
Feb 28 2016 04:26
I'm not?
WHat about the first line?
demipixel
@demipixel
Feb 28 2016 04:26
var playerNumber = 16;
var player = testObj[16];
I think they want you to do
var playerNumber = 16;
var player = testObj[playerNumber];
but idk
NonstopDRE
@NonstopDRE
Feb 28 2016 04:27
I need help with the convert celsius to fahrenheit challenge
David Bruskin
@kidimi
Feb 28 2016 04:27
I originally did that and it said I should use the playernumber, so I put the 16 on the second line.
demipixel
@demipixel
Feb 28 2016 04:27
@NonstopDRE Shoot
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:27
@NonstopDRE Do you need the equation, or how to implement it?
demipixel
@demipixel
Feb 28 2016 04:27
@kidimi What do you mean?
NonstopDRE
@NonstopDRE
Feb 28 2016 04:28
how to implement it
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:28
@NonstopDRE Show us your current code
David Bruskin
@kidimi
Feb 28 2016 04:28
When I do what you suggested, I get "ReferenceError: playernumber is not defined"
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:28
@kidimi check camelcase?
demipixel
@demipixel
Feb 28 2016 04:28
@kidimi Capitilization matters
David Bruskin
@kidimi
Feb 28 2016 04:29
Ahhhhh.
THANK YOU demipixel. It's always something small that gets me.
demipixel
@demipixel
Feb 28 2016 04:29
And all of us
David Bruskin
@kidimi
Feb 28 2016 04:29
:) Thx again.
demipixel
@demipixel
Feb 28 2016 04:29
np
Vik
@vvang044
Feb 28 2016 04:32
@demipixel how can i get rid of these pop ups....i tried the notifications and it doesnt seem to work
demipixel
@demipixel
Feb 28 2016 04:32
@vvang044 What popups?
Vik
@vvang044
Feb 28 2016 04:32
the green message notification
demipixel
@demipixel
Feb 28 2016 04:32
Oh yeah
Top right corner (to the left of the search bar)
There's a settings button
Click That => Notifications
Change it to "Only when somebody mentions me"
Vik
@vvang044
Feb 28 2016 04:33
did that
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:33
I think he means the green boxes that keep popping up from all the rooms
demipixel
@demipixel
Feb 28 2016 04:33
Like the notification numbers?
Vik
@vvang044
Feb 28 2016 04:33
yep
demipixel
@demipixel
Feb 28 2016 04:34
I don't think there's a way to stop that
Wait yes there is
Go to notifications
Vik
@vvang044
Feb 28 2016 04:34
grr.....
demipixel
@demipixel
Feb 28 2016 04:34
And click "Hide unread message badge"
Vik
@vvang044
Feb 28 2016 04:34
it is
checked
demipixel
@demipixel
Feb 28 2016 04:35
It's specific for each room
So you have to go to each room that you want that to happen
Vik
@vvang044
Feb 28 2016 04:35
i cannot read ......
so going backto my bonfire....i don't think i made any progress even after your explaination
NonstopDRE
@NonstopDRE
Feb 28 2016 04:36

function convert(celsius) {
// Only change code below this line
function convert(degree) {
if (degree == "C") {
F =
document.getElementById("c").value 9 / 5 + 32;
document.getElementById("f").value = Math.round(f);
} else {
C =
(document.getElementById("f").value -32)
5 / 9;

  document.getElementById("c").value = Math.round(C);
}

}

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

// Change the inputs below to test your code
convert(30);

Vik
@vvang044
Feb 28 2016 04:38
should give you 86 i believe
if i still remember the exercise
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:39
Is this the weather app or the bonfire? @NonstopDRE
NonstopDRE
@NonstopDRE
Feb 28 2016 04:39
this is the exercise convert celsius to fahrenheit
i'm completely lost
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:40
@NonstopDRE You don't need document.getElementById, and also, you are required to convert only from Celsius to F
Vik
@vvang044
Feb 28 2016 04:40
the instructions has the answer to convert celcius to F
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:41
Yep
"Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit."
Thats pretty much all you need to do to complete it
NonstopDRE
@NonstopDRE
Feb 28 2016 04:41
oh i was probably overthinking it thanks
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:42
@NonstopDRE Yep, you are way ahead of yourself lol, you'll need that for the weather app you'll be creating though
Vik
@vvang044
Feb 28 2016 04:42
@eagarcia8 have you completed the reverse string bonfire
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:42
@vvang044 I don't remember
@vvang044 Probably
@vvang044 According to the website I did.
Vik
@vvang044
Feb 28 2016 04:43
basic algorithn scripting
lol.....good for you....well im stuck
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:43
@vvang044 On reversing a string?
Vik
@vvang044
Feb 28 2016 04:43
yep
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:44
@vvang044 Oh this is one of the early ones, big tip, look at the links, it's all you need to pass it.
@vvang044 Haha it even has it in the order you should use them
@vvang044 Can you post your current code?
Vik
@vvang044
Feb 28 2016 04:45
i did....and im slow poke....it takes for me to get it
so here is the code
function reverseString(str) {
  var array = [];
  var newArray = [];
  var newString='';

  array = str.split("");
  newArray = array.reverse();
  newString = newArray.join("");

  return str;
}
demipixel
@demipixel
Feb 28 2016 04:46
@vvang044 Let's start simple:
function reverse(str) {
  return str;
}
So how do we get an array of characters from str?
(hint, you already did it in your above code)
CamperBot
@camperbot
Feb 28 2016 04:47
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Vik
@vvang044
Feb 28 2016 04:47
you need to declare a var array = []
demipixel
@demipixel
Feb 28 2016 04:47
I'm just saying, how do we get an array of characters
var array = [] makes a new variable array with [] in it
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:48
@vvang044 Remember that you need to work with only one variable that has the string, you have 3 different variables.
demipixel
@demipixel
Feb 28 2016 04:48
@vvang044 What's actually converting the string into an array of characters?
What function?
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:48
@demipixel His code works, it's just that he's referencing different variables with nothing in them.
Vik
@vvang044
Feb 28 2016 04:49
array = str.string
demipixel
@demipixel
Feb 28 2016 04:49
str.string?
or str.split("")?
Vik
@vvang044
Feb 28 2016 04:49
yep
demipixel
@demipixel
Feb 28 2016 04:49
Okay, so
Vik
@vvang044
Feb 28 2016 04:49
and we assign that array correct?
demipixel
@demipixel
Feb 28 2016 04:49
function reverse(str) {
  return str.split("");
}
Now how do we reverse this array?
What method?
Vik
@vvang044
Feb 28 2016 04:51
array.reverse
demipixel
@demipixel
Feb 28 2016 04:51
yep
function reverse(str) {
  return str.split("").reverse();
}
And lastly, how do we join it back again?
I kinda gave the answer away there hehe
Vik
@vvang044
Feb 28 2016 04:51
wait.....here is my question
we are assigning a variable for these new values?
demipixel
@demipixel
Feb 28 2016 04:52
You only need to assign a variable if you need to save information
In this case, we can just do:
function reverse(str) {
  return str.split("").reverse().join("");
}
Vik
@vvang044
Feb 28 2016 04:52
bloody hell.....i gave three variables
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:52
@vvang044 Your code still works though, you just need to look at what you are returning, you are returning the original str, not your modified variable
demipixel
@demipixel
Feb 28 2016 04:53
@vvang044 Well, do you understand why you don't have to?
Vik
@vvang044
Feb 28 2016 04:53
well i need to return hello
not a sentence
demipixel
@demipixel
Feb 28 2016 04:53
@vvang044 You want to return "olleh"
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:53
@vvang044 Yep that hello is in newString
because str = olleh and newString = hello, which one do you want
Vik
@vvang044
Feb 28 2016 04:54
ok let me fix my code.....
oh good god.......lol
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:56

this was my solution lol back when i was a noob, still kind of am though:```function reverseString(str) {
str = str.split("");
str = str.reverse();
str = str.join("");
return str;
}

reverseString("hello");```

Vik
@vvang044
Feb 28 2016 04:56
now i understood why my previous code didnt work and thank you for being patient
demipixel
@demipixel
Feb 28 2016 04:57
@eagarcia8 Do you know how you'd do it in one line?
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:57
@demipixel Yep dot notation.
demipixel
@demipixel
Feb 28 2016 04:57
I don't think it's called dot notation but alright :P
Vik
@vvang044
Feb 28 2016 04:57
what it is called?
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:57
@demipixel Really? thats what the article titled it, whats it called?
demipixel
@demipixel
Feb 28 2016 04:57
dot notation is the type of notation for an object
Vik
@vvang044
Feb 28 2016 04:58
true
demipixel
@demipixel
Feb 28 2016 04:58
i.e.
obj["hello"] == obj.hello
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:58
@demipixel ah yes yes, i guess i just mixed both of them in
demipixel
@demipixel
Feb 28 2016 04:58
I would call this "reverse" thing, like, idk... stacked methods
Don't know if there's an actual name
Eduardo Garcia
@eagarcia8
Feb 28 2016 04:58
@demipixel I feel anything that has to do with dots, is dot notation haha
Vik
@vvang044
Feb 28 2016 04:58
its called myNotation
lol
demipixel
@demipixel
Feb 28 2016 04:59
@eagarcia8 Well, I mean
technniicallllllly it is
Nobody would EVER do this, but
You could do:
Vik
@vvang044
Feb 28 2016 04:59
@eagarcia8 @demipixel thank you for explaining.....
CamperBot
@camperbot
Feb 28 2016 04:59
vvang044 sends brownie points to @eagarcia8 and @demipixel :sparkles: :thumbsup: :sparkles:
:star: 291 | @eagarcia8 | http://www.freecodecamp.com/eagarcia8
:star: 61 | @demipixel | http://www.freecodecamp.com/demipixel
demipixel
@demipixel
Feb 28 2016 04:59
function reverse(str) {
  return str["split"]("")["reverse"]()["join"]("");
}
And technically that would use no dot notation
But that looks very ugly
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:00
@demipixel I feel like "chaining" might be the correct term
demipixel
@demipixel
Feb 28 2016 05:00
@eagarcia8 Whatever you want to call it haha
Vik
@vvang044
Feb 28 2016 05:00
happy coding....im outta here
demipixel
@demipixel
Feb 28 2016 05:00
Alright then
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:00
later @vvang044
demipixel
@demipixel
Feb 28 2016 05:00
cya @vvang044
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:01
@demipixel I just looked at your code, I don't even understand whats going on there
demipixel
@demipixel
Feb 28 2016 05:01
Well
str.split
str["split"]
These are the same right?
So are these then:
str.split("");
str["split"]("");
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:02
yea what are ("")
oh
I see
demipixel
@demipixel
Feb 28 2016 05:02
It's just like the original
It just looks stupid
Which is why nobody does it haha
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:02
those ("") look really confusing
I've never used [] for chaining, just for array and object indexes
demipixel
@demipixel
Feb 28 2016 05:03
Well
Have you got to multidimensional arrays yet?
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:03
array[][]
demipixel
@demipixel
Feb 28 2016 05:03
yeah, so
Dot notation doesn't work if you're using variables
So if you have a 5D array...
arr[v][w][x][y][z];
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:05
OH wait you CAN use [] for method calling???
I just saw str["split"]
never done that ever.
To me .() is functions and [] are for indexes and variables
demipixel
@demipixel
Feb 28 2016 05:06
@eagarcia8 You can access anything with either dot notation or []
However, you can only access a property with a variable with []
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:06
@demipixel Sounds good, but also confusing haha
demipixel
@demipixel
Feb 28 2016 05:06
Well, think of a string as an object
You know you can access like:
var obj = {
  a: 2,
  b: 3
}

return obj.a;
so what about a string?
var str = {
  split: function(splitter) { ... },
  otherStringFunction: function() { ... }
};

return str.split("");
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:07
so all these functions are really part of an "array" for every variable? like shift unshift pop push?
OH wow
yep learned something new today
demipixel
@demipixel
Feb 28 2016 05:08
Objects != Arrays
Arrays are a type of Object
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:08
Right right
demipixel
@demipixel
Feb 28 2016 05:08
so technically arrays:
var arr = {
  0: "hello",
  1: "there",
  reverse: function() { ... },
  join: function(joiner) { ... },
  etc: ...
};
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:09
So this stuff is getting into development of javascript
demipixel
@demipixel
Feb 28 2016 05:09
Not really
You'll use this stuff more when you get more advanced
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:09
Sounds good
demipixel
@demipixel
Feb 28 2016 05:09
JS is awesome because of stuff like this
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:10
Yea, I've been using PHP all my life until jQuery arrived
demipixel
@demipixel
Feb 28 2016 05:10
PHP and Jquery do really different things...
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:10
Good stuff, the dot notation or chaining is really wierd but makes sense
Yea I know, but I'm talking about the language syntax
I'm used to stuff like data = data;
demipixel
@demipixel
Feb 28 2016 05:12
data = data wouldn't do much ;)
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:12
I know, but I mean the syntax lol
demipixel
@demipixel
Feb 28 2016 05:12
yeah
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:12
I started computer languages with ActionScript
I don't even remember any of it, pretty sure I can't write in that anymore haha
Robert Valmassoi
@valmassoi
Feb 28 2016 05:13
Screen Shot 2016-02-27 at 8.52.19 PM.png
not accepting my correct answer?
Eduardo Garcia
@eagarcia8
Feb 28 2016 05:14
@valmassoi Can you tell us the bonfire, and can you show us your current code?
Robert Valmassoi
@valmassoi
Feb 28 2016 05:14
if i just type in return 60; it does
demipixel
@demipixel
Feb 28 2016 05:14
@valmassoi is it a string?
you need to make sure "60" is a number
Robert Valmassoi
@valmassoi
Feb 28 2016 05:14
for (var q in a){ // number with highest count is common
    if (a[q]==arr.length -1){
      return q;
    }
  }
demipixel
@demipixel
Feb 28 2016 05:14
yep
q is a string
That's why you have to do it the slow way
for (var q = 0; q < a.length; q++)
Only use "in" for getting keys in objects
Robert Valmassoi
@valmassoi
Feb 28 2016 05:15
oh thanks i thought they did the same thing
demipixel
@demipixel
Feb 28 2016 05:15
As a shortcut for
var keys = Object.keys(obj);
for (var k = 0; k < keys.length; k++) {

}
@valmassoi "in" always returns a string
So it's returning the string "60"
Robert Valmassoi
@valmassoi
Feb 28 2016 05:15
cool thanks
demipixel
@demipixel
Feb 28 2016 05:15
And FCC wants the number 60
np
vin4oo
@vin4oo
Feb 28 2016 05:26
Aright I'm confused and I need help

function myTest(val) {
// Only change code below this line

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

if (val) {
return "Outside";
}

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

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

I need anything not in between 10 and 20 to return "Outside"
Anybody?
Robert Valmassoi
@valmassoi
Feb 28 2016 05:29
@demipixel i was getting blank output with that. a is an object and so q should be a string.
so i need to convert the string to number then
demipixel
@demipixel
Feb 28 2016 05:30
Wait a is an object?
It's possible it wants you to loop through the Object.keys like I mentioned above
Robert Valmassoi
@valmassoi
Feb 28 2016 05:30
yeah
demipixel
@demipixel
Feb 28 2016 05:30
Otherwise yeah, parseInt
Robert Valmassoi
@valmassoi
Feb 28 2016 05:31
parseInt ftw
demipixel
@demipixel
Feb 28 2016 05:32
Usually best not to use unless the data is coming from user input
Robert Valmassoi
@valmassoi
Feb 28 2016 05:33
just bad practice? whats wrong doing so?
demipixel
@demipixel
Feb 28 2016 05:34
I mean, is it in the object as "60"?
Robert Valmassoi
@valmassoi
Feb 28 2016 05:37
i changed the object name a to countNumbers...
var countNumbers = multiples.reduce(function (acc, curr) { //turns into object counting each number
  if (typeof acc[curr] == 'undefined') {
    acc[curr] = 1;
  } else {
    acc[curr] += 1;
  }
Ryan Price
@rsprice
Feb 28 2016 05:38
reduce is such a cool method
demipixel
@demipixel
Feb 28 2016 05:38
What problem is this again
Robert Valmassoi
@valmassoi
Feb 28 2016 05:39
Smallest Common Multiple
demipixel
@demipixel
Feb 28 2016 05:39
bf Smallest Common
CamperBot
@camperbot
Feb 28 2016 05:39

:fire:Bonfire: Smallest Common Multiple :link:

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

Find the smallest number that is evenly divisible by all numbers in the provided range.

more info:  bf details | bf links | hint

demipixel
@demipixel
Feb 28 2016 05:39
Oh yeah
Robert Valmassoi
@valmassoi
Feb 28 2016 05:39
im counting which multiple is contained for each
demipixel
@demipixel
Feb 28 2016 05:40
I see, you're treating it as a dictionary
So you have to have numbers as that
So yeah, either "in" with parseInt or go through the keys
Robert Valmassoi
@valmassoi
Feb 28 2016 06:07
function smallestCommons(arr) {

  //array of all numbers
  if(arr[0] < arr[1]){
    for (i=1; i<arr[1]-1; i++){
      arr.push(arr[0]+i);
    }
  }
  else{
    for (i=1; i<arr[0]-1; i++){
      arr.push(arr[1]+i);
    }
  }

  //order array
  arr.sort();
  arr = arr.slice(1, arr.length);

  var multiples =[];

  //arrays of all posible multiples for each number
  for (var j=0; j<arr.length; j++){
    for (var z=1; z<35000; z++){// do i just set to a high number?
      var multi = arr[j]*z;
      multiples.push(multi);
    }
  }

  //turns into object counting each number
  var countNumbers = multiples.reduce(function (acc, curr) { 
  if (typeof acc[curr] == 'undefined') {
    acc[curr] = 1;
  } else {
    acc[curr] += 1;
  }
  return acc;
}, {});

  // number with highest count is common
  for (var q in countNumbers){ 
    if (countNumbers[q]==arr.length){ //if i do arr.length-1 it gives the answer 1,12 would give
      return parseInt(q);
    }
  }
}

smallestCommons([1, 13]); //doesnt work

//smallestCommons([1, 5]); //works
mind taking a look @demipixel
im guessing having such a long for loop is a bad idea
cant think how else to do it though
demipixel
@demipixel
Feb 28 2016 06:09
Well
Is there a specific issue or are you just too lost in your code to figure out what's wrong (which sometimes happens :P)
Robert Valmassoi
@valmassoi
Feb 28 2016 06:10
whats weird is: if (countNumbers[q]==arr.length){ //if i do arr.length-1 it gives the answer 1,12 would give
makes me think im not far off
demipixel
@demipixel
Feb 28 2016 06:10
do you know how to console.log?
Robert Valmassoi
@valmassoi
Feb 28 2016 06:10
yes lol
demipixel
@demipixel
Feb 28 2016 06:11
Well
so what happens when you start logging arr?
Robert Valmassoi
@valmassoi
Feb 28 2016 06:11
gets huge
demipixel
@demipixel
Feb 28 2016 06:11
Okay, so
What piece of code adds to arr
Marek Slabicki
@thaniri
Feb 28 2016 06:14
hey can anyone explain this error for me? "holderArr is not defined" I'm using it within scope of the function so not sure what the code is upset over
function sumFibs(num) {
  holderArray = [1,1];
  i = 1;

  while (i < num){
    i = i + i;
    if (i % 2 !== 0){
      holderArr.push(i);
    }
  }
  return holderArr;
}

sumFibs(4);
Robert Valmassoi
@valmassoi
Feb 28 2016 06:14
i just testing other inputs.. anything up to 1,12 works
demipixel
@demipixel
Feb 28 2016 06:15
@valmassoi issue with prime numbers?
@thaniri You're doing i+i, that'll double i
Is that what you intended to do?
Marek Slabicki
@thaniri
Feb 28 2016 06:15
the math can be wrong for now, im not getting any output at all however
maybe i need 2 variables
Robert Valmassoi
@valmassoi
Feb 28 2016 06:17
you probably want to use i++
Marek Slabicki
@thaniri
Feb 28 2016 06:17
that is the same as i + i which doesn't solve the problem
going to reevaluate this one
Robert Valmassoi
@valmassoi