GithubHelp home page GithubHelp logo

overthinking-loops's Introduction

Overthinking Loops

There's just so many ways to do loops. for loops, while loops, recursive function calls, and a plethora of Array.prototype functions.

In this repo you will find examples of overthinking a stupid simple problem. If you don't learn anything new, at least have some fun!

Problem statement

There's a verry hungry caterpillar πŸ› sitting in a basket of fruits. As any other caterpillar would do, he starts eating them.

At some point, he will get full and if attempting to eat more, he will die (throw an error).

You have to feed the caterpillar fruits from the basket, and make sure not to let him eat to much!

PS: The caterpillar is picky and doesn't like 🍈.

Solutions

Most of the time, we use loops when working with arrays. But iteration doesn't have to be restricted to arrays: you can iterate on iterator objects, which you can create with a generator function.

I bet that there are plenty more ways to overthink loops, but for now in this repository we will play with these two:

You can find each in its folder ✨


Inspired from reading the story of the very hungry caterpillar from Eric Carle with my toddler πŸ‘ΆπŸ».

overthinking-loops's People

Contributors

stefanalexlupu avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.