Understanding Loops - A Tangible Example

terabytetiger

Tyler V. (he/him)

Posted on June 18, 2024

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

💖 💪 🙅 🚩
terabytetiger
Tyler V. (he/him)

Posted on June 18, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Dev challenge - Algorithms
devchallenge Dev challenge - Algorithms

June 24, 2024

One Byte Explainer: Large Language Models
Data Compression: Under 256 characters
devchallenge Data Compression: Under 256 characters

June 24, 2024