These are chat archives for FreeCodeCamp/Help

23rd
Mar 2015
Darryl Dixon - Piece Digital
@piecedigital
Mar 23 2015 00:07
Yeah, nodeschool is catered more towards workshops, as is expressed on the site.
Working through them solo requires some prior knowledge of Node or another back end programming langauge.
In most cases, at least.
Harshal
@McQuinTrix
Mar 23 2015 00:09
@piecedigital yeah i saw that .. the tutorial was like : Level 0 , then next Level 10
Darryl Dixon - Piece Digital
@piecedigital
Mar 23 2015 00:13
LOL. Yep.
Luis Herrera
@luhego
Mar 23 2015 02:42
Hello, I can't connect to webchat.freenode.net
Elliescode
@EllieAdam
Mar 23 2015 03:22
Hello!
function max(num1, num2){
  var result = '';
  if (num1 > num2){
    result = num1 + ' is greater than ' + num2;
  }else{
     result = num1 + ' is less than ' + num2;
  }
alert(result);
};
  max(100,50);
What's wrong with this code? I have error that
the 'max()' function isn't returning a number.
Luis Herrera
@luhego
Mar 23 2015 03:27
@EllieAdam I tried this code and everythink worked ok in my console.
Elliescode
@EllieAdam
Mar 23 2015 03:31
I get this error
the 'max()' function isn't returning a number.
Viacheslav
@Stee1House
Mar 23 2015 04:17
@EllieAdam because your func nothing returns
if this bonfires
Danny Fritz
@dannyfritz
Mar 23 2015 04:26
Yeah. It looks like your max functions creates strings
Oliver
@Dadsaster
Mar 23 2015 04:26
@EllieAdam after your alert add return result;
Viacheslav
@Stee1House
Mar 23 2015 04:57
@Dadsaster this will wrong, because function must return number
Oliver
@Dadsaster
Mar 23 2015 05:18
@Stee1House A function doesn't need to return a number and in this case it should return the string contained in the variable result.
Viacheslav
@Stee1House
Mar 23 2015 05:22
@Dadsaster @EllieAdam wrote 'I get this error - the 'max()' function isn't returning a number'
Oliver
@Dadsaster
Mar 23 2015 05:27
I understand what you are getting at @Stee1House but she is trying return a string based on what she coded. She also isn't returning anything right now and is getting an error message about returns. Programmers write error messages and they very often aren't accurate.
You could also write this in one line as:
function max(num1, num2){
  return (num1 > num2) ? num1 + ' is greater than ' + num2 : num1 + ' is less than ' + num2;
}
  max(100,50);
Viacheslav
@Stee1House
Mar 23 2015 05:34
@Dadsaster ok, understood
Bianca Mihai
@biancamihai
Mar 23 2015 14:01
Hi, question, using Redis for caching in Node.js? Do you use it? Redis does not know about json so it only stores strings, will have to do json.stringify when stored and json.parse when retrieved ... this are blocking operations ... please advise :) ...
Serhii Borovskyi
@serhiicss
Mar 23 2015 16:55
Hello, I am a bit stuck. I am creating a function that takes user input, multiplies it by 2 and outputs the result to a html element. I can't figure out a way to output the result.
Cristián Berríos
@crisberrios
Mar 23 2015 16:56
vanilla or something like zepto?
(or jQuery) ?
if you want something more dynamic you could also look into bacon.js
simplest would be something like....
$('.input').keyup(function() {
  $('.output').val(parseInt($(this).val())*2);
});
Serhii Borovskyi
@serhiicss
Mar 23 2015 16:59
Vanilla and here is what I have so far
function fConvert() {
    var result = document.getElementById("userInput").value * 2;
}
now I want to add the result to an html, say <p> element
Cristián Berríos
@crisberrios
Mar 23 2015 17:00
value is a string
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:00
oh yes
Cristián Berríos
@crisberrios
Mar 23 2015 17:00
so you should parse it into a number 1st
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:00
ok gimme a min :)
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:21
function fConvert() {
    var userInput = document.getElementById("userInput").value;
    parseInt('userInput') * (9 / 5) + 32;
}
should I make a variable for the result?
Renter
@MrRenter
Mar 23 2015 17:23
or you could set your result to an element / div / p / etc
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:25
using the .innerHTML?
Renter
@MrRenter
Mar 23 2015 17:25
you tell me. why dont you try and see what happens
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:26
:) ok
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:32
function fConvert() {
    var userInput = document.getElementById("userInput").value;
    document.querySelector('#result').innerHTML  = parseInt('userInput') * (9 / 5) + 32;
}
then I add <button onclick="fConvert()">
to the html, but nothing happens on click
Cristián Berríos
@crisberrios
Mar 23 2015 17:33
hmm
can you do a jsbin?
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:33
yeah, just a min
Cristián Berríos
@crisberrios
Mar 23 2015 17:40
you have to remove type="submit"
as that does fire a submit event
also, you are calling for 'userInput' instead of the variable
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:42
instead of what variable?
userInput is an element ID
that I decalare as userInput variable
ah I see
I always mix up those. :)
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:50
Thanks guys!
Serhii Borovskyi
@serhiicss
Mar 23 2015 17:58
Once I add a function for the 2nd button, I get an error that first function not defined. http://jsbin.com/jupogohisa/1/edit?html,js,output
Cristián Berríos
@crisberrios
Mar 23 2015 18:01
check the errors below the js tab
you have syntax errors
Serhii Borovskyi
@serhiicss
Mar 23 2015 18:04
@crisberrios I found it. Thank you!
Oliver
@Dadsaster
Mar 23 2015 18:48
@biancamihai Have you looked at https://www.npmjs.com/package/node-cache
Brian
@bconner22
Mar 23 2015 19:22
Hey guys! On this problem, http://www.freecodecamp.com/bonfires/missing-letters , I have the letter matching/not matching working, and I have a statement to make the answer undefined if no letters are missing. it works on my computer but not on the bonfire! I've assigned my final variable to done = undefined but the bonfire doesn't seem to like it. I tried making it an empty array, an empty string, nothing seems to work
Cristián Berríos
@crisberrios
Mar 23 2015 19:33
can you share your code?
Brian
@bconner22
Mar 23 2015 19:34
sure is that allowed?
how do you make the screenshot of it show up in here?
Cristián Berríos
@crisberrios
Mar 23 2015 19:34
sure
share it with markdown format
``` in lines before and after the code
^ check the right type of tick, not ' or '
Brian
@bconner22
Mar 23 2015 19:36
like this?

``` function fearNotLetter(str) {
var done = [];
var letters = 'abcdefghijklmnopqrstuvwxyz';
var arr = letters.split("");
var sar = str.split("");
var key = 0;
for (i= 0; i<sar.length; i++){
if (arr[i] !== sar[key]){

        done.push(arr[i]);
    } else {
        key = key+1;
    }

}
if (done.length >0) {
done = done.join();
console.log(done);
} else {
done = undefined;
return done;
}

}
fearNotLetter('abce'); ```

i don't know why it did that in the middle only
Cristián Berríos
@crisberrios
Mar 23 2015 19:37
missed the last line
backticks have to be in their own line
Brian
@bconner22
Mar 23 2015 19:37

``` function fearNotLetter(str) {
var done = [];
var letters = 'abcdefghijklmnopqrstuvwxyz';
var arr = letters.split("");
var sar = str.split("");
var key = 0;
for (i= 0; i<sar.length; i++){ if (arr[i] !== sar[key]){ done.push(arr[i]); } else { key = key+1; } } if (done.length >0) {
done = done.join();
console.log(done);
} else {
done = undefined;
return done;
}

}
fearNotLetter('abce');```

dangit

```function fearNotLetter(str) {
var done = [];
var letters = 'abcdefghijklmnopqrstuvwxyz';
var arr = letters.split("");
var sar = str.split("");
var key = 0;
for (i= 0; i<sar.length; i++){ if (arr[i] !== sar[key]){ done.push(arr[i]); } else { key = key+1; } } if (done.length >0) {
done = done.join();
console.log(done);
} else {
done = undefined;
return done;
}

}
fearNotLetter('abce');```

Cristián Berríos
@crisberrios
Mar 23 2015 19:38
you can also edit the previous posted code
no need to paste again
Brian
@bconner22
Mar 23 2015 19:38
oh backticks so hit enter, paste code, then again?
Cristián Berríos
@crisberrios
Mar 23 2015 19:39
yes
like this
shift + enter for new line, ctrl + enter to post
Brian
@bconner22
Mar 23 2015 19:39
function fearNotLetter(str) {
    var done = [];
    var letters = 'abcdefghijklmnopqrstuvwxyz';
    var arr = letters.split("");
    var sar = str.split("");
    var key = 0;
  for (i= 0; i<sar.length; i++){
    if (arr[i] !== sar[key]){
      done.push(arr[i]);
    } else {
      key = key+1;
    }
  }
  if (done.length >0) {
    done = done.join();
    return done;
  } else {
    done = undefined;
    return done;
  }

}
fearNotLetter('abce');
Cristián Berríos
@crisberrios
Mar 23 2015 19:39
:thumbsup:
Brian
@bconner22
Mar 23 2015 19:40
thankya!
i know my indent is off where my "for" loop starts
the letter matching is working, it's the undefined part that's not(on the bonfires anyway, that code works fine on my computer)
only difference is I'm using console.log to instead of return on my computer so I can see it in the console
Cristián Berríos
@crisberrios
Mar 23 2015 19:42
let me check
expect(fearNotLetter('yz')).to.be.undefined;AssertionError:expected 'a,b' to be undefined
expect(fearNotLetter('bcd')).to.be.undefined;AssertionError:expected 'a' to be undefined
the problem is, you always start looking from 'a'
so, for 'yz' you return 'a,b'
(2 letters, as the in put string length is 2)
Brian
@bconner22
Mar 23 2015 19:45
well i start with both at position 0('a'), then don't do anything until my letters array matches the str
as for matching letters, it works on my pc
Cristián Berríos
@crisberrios
Mar 23 2015 19:47
fearNotLetter('wxz'); => ['a','b','c']
Brian
@bconner22
Mar 23 2015 19:47
oh wait i'm starting to see what you're saying
Cristián Berríos
@crisberrios
Mar 23 2015 19:47
there's certainly an algorithmic problem
Brian
@bconner22
Mar 23 2015 19:48
ah yes now i see
my algorithm is bad, and i should feel bad... lol
Cristián Berríos
@crisberrios
Mar 23 2015 19:48
well, now on to fixing it ;)
Brian
@bconner22
Mar 23 2015 19:49
yep thanks... even though that yz thing was right in front of me, i didn't see it till you brought it up. Thanks Cris, I'll get back to the drawing board!
William
@KathyTheTurtle
Mar 23 2015 19:50
has anyone here done the last bonfire ("no repeats please")?
Cristián Berríos
@crisberrios
Mar 23 2015 19:50
yes I've done it
in about 3 possible ways
William
@KathyTheTurtle
Mar 23 2015 19:50
damn
Brian
@bconner22
Mar 23 2015 19:50
speaking of which, how close am i to the end?
Cristián Berríos
@crisberrios
Mar 23 2015 19:51
there are about 40 bonfires
William
@KathyTheTurtle
Mar 23 2015 19:51
can't even fine one possible way
Cristián Berríos
@crisberrios
Mar 23 2015 19:51
you can check them in github (bonfires.json)
Brian
@bconner22
Mar 23 2015 19:51
i have a 59 by my name with challenges included
ah thanks
William
@KathyTheTurtle
Mar 23 2015 19:52
any hints on how to solve?
Bianca Mihai
@biancamihai
Mar 23 2015 19:52
hi @bconner22 this is just an ideea, untested ... but what if you use the ascii code? a=97, b=98, c=99 ... that way you know if a letter is missing from the string ...
Cristián Berríos
@crisberrios
Mar 23 2015 19:52
that's a good method @biancamihai, charCodeAt is what I used :D
Brian
@bconner22
Mar 23 2015 19:53
thought about that @biancamihai , I think i'm pretty close, just have a couple bugs to work out
Bianca Mihai
@biancamihai
Mar 23 2015 19:53
if the difference between the prev letter and the current one is > 1
:) didn't test but I think it should work
@Dadsaster thanks! node-cache is what I'm using now
Cristián Berríos
@crisberrios
Mar 23 2015 20:27
@KathyTheTurtle you can do it either by making all the possible permutations and then filtering, or using some math and factorials. In both cases, most likely you'll want to use recursion
William
@KathyTheTurtle
Mar 23 2015 20:29
@crisberrios so use recursion to generate a list of all the permutations?
Cristián Berríos
@crisberrios
Mar 23 2015 20:30
it's one way, not the only, but yes.
William
@KathyTheTurtle
Mar 23 2015 20:30
ok I'll try that.. thanks
Germaine Pannell
@germainep
Mar 23 2015 21:25
i have a random question has anyone used bourbon and neat instead of bootstrap
Cristián Berríos
@crisberrios
Mar 23 2015 21:30
I do :P
Germaine Pannell
@germainep
Mar 23 2015 21:31
i was wondering if knowing that and not knowing bootstrap as much would be a disadvantage
I love the way it keeps everything in your sass files and not in your html but I rarely see it listed as a good to know on job post.
Cristián Berríos
@crisberrios
Mar 23 2015 21:33
do the basic bootstrap stuff, put it on your CV and do a refresher if you are called for an interview, just in case
compass is a bit more popular in the Rails circle I think
Germaine Pannell
@germainep
Mar 23 2015 21:34
ok sounds like a plan
Cristián Berríos
@crisberrios
Mar 23 2015 21:35
also, I've found that grids are getting less useful in the modern web
rem is all you need, all you need is rem
:P
this is a small web I'm doing, and did start with neat but then I ditched it. https://rawgit.com/crisberrios/socomsa/master/build/index.html
bourbon, on the other hand, has been very useful for improving my productivity
you can check this starter I made for a ready-to-go bourbon environment https://github.com/crisberrios/static-starter
Germaine Pannell
@germainep
Mar 23 2015 21:37
yeah i love bourbon the mixings save you so much typing
Cristián Berríos
@crisberrios
Mar 23 2015 21:39
and let you have more consistency with the benefits of using sass
also better color manipuation darken($base-color,10%)
transparentize($header-color,0.4)
Germaine Pannell
@germainep
Mar 23 2015 21:39
i was just about to say something along the same lines
anandgraves
@anandgraves
Mar 23 2015 21:41
For using grids I've found using Susy very very versatile (http://susy.oddbird.net/)
Germaine Pannell
@germainep
Mar 23 2015 21:45
i might have to go back to using compass i’m not even sure why i stopped using it but I’ve been using grunt-watch to do my js uglify and css compiling and minify
Thiago Ferreira
@ThiagoFerreir4
Mar 23 2015 21:45
@germainep Hi!
Germaine Pannell
@germainep
Mar 23 2015 21:45
@crisberrios do you use scss or sass files
Thiago Ferreira
@ThiagoFerreir4
Mar 23 2015 21:46
are you using angular for timecoordinatorapp? :)
Germaine Pannell
@germainep
Mar 23 2015 21:46
Hi @ThiagoFerreir4
Cristián Berríos
@crisberrios
Mar 23 2015 21:46
scss for now, but might switch to sass in the future, since the code is cleaner
it goes well along jade and coffeescript
but no real advantages aside from that, so scss is more than enough for now
Germaine Pannell
@germainep
Mar 23 2015 21:49
@ThiagoFerreir4 I’m still woking it out right now cause I want to use D3.js to display a time-line for the meeting visuals and I don’t know much about D3.js yet to know if it will play nice with the logic being output from angular
Germaine Pannell
@germainep
Mar 23 2015 21:55
@crisberrios you are right. the Devtip youtube channel got me started with sass in my early stages so that’s what became familar with and you know how workflows go if they aren’t broke don’t fix them
Cristián Berríos
@crisberrios
Mar 23 2015 21:55
that's right
Harshal
@McQuinTrix
Mar 23 2015 21:55
Cristián Berríos
@crisberrios
Mar 23 2015 21:55
always room for improvement
but well oiled machines are more important
thanks @McQuinTrix, I'll give it a look when I have time :) already registered
Harshal
@McQuinTrix
Mar 23 2015 21:57
haha cool :P
@piecedigital Nodeschool lessons are not that hard, i was being lazy xD
Hey guys, could someone help please with that Bonfire?
Cristián Berríos
@crisberrios
Mar 23 2015 22:44
sure
what do you need to know?
Aza Noriega
@MegaGM
Mar 23 2015 22:44
@crisberrios Sorry, but I completely don't understand what to do xD
Cristián Berríos
@crisberrios
Mar 23 2015 22:45
(don't declare vars inside loops)
ok, you're almost at it
it's just you got the wording wrong
as most people :P
Harshal
@McQuinTrix
Mar 23 2015 22:46
!==
Cristián Berríos
@crisberrios
Mar 23 2015 22:46
it's the sum of odd fibs up to n
not the sum of the 1st n odd fibs
so, if you input 10
it's the odd fibs up to and including 10
Aza Noriega
@MegaGM
Mar 23 2015 22:48
That code freeze my browser :D
Could you gimme a hint why?
Harshal
@McQuinTrix
Mar 23 2015 22:49
its your fibonacci function most likely
Cristián Berríos
@crisberrios
Mar 23 2015 22:52
take into account that your fib function returns the nth fib (nothing wrong about that)
and for big numbers it can get pretty slow
Evan Davis
@davisec52
Mar 23 2015 23:06
I'd appreciate someone explaining the assertion errors for the Smallest Common Multiple bonfire. What does this mean: expect(smallestCommons([1,5])).to.equal(60);AssertionError:expected 1 to equal 60
Aza Noriega
@MegaGM
Mar 23 2015 23:24
@crisberrios I'm sorry, but
@all Could somebody give me some directions for dummies? The same Bonfire http://www.freecodecamp.com/bonfires/sum-all-odd-fibonacci-numbers
var Fib = function(n) {
  if (n <= 1) return n;
  return Fib(n-1) + Fib(n-2);
};
for(var i=0; i<= 4; i++)
  console.log(Fib(i));
Victor
@pahlsson
Mar 23 2015 23:29
@davisec52 "AssertionError:expected 1 to equal 60" means that the correct answer for the test is 60, but the value returned was 1
Cristián Berríos
@crisberrios
Mar 23 2015 23:29
^
your fib code runs fine
but for the bonfire
if you are asked to return all odd fibs and the passed value is 15
Evan Davis
@davisec52
Mar 23 2015 23:31
@crisberrios @pahlsson Thank you. Then I probably don't undestand what the bonfire is asking for. Any chance you could explain as if I were a 6 year old?
Cristián Berríos
@crisberrios
Mar 23 2015 23:31
1
1
2
3
5
8
13
you should only sum odd values in this range
@davisec52 it's smallest common for 1,2,3,4,5 not 1,5
1,5 is a range, not discrete values
Evan Davis
@davisec52
Mar 23 2015 23:34
Would not 1 be the smallest common denominator for that range?
Cristián Berríos
@crisberrios
Mar 23 2015 23:35
it's smallest common multiple
largest common denominator
or greatest
Evan Davis
@davisec52
Mar 23 2015 23:36
@crisberrios Ah, right. Thank you.