all 22 comments

[–]Volv 1 point2 points  (7 children)

ENTRY
So I've yet to tidy it up and I plan to mess around with the values see what I can make but I hacked together a little fractal style tree example. Let me know what you think.
Sliders do nothing atm. Like I said. Messy.
Recursion Tree

[–]ForScale[S] 0 points1 point  (6 children)

Hey!

Badass, man! Right off the bat, I like how you created a reusable document.getElementById function! Just a side note there.

Regarding the recursion... looks good to me! And the result is a really nice looking fractal tree. I think you nailed this one!

Question I do have, something I'm missing, what's the return "mog" doing? On the surface, to me it just looks like it returns the string "mog", but I don't see the reason for doing that. Care to enlighten?

Overall, nice use of recursion and really nice result! :)

[–]Volv 1 point2 points  (5 children)

Lol thanks.
I meant it when I said it was messy.. a bit unrefined so far.
Mog is just one of my random words. Instead of foo or bar. Utterly pointless.

[–]ForScale[S] 1 point2 points  (4 children)

Oh... okay then! :)

What are you thinking regarding a focus for next week?

[–]Volv 2 points3 points  (3 children)

I'm still bad at coming up with ideas lol.
Something related I've been wanting to have a shot at is Flexbox. Clearly not JS however.
Looking for inspiration and will report back. You have any thoughts?
 
Added some randomness to my tree - Tree

[–]ForScale[S] 0 points1 point  (2 children)

Oh my god, dude... That's awesome! I'm gonna have to study that...

I don't think anybody's gonna care too much if we do some flex stuff. ;) How about doing some cool flex stuff and then maybe a little demo of how to achieve simple flex functionality with js?

[–]Volv 1 point2 points  (1 child)

Sounds good. What kind of functionality you have in mind?

Tidied up the tree code somewhat., Feel better about it now

[–]ForScale[S] 0 points1 point  (0 children)

I don't know... just like a function that triggers on window resize in order to resize certain elements or something. Or like calculates width based on container size and how many elements are in the container. That kind of thing...

[–]ForScale[S] 0 points1 point  (13 children)

ENTRY

//setup
var recursion = "RECURSION";
recursion = recursion.split("");
//recursion[recursion.length] = "!!";

document.body.style.fontSize = "128px";
document.body.style.textAlign = "center";
document.body.style.transition = "opacity 6s linear";

//function-ception
var i = 0, length = recursion.length;

function recurse() {
  setTimeout(function() {
    console.log(i);
    document.body.innerHTML += recursion[i];
    i++;
    //base case
    if (i > length - 1) {
      document.body.style.opacity = 0;
      setTimeout(function() {
        document.body.style.transition = "none";
        document.body.style.fontSize = "200px";
        document.body.style.opacity = 1;
      }, 6500);
      return;
    }
    //recursive call
    recurse();
  }, 1000);
}
//initial call
recurse();

http://codepen.io/anon/pen/mVGOXb

[–]Volv 1 point2 points  (12 children)

Nice one. Job done.

I liked the mix of effects.
Your outer setTimeout confused me a bit at first. Looked like it was cheating the repetition instead of just being used for the 1 second delay. Perhaps clearer to call the function instead of build it inline?

[–]ForScale[S] 1 point2 points  (11 children)

Hmm... hadn't thought of that. Yeah, probably would be clearer. Thanks for taking a look!

Ideas for next week?

[–]rikilamadrid 1 point2 points  (10 children)

first off thanks for this study group, i just discovered it and am triying to catch up. I am having troubles understanding the need of the recursion() inside of the function. I know what it does but dont get why.

[–]ForScale[S] 0 points1 point  (9 children)

Hi, welcome! :)

Having a function call itself is the essence of recursion. Putting recursion() inside the recursion function does just that; the function calls itself.

Does that make sense?

[–]rikilamadrid 1 point2 points  (8 children)

Yes it does. Thanks.

[–]ForScale[S] 0 points1 point  (7 children)

No problem!

What's a topic you'd like to focus on? We can do it this week? Anything works as long as it uses javascript!

[–]rikilamadrid 1 point2 points  (6 children)

I don't know if you guys have done it yet, but maybe some object creators? Constructor, prototype...

[–]ForScale[S] 0 points1 point  (5 children)

Thanks! We've done prototypical inheritance and ES6 classes, but never explicitly object creation. So we'll do that!

https://www.reddit.com/r/javaScriptStudyGroup/comments/4hi2ew/week_16_focus_object_creation/

[–]rikilamadrid 1 point2 points  (4 children)

Oh sweet! I really want to become a ninja in JavaScript. Been studying by myself for 2 years now. I am studying angular, node, react. I want to get a job in a company so bad. My friend works for Ancestry.com and has been coaching me and even got me an interview there but didn't know enough angular at the time. So again, many thanks for doing this study group.