Forem

Cover image for Understanding Loops - A Tangible Example
Tyler V. (he/him)
Tyler V. (he/him)

Posted on

1

Understanding Loops - A Tangible Example

This is a submission for DEV Computer Science Challenge v24.06.12: One Byte Explainer.

Explainer

Image of a short JavaScript function that we'll be stepping through in the guide. First, it sets the age variable to 25 (or whatever your age is), then has a comment to grab a piece of paper and draw a birthday cake. Then there's a short while loop that while age is greater than 0, draw a candle then subtract 1 from the age variable. Outside of the loop is another comment that it's celebration time.

1 - Setup

Get paper, draw a cake, and set age to your age.

2 - Do Loop

age isn't 0, so draw a candle and subtract 1 from age.

3 - Checkup

Is age still greater than 0? Go to step 2
Otherwise, go to 4.

4 - 🎉

Celebration time!


Additional Context

I didn't include markdown in my count - ended up at 248 according to VS Code:

Image of text highlighted and showing 248 characters were selected

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay