These are chat archives for FreeCodeCamp/Help

9th
Feb 2015
Suzanne Atkinson
@AdventureBear
Feb 09 2015 05:40
how do you include an scss file in an index.html? I've searched the sass page (http://sass-lang.com/guide) and don't see it. I imported a codepen into a local project to play with it that seems to be using scss or sass, and not sure what I should name it and how to include it.
Cristián Berríos
@crisberrios
Feb 09 2015 05:40
you have to compile SCSS into CSS
Nathan
@terakilobyte
Feb 09 2015 05:40
I was under the impression it had to be compiled to a css file your page imports
ah @crisberrios is here, you're in good hands
back to geeking out on ramda for me!
Cristián Berríos
@crisberrios
Feb 09 2015 05:41
I'm using Koala under windows, once set, it'll monitor your scss files for changes and automatically compile them into css into your desired folder
Suzanne Atkinson
@AdventureBear
Feb 09 2015 05:41
go Nathan.
I'm using Webstorm. I have 3 files, html, a js, and a css (scss). How do I complie it?
Cristián Berríos
@crisberrios
Feb 09 2015 05:42
Well, you CAN install ruby, and support for rubygems, and sass, and configure everything inside webstorm so it'll use the CLI and compile scss into css
Suzanne Atkinson
@AdventureBear
Feb 09 2015 05:42
:(
Cristián Berríos
@crisberrios
Feb 09 2015 05:42
but apps like koala make it easier
Suzanne Atkinson
@AdventureBear
Feb 09 2015 05:43
I want to keep this simple...I"m just tryin gto adapt that codepen I found earlier.
Cristián Berríos
@crisberrios
Feb 09 2015 05:43
If you want to learn more about Sass, there's a course in CodeSchool.
Today I've started to build my personal site using Sass/bourbon/neat/bitters/refills
Suzanne Atkinson
@AdventureBear
Feb 09 2015 05:45
that's more than I want to do right now, lol. Do you have a minute for me to tell you what my mini project is? I feel like the JS will only take me 15 minutes once I get a way to see what I'm doing. I just liked the interface of this codepen. But codepen's screen is too small to compose in
but I DO appreciate the info and I can proceed with that on another branch of my education
do you want to share your page so far?
Nathan
@terakilobyte
Feb 09 2015 05:46
@crisberrios we'll have to pair one day so you can teach me all these things @crisberrios
Cristián Berríos
@crisberrios
Feb 09 2015 05:46
sure, just let me learn a little more I think CSS is where I'm most weak ATM
@AdventureBear just got part of the nav but I'll upload it to github pages so the source can be available, including SCSS.
Suzanne Atkinson
@AdventureBear
Feb 09 2015 05:52
cool
Evan Davis
@davisec52
Feb 09 2015 19:51
Hi. I'm having trouble counting the number of recursive calls in a function. The sample below is an attempt at finding the additive persistence of a number. As you can see, it converts the number to an array of integers and then reduces the sum of the integers. A call to console.log shows that the function makes recursive calls, but the indicator only shows 1 call.


function erg(num) {
    var indicator = 0;
    var numbers = [];
    if( num < 10) {
        return;
    }

        var intArr = num.toString().split("").map(function(a){return +a});
        var reduction = intArr.reduce(function(a, b){return a + b});
        numbers.push(reduction);
        indicator++;

    erg(reduction);
    return indicator; 
}
erg(1112233444);
Cristián Berríos
@crisberrios
Feb 09 2015 19:53
let's see
Evan Davis
@davisec52
Feb 09 2015 19:53
@crisberrios Hi
Cristián Berríos
@crisberrios
Feb 09 2015 19:54
ok, indicator is inside erg
so it'll create a new variable on each instance
you should either use a global variable, or pass the variable in the args and take it into consideration
Evan Davis
@davisec52
Feb 09 2015 19:56
How would I make it a global variable?
Cristián Berríos
@crisberrios
Feb 09 2015 19:56
defining it outside of the function
though in a "production enviroment" global variables aren't desirable.
Evan Davis
@davisec52
Feb 09 2015 19:57
Do you mean put it outside of the function?
Cristián Berríos
@crisberrios
Feb 09 2015 19:57
yes
This message was deleted
This message was deleted
hmm nah
Evan Davis
@davisec52
Feb 09 2015 19:58


var indicator = 0;
function erg(num) {

    var numbers = [];
    if( num < 10) {
        return;
    }

        var intArr = num.toString().split("").map(function(a){return +a});
        var reduction = intArr.reduce(function(a, b){return a + b});
        numbers.push(reduction);


    erg(reduction);
    return indicator++; 
}
erg(1112233444);
Still returns 1. However, each reduction and push to numbers is treated as a separate instance. I don't really understand why or how to put each call into just one array called numbers ( instead of separate instances of numbers).
Cristián Berríos
@crisberrios
Feb 09 2015 20:00
wait
Evan Davis
@davisec52
Feb 09 2015 20:01
ok
Cristián Berríos
@crisberrios
Feb 09 2015 20:02
how much should the answer be?
Evan Davis
@davisec52
Feb 09 2015 20:03
In this case, it is 2.
Nathan
@terakilobyte
Feb 09 2015 20:03
throw a console.log after your var reduction declaration
find out what the value is
Cristián Berríos
@crisberrios
Feb 09 2015 20:03
well, remember that indicator++
means you are returning indicator
and THEN increasing it's value
also, when number is <10 you won't do anything with indicator
take those 2 into consideration and check the algorithm
Evan Davis
@davisec52
Feb 09 2015 20:05
2
I can change the base number to if(num > 1) but that does not give a result. I don't really see how to modify the the indicator.
Evan Davis
@davisec52
Feb 09 2015 20:10
I attempted briefly to set this up with for-loops. I can convert the number to an array, use the loop to reduce the integers, but just have no idea how to count the number of reductions.
Cristián Berríos
@crisberrios
Feb 09 2015 20:42
it should be easy with a while()
while num>9 array, map, reduce, increment
Evan Davis
@davisec52
Feb 09 2015 20:57

var indicator = 0;
function erg(num) {

    var numbers = [];
    if( num < 9) {
        return;
    }
    while(num) {
        var intArr = num.toString().split("").map(function(a){return +a});
        var reduction = intArr.reduce(function(a, b){return a + b});
        numbers.push(reduction);
        indicator++;
    }

    erg(reduction);
    return indicator; 
}
erg(1112233444);
This shoots off into an infinite loop.
Cristián Berríos
@crisberrios
Feb 09 2015 20:59
variables aren't bound to blocks, so once defined they don't "die" on each loop
and the conditional you are using for while is just "num" so it'll loop forever
Evan Davis
@davisec52
Feb 09 2015 21:01
doesn't matter, it still goes into an infinite loop whether I put < 9 or >1
Cristián Berríos
@crisberrios
Feb 09 2015 21:01
and also you are still using recursion (which is a valid way)
Evan Davis
@davisec52
Feb 09 2015 21:01
Ah, I'll remove the recursion

var indicator = 0;
function erg(num) {

    var numbers = [];

    while(num < 9) {
        var intArr = num.toString().split("").map(function(a){return +a});
        var reduction = intArr.reduce(function(a, b){return a + b});
        numbers.push(reduction);
        indicator++;
    }
    return indicator; 
}
erg(1112233444);
removing recursion cut the infinite loop, but the indicator doesn't increment.

 num = eval(String(num).split("").join("+"));
         count += 1;
This code does work in the while loop and also increments. Any idea why the first code sample does not work?
Cristián Berríos
@crisberrios
Feb 09 2015 21:11
let's go to floobits
Evan Davis
@davisec52
Feb 09 2015 21:12
On my way . . .
Ashley Drake
@aldraco
Feb 09 2015 21:42
hello - I have a quick question for someone proficient with node/express and the command line
I type "node app.js" to test out my app, and the CLI seems to "hang," i.e. it never gets back to the username: filepath$ input prompt. Is that normal?
I'm asking because i'm working on the Express.js challenge and trying to follow along; the teacher issues a CURL from the command line with the server running, but I can't do that.
TIA
Cristián Berríos
@crisberrios
Feb 09 2015 21:52
sure, as it's running in the foreground
are you running a VM with linux?
Ashley Drake
@aldraco
Feb 09 2015 21:53
not sure what you mean by VM... I am able to get to the page on localhost:port, though
I'm on a mac
Cristián Berríos
@crisberrios
Feb 09 2015 21:55
ok, but you are running node from CLI
Ashley Drake
@aldraco
Feb 09 2015 21:55
correct
Cristián Berríos
@crisberrios
Feb 09 2015 21:56
well, easiest option is to just open another terminal window
if you want to run Node in the background you can do so, but then you won't be able to end the process without killing it
also, you won't see the debug outpput
Ashley Drake
@aldraco
Feb 09 2015 21:57
ok. so running it directly from CLI is "foreground," and running it in the background would require a virtual machine? is that correct?
and the extra window did what I needed, so thanks for that
Cristián Berríos
@crisberrios
Feb 09 2015 21:59
well, running it in the background means it will keep running even if you close the terminal window and it won't "freeze" it
but then, to close it, you have to use the kill command
I don't know if it's available in OSX, but since it's Unix based most likely it is, or something similar
Ashley Drake
@aldraco
Feb 09 2015 22:00
awesome. thanks, I will do some research for that.
I appreciate it
Cristián Berríos
@crisberrios
Feb 09 2015 22:01
A VM is a "virtual machine" where you can run windows, linux or other OS inside a sandboxed enviroment using a virtualization software like virtualbox or VMware
Ashley Drake
@aldraco
Feb 09 2015 22:02
i see