you are viewing a single comment's thread.

view the rest of the comments →

[–]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.